-
Notifications
You must be signed in to change notification settings - Fork 12k
Suggestion: typescript module resolution support #2254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This also seems convenient to me from a syntax point of view. But I think there are some "cons" to go with the "pros" above - in particular around ease of understanding. As developers first enter the typescript and Angular ecosystem, among 1000 other things they need to understand import statements. In the current default behavior, this can be explained in just a few seconds: import paths which start with "." are importing other modules in the application being worked on. Other imports (from paths that don't start with ".") are importing libraries, code written in other projects or by other people. The typescript configuration described above would add more complexity to the current easy-to-understand default situation. So while I like it for my own convenience, I think this should be weighed as a trade-off before such a feature is put in to the default configuration CLI creates. |
I agree, that this feature can add mode complexity. Probably, the most frustrating is Also, sometime we want to make shared module. With a few services. We can make it, as a separate package and import from Wrap in. For example:
Then, we be able to place shared modules into
// heroes-list.component.ts
import { Component } from '@angular/core';
import { HeroesService } from './heroes.service.ts';
import { ApiService } from '#api-module';
import {
UINotyficationService,
UISelectService
} from '#ui-module'; |
First post updated. Actually, new developer can simply use relative paths until he will encounter the tsconfig.json's path option. |
It seems I miss older similar issue #1465 |
Fixed by #2470 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Update 1
Original Post
TypeScript module resolution
microsoft/TypeScript#5039
Configs
Add
baseUrl
and, optionaly,paths
totsconfig.json
Add
modules
toangular-cli.json
apps
Realisation
ValeryVS@c812fe8
Pros
Then we will be able to write
import { MyModule } from 'my';
and it will load module from
src/modules/my/index.ts
We aslo can write
src/app
orsrc/app/shared
toangular-cli.json
and get rid of relative paths when we load services in app.The text was updated successfully, but these errors were encountered: