Skip to content

Possible problem with multiple tsconfig.json files in subdirectories #10084

Closed

Description

@a8775
  • VSCode Version: 1.4.0-insider
  • OS Version: Windows 10

Please see the demonstration project on git: https://github.com/a8775/vscode-tsconfig

Setup

Tested with the following versions:

  • nodejs 6.2.0
  • typescript 1.8.9
  • typings 1.3.2

Steps to reproduce the problem:

  1. Clone the project
  2. In project directory execute commands:
    • npm install - to download dependencies
    • typings install - to download required typings files

TypeScript

In working directory run the command: tsc -p .

Should compile correctly.

vscode

Select the right file in a editor window and compile the project:

  1. Select the the file: ./MySubProject/mySubProjectFile.ts
  2. Compile the project: Ctrl-Shift-B

The project should be compiled without errors.

Now press space in any syntactically correct place. You get compilation errors.

Activity

  1. dbaeumer commented on Aug 4, 2016

    @dbaeumer
    Member

    I was able to reproduce this.

  2. dbaeumer commented on Aug 4, 2016

    @dbaeumer
    Member

    The problem is that the code inside the mySubProject folder doesn't see the code in the typings folder. The compiler only looks from the tsconfig.json file downwards. If you want to keep your layout you can do the following: add a file typings.d.ts with the following content to the MySubProject folder

    /// <reference path="../typings/index.d.ts" />
    

    This makes it work correctly.

  3. added
    typescriptTypescript support issues
    *questionIssue represents a question, should be posted to StackOverflow (VS Code)
    on Aug 4, 2016
  4. a8775 commented on Aug 4, 2016

    @a8775
    Author

    Thank you Dirk Bäumer (@dbaeumer) for that hint.

    I have solved the problem by removing/renaming the second tsconfig.json in MySubProject.

    My main point was that the VSCode is not consistent and it looks like a bug:

    1. Once I compile the project and VSCode UI shows zero errors,
    2. After that I touch any key eg. space suddenly the errors appears.

    What's more, logically when I compile the top project with tsc it's not showing any error and so the VSCode shouldn't as well.

    I guess the problem is in the VSCode that it's using both of the tsconfig.json contrary to the tsc -p . that use only one found in the path passed as a parameter. I believe VSCode should do exactly the same.

    The more I think about the problem, I am inclined to the opinion that it is a BUG in VSCode.

    The compiler only looks from the tsconfig.json file downwards.

    Dirk Bäumer (@dbaeumer) I read again your answer and I'm not sure you saw that in this test project are TWO tsconfig.json files.

    I totaly agree and understand that compiler is looking only downwards but I think it should start with the same path as tsc compiler.

  5. dbaeumer commented on Aug 11, 2016

    @dbaeumer
    Member

    I do understand that the project has two tsconfig.json files and the problem is a misalignment between the tsc and the tsserver in terms of the project team. I will move the issue to the TS to comment on. For the TS team:

    • when running tsc -p . it compiles the files in MySubProject using the tsconfig.json from root.
    • when open a file in the tsserver from MySubProject the tsconfig.json from the MySubProject folde is used.

    This results in different project scopes.

  6. removed
    *questionIssue represents a question, should be posted to StackOverflow (VS Code)
    typescriptTypescript support issues
    on Aug 11, 2016
  7. dbaeumer commented on Aug 11, 2016

    @dbaeumer
    Member

    This issue was moved to microsoft/TypeScript#10283

  8. added
    typescriptTypescript support issues
    upstreamIssue identified as 'upstream' component related (exists outside of VS Code)
    on Aug 11, 2016
  9. a8775 commented on Aug 11, 2016

    @a8775
    Author

    Dirk Bäumer (@dbaeumer) sorry I was raising the problem again, I would like the tool I use every day was perfect for everyone :)

    I appreciate the work of all team, thanks a lot!

  10. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

typescriptTypescript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions