Skip to content

Suggestion: typescript module resolution support #2254

Description

@ValeryVS

Update 1

app/
shared/
api-module/
ui-module/
heroes/
heroes-list.component.ts
// tsconfig.json
{
"compilerOptions": {
"paths": {
"#shared": [
"app/shared"
]
}
}
}
// shared/index.tsexport*from'./api-module/api.module';export*from'./api-module/api.service';export*from'./api-module/ui.module';export*from'./api-module/ui-notification.service';export*from'./api-module/ui-select.service';
// app/heroes/heroes-list.component.tsimport{Component}from'@angular/core';import{ApiService}from'#api-module';import{UINotyficationService,UISelectService}from'#ui-module';import{HeroesService}from'./heroes.service.ts';

Original Post

TypeScript module resolution
microsoft/TypeScript#5039

Configs
Add baseUrl and, optionaly, paths to tsconfig.json

{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": [ "modules/*" ]
}
}
}

Add modules to angular-cli.jsonapps

{
"apps": [
{
"modules": [
"src/modules"
]
]
}

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 or src/app/shared to angular-cli.json and get rid of relative paths when we load services in app.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions