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

tsconfig.json as higher priority in Visual Studio #5287

Closed
AbubakerB opened this issue Oct 16, 2015 · 19 comments
Closed

tsconfig.json as higher priority in Visual Studio #5287

AbubakerB opened this issue Oct 16, 2015 · 19 comments
Assignees
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio

Comments

@AbubakerB
Copy link
Contributor

Hey guys,

A question, what is the reason as to why a project file supersedes a tsconfig in Visual Studio? (#4820 comment)

I'd assume that as soon as I introduce a tsconfig.json at any sub-directory level, that tsconfig.json should override the typescript compilation options for that level and below, unless another tsconfig exists within.
That's what makes most sense to me.

Is there a specific reason as to why the current method doesnt work like that?
The action of me adding a tsconfig.json in a project specifically means, i want to override the compilation options, right?

Project(MVC5) / file.ts --> file.ts should use default project TS options
Project(MVC5) / scripts / tsconfig1.json
Project(MVC5) / scripts / file2.ts --> file2.ts should use tsconfig1 options
Project(MVC5) / scripts / framework / tsconfig2.json
Project(MVC5) / scripts / framework / file3.ts --> file3.ts should use tsconfig2 options

Thanks for your time

@AbubakerB AbubakerB changed the title tsconfig.json as highest priority in Visual Studio tsconfig.json as higher priority in Visual Studio Oct 16, 2015
@DanielRosenwasser
Copy link
Member

I think the intuition is that a project file is a more committed/custom solution that the user has in mind. After all, if you have a project file, why wouldn't you just set your compilation settings there?

@mhegazy and @paulvanbrenk can correct me if I'm wrong.

@paulvanbrenk
Copy link
Contributor

tsconfig.json should have higher priority, since we should default to code sharing across editors. The Project properties in VS need updating to reflect that thinking, but the current implementation should work that way.

@mhegazy mhegazy added Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio labels Oct 16, 2015
@mhegazy mhegazy added this to the TypeScript 1.8 milestone Oct 16, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Oct 26, 2015

Also note, we will need a way to switch off/on compile-on-save for projects managed by tsconfig.json. compileOnSave property at the top level is what atom-typescript uses and seems like a good option. see #2326 for more details.

@ffMathy
Copy link

ffMathy commented Nov 17, 2015

Any updates on this? Is it still going to be part of Typescript 1.8? I rely on it heavily. I can't continue development until it is fixed.

@paulvanbrenk
Copy link
Contributor

Yes, there is still work planned here for 1.8.

However looking at your project.. I don't think this will work as you expect. The tsconfig.json support will always override the project settings.. and once you introduce a tsconfig.json file we'll ignore all .ts files which are not part of a tsconfig.json scope.

Further we won't support nested tsconfig.json files, a tsconfig.json context will contain all files in it's cone. Further the naming of tsconfig.json is prescriptive... tsconfig1.json will not work. (I'm assuming your sample uses that as an illustration).

So for your project this results in the following compilation contexts:

Project(MVC5) / file.ts
Project(MVC5) / scripts / tsconfig.json (1)
Project(MVC5) / scripts / file2.ts
Project(MVC5) / scripts / framework / tsconfig.json (2)
Project(MVC5) / scripts / framework / file3.ts

tsconfig.json (1) will create an output containing the code from both file2.ts and framework/file3.ts.
tsconfig.json (2) will create an output containing the code from framework/file3.ts.

If you want to separate file2 and file3, you'll have to put them in 2 sub-directories of scripts.

Project(MVC5) / scripts / app / tsconfig.json (1)
Project(MVC5) / scripts / app / file2.ts
Project(MVC5) / scripts / framework / tsconfig.json (2)
Project(MVC5) / scripts / framework / file3.ts

Also this currently works in the language service, but the only way to compile this is to use a grunt/gulp pipeline.

@ffMathy
Copy link

ffMathy commented Nov 17, 2015

That sounds brilliant to me. Exactly as I want it. Explicit and minimal.

@AbubakerB
Copy link
Contributor Author

Thanks @paulvanbrenk!!! looking forward to it!

@ffMathy
Copy link

ffMathy commented Dec 7, 2015

Great work on this. Now I can't wait!

@kasajian
Copy link

This may be an obvious point, but if I have a developer add a .ts file in Visual Studio, will it go into both the .csproj and tsconfig.json files? Or will Visual Studio have a visual way to show the contents of the tsconfig.json file?

Or, are we saying that, when someone is using tsconfig.json file for web project, they should not add .ts files to Visual Studio at all, but only add them to tsconfig.json?

I'm not necessarily saying that any of these options is preferred nor that they are invalid. But curious if there's been discussion about various common workflows.

@paulvanbrenk
Copy link
Contributor

We expect most users to not explicitly add ts files to their tsconfig.json file, but depend on the logic in the compiler to automatically pull in all .ts files. This way they would just add them to Visual Studio.

You will still be able to see the compiler context for the tsconfig.json file using the Virtual Project option. If there's a lot of feedback we can decide to make changes later, but for now we want to focus on the most common scenario.

@kasajian
Copy link

Paul, thank you. I'm trying to figure out how I'll be able to use this feature in the future to solve a problem that I have right now that forces me to abandon the TS build step altogether from within Visual Studio and issue tsc.exe commands directly from the "pre-build" step from the web project (via a batch file). Ugly, but I don't have another solution. The issue that I'm talking about is documented here: #5448 -- I suggest looking at the specific comment which starts with the text "The following is what I hope to be a better explanation of the issue that I'm facing". I believe 5287 and 4714 will address my use-case indirectly.

Because neither feature request directly address my use case, I'm trying to put the pieces together now to see how it will work. That way, if there's some subtle thing that I need, I can contribute to the discussion as the features get implemented.

@paulvanbrenk
Copy link
Contributor

@kasajian I think the multiple tsconfig.json support will do exactly what you want.

@kasajian
Copy link

cool. So how would that work? Like, would I specify in Visual Studio which tsconfig file a particular .ts file is associated with?

@paulvanbrenk
Copy link
Contributor

You use the files property, as discussed here: https://github.com/Microsoft/TypeScript/wiki/tsconfig.json

@kasajian
Copy link

Okay, then I'll circle back to what I said previously to which you responded "We expect most users to not explicitly add ts files to their tsconfig.json file, but depend on the logic in the compiler to automatically pull in all .ts files. This way they would just add them to Visual Studio."

So then it goes to reason that using the Visual Studio UI to add files to the project is really only useful in the case there's only a single tsconfig.json file. Alternatively, the user will have to add .ts files to both the Visual Studio project and the tsconfig.json file.

To me, the story isn't very clear, and I realize that may be because we simply haven't thought through that far ahead. I'm just trying to wrap my head around the user workflow for the user who wants to do what I indicated in 5448.

thank you.

@paulvanbrenk
Copy link
Contributor

Or you could do something like this

/app-root
  /admin
    /tsconfig.json << no files property, pulls in admin.ts
    /admin.ts << automatically included
  /play
    /tsconfig.json << no files property, pulls in play.ts
    /play.ts

@kasajian
Copy link

beautiful

@paulvanbrenk
Copy link
Contributor

Support for multiple tsconfig.json files is part of 1.8, as is support for more project types.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 26, 2016
@oising
Copy link

oising commented Feb 12, 2016

Not quite fixed - still some cases not covered:
#7044

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript Visual Studio Integration with Visual Studio
Projects
None yet
Development

No branches or pull requests

7 participants