Skip to content

(bug) Angular workspace multiple tsconfig.json files with invalid names. #15662

Closed
@Domvel

Description

@Domvel

🐞 Bug report

It's more a problem rather than a bug.

Command

- [x] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Since workspaces exists with the special tsconfig.json name. Keep reading...

Description

An Angular workspace (see docs) creates projects with one tsconfig.json file in the root and more tsconfig.json files for each project which extends the root config json. That's ok. But the names of the tsconfig files in the projects are not valid names to work with e.g. vscode.

In a project there are two tsconfig files.

  • tsconfig.spec.json
  • tsconfig.app.json

The problem is that the IDE (or other tools) can't detect this file, because of the special name.
The valid name should be tsconfig.json like the root file.

For example:
If you add an exclude in the tsconfig.app.json to exclude other apps in the project folder except itself and the shared-lib, it will not work for e.g. the auto import of vscode. Because the tsconfig.app.json is not load. If I rename it to tsconfig.json it works.
Background: In my case I do not want to get suggestions about imports of other apps in the project folder. Only fromthe shared-folder. This should be a default configuration of Angular workspace, but it's another issue.

🔬 Minimal Reproduction

Just greate a worksapce.

ng new my-workspace --createApplication="false"
ng generate application app1
ng generate application app2

or simple greate a project without angular to see the problem.

auto-import-issue
|= projects
|  |= app1
|  |  |- main.ts
|  |  |- page.ts
|  |  \- tsconfig.app.json
|  \= app2
|     |- main.ts
|     |- page.ts
|     \- tsconfig.app.json
\- tsconfig.json

🌍 Your Environment


Angular CLI: 8.3.5
Node: 10.15.3
OS: win32 x64
Angular: 8.2.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.801.3
@angular-devkit/build-angular      0.803.5
@angular-devkit/build-ng-packagr   0.803.5
@angular-devkit/build-optimizer    0.803.5
@angular-devkit/build-webpack      0.803.5
@angular-devkit/core               8.1.3
@angular-devkit/schematics         8.1.3
@angular/cli                       8.3.5
@ngtools/webpack                   8.3.5
@schematics/angular                8.3.5
@schematics/update                 0.803.5
ng-packagr                         5.5.1
rxjs                               6.4.0
typescript                         3.5.3
webpack                            4.39.2

Other informations

Maybe the enviroment like vscode or typescript should wildcard the tsconfig.*.json.
But in this case we have two tsconfig.json files in a project. For spec and app. This is a conflict.
The IDE (vscode) should grab the angular.json? You can't expect it. But the Angular team could request it. ... I'm not sure If I understood the intention of the Angular team about these tsconfig files. Maybe it is intended that the tsconfig files are invalid names to prevent loading from other tools like vscode and only Angular should handle it.

I need the tsconfig sometimes for declaring paths. But at this moment I just want to ignore all other apps in the project folder to prevent auto import etc. from other projects but the shared-lib folder.

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