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

Can load tsconfig from subfolders #349

Closed
wants to merge 1 commit into from

Conversation

alperencaliskan
Copy link

My .net core workspace is structured like this.

Workspace
├── Vuecore.Service
├── Vuecore.Shared
└── Vuecore.Web <─ this is where tsconfig.json exists.

Extension doesn't load tsconfig.json if the file is not in workspace but subfolders of workspace. Result of this leads to not applying config options for typescript. For example "Experimental support for decorators is a feature that is subject to change in a future release." warning occurs. And possibly the reason for #301 issue.

This fix makes language service to search tsconfig.json in currently editing file's folder to the root of workspace until it finds config file. Seems to work. There is some duplicate code but revision is welcome.

@octref
Copy link
Member

octref commented Jul 24, 2017

Sorry has been & will be a bit busy. Will take a look later this week.

@WoLfulus
Copy link

This is also happening for me too.

In my case I do have client/tsconfig.json and server/tsconfig.json

Copy link
Member

@octref octref left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think duplicating code is good...

Also what's your reasoning for choosing lastFile for figuring out where the tsconfig/jsconfig is?

@HerringtonDarkholme
Copy link
Member

OP wants to support multiple subprojects in one editor window.
But I worry changing tsconfig on fly would break TS internal invariant.

@octref Do you know how vscode handle subprojects?

@octref
Copy link
Member

octref commented Jul 25, 2017

https://code.visualstudio.com/updates/v1_14#_preview-multi-root-workspaces

I haven't looked into the details though.

@alperencaliskan
Copy link
Author

Actually i just want vetur to load tsconfig.json from where i want. Because in my case tsconfig.json is not in root directory. Making tsconfig file search path as an option is enough for me. Then i found out ts.findConfigFile function already does what i want. So this fixes my problem and maybe others'.

@octref ts.findConfigFile method looks for config file in the given path first (the file you are editing in this case) and goes up to root "/" folder (i assumed only up to project root but i was wrong) and uses the first config file found.

@WoLfulus
Copy link

WoLfulus commented Jul 25, 2017

It doesn't solve my case though. I have multiple projects inside the same folder.

Copy link
Member

@HerringtonDarkholme HerringtonDarkholme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing configuration file on fly will cause a lot of unexpected errors.

VSCode relies on tsserver to handle multiple projects. And tsserver just maintains a set of language services for different projects.

See https://github.com/Microsoft/TypeScript/blob/master/src/server/editorServices.ts#L1465

and

https://github.com/Microsoft/TypeScript/blob/master/src/server/editorServices.ts#L360

and

https://github.com/Microsoft/TypeScript/blob/master/src/server/project.ts#L116

@alperencaliskan
Copy link
Author

alperencaliskan commented Jul 26, 2017

@WoLfulus if your project structured like this
Workspace
├── client/
         ├── tsconfig.json
         ├── src
                  ├── App.vue
├── server/tsconfig.json

then when editing App.vue it will use client/tsconfig.json and should work for you.

@HerringtonDarkholme Vscode can use different configurations for different *.ts files if there are multiple tsconfig files. We need to make this work for *.vue files. Attached a test project, open root folder as vscode workspace. "noImplicitAny" enabled for client and disabled for server. It works as expected. Tested on 1.14.2 (not preview). I think this feature is not related to "Multi Root Workspaces" because i am not using insiders build.

testproj.zip

Edit: tree structure was not correct on markdown.

@HerringtonDarkholme
Copy link
Member

I have listed related source code and explained how vscode support multiple tscofig.

In short, we need multiple language service, not changing configuration.

@octref
Copy link
Member

octref commented Jul 27, 2017

Yeah, I suggest now you could try editing your Vuecore.Web in a window and open other projects in alternative windows for editing. Or giving Insider a try for multi-workspace.

@alperencaliskan
Copy link
Author

Ok then, thanks for your time.

@archseer
Copy link
Contributor

@HerringtonDarkholme Could this at least be merged as a temporary solution for #815? I'd rather have a buggy fix for #815 than have no fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants