Skip to content
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

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

Closed
a8775 opened this issue Aug 3, 2016 · 6 comments
Closed

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

a8775 opened this issue Aug 3, 2016 · 6 comments
Assignees
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@a8775
Copy link

a8775 commented Aug 3, 2016

  • 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.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 4, 2016

I was able to reproduce this.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 4, 2016

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.

@dbaeumer dbaeumer closed this as completed Aug 4, 2016
@dbaeumer dbaeumer added typescript Typescript support issues *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Aug 4, 2016
@a8775
Copy link
Author

a8775 commented Aug 4, 2016

Thank you @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.

@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.

@dbaeumer
Copy link
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.

@dbaeumer dbaeumer removed *question Issue represents a question, should be posted to StackOverflow (VS Code) typescript Typescript support issues labels Aug 11, 2016
@dbaeumer dbaeumer removed their assignment Aug 11, 2016
@dbaeumer
Copy link
Member

This issue was moved to microsoft/TypeScript#10283

@dbaeumer dbaeumer added typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Aug 11, 2016
@dbaeumer dbaeumer self-assigned this Aug 11, 2016
@a8775
Copy link
Author

a8775 commented Aug 11, 2016

@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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants