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

language server ignores multiple tsconfig files #49210

Closed
DetachHead opened this issue May 23, 2022 · 1 comment
Closed

language server ignores multiple tsconfig files #49210

DetachHead opened this issue May 23, 2022 · 1 comment

Comments

@DetachHead
Copy link
Contributor

DetachHead commented May 23, 2022

Bug Report

if a project has multiple tsconfig files (eg tsconfig.json and tsconfig.other.json) then the language server seems to ignore the one that isn't named tsconfig.json

🔎 Search Terms

language server multiple tsconfig

🕗 Version & Regression Information

4.8.0-dev.20220522

Playground github Link

https://github.com/DetachHead/typescript-nodejs-project/tree/global-types-issue

💻 Code

main config

// tsconfig.json
{
    "compilerOptions": {
        "target": "es3"
    },
    "include": ["src/main.ts"]
}
// src/main.ts
export {}

"".replaceAll // error

other config

// tsconfig.json
{
    "compilerOptions": {
        "target": "es2021"
    },
    "include": ["src/other.ts"]
}
export {}

"".replaceAll // error ???

🙁 Actual behavior

the following error in other.ts:

Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later.

image

🙂 Expected behavior

no error when accessing the globally defined pm object in either file

@DetachHead DetachHead changed the title language server doesn't resolve globally declared types when using types property in tsconfig when it has a name other than tsconfig.json language server ignores some compiler options in tsconfig when it it has a name other than tsconfig.json May 23, 2022
@DetachHead DetachHead changed the title language server ignores some compiler options in tsconfig when it it has a name other than tsconfig.json language server ignores some compiler options in tsconfig when it has a name other than tsconfig.json May 23, 2022
@DetachHead DetachHead changed the title language server ignores some compiler options in tsconfig when it has a name other than tsconfig.json language server ignores multiple tsconfig files May 23, 2022
@MartinJohns
Copy link
Contributor

See #33094.

@DetachHead DetachHead closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2022
lobsterkatie added a commit to getsentry/sentry-javascript that referenced this issue Jun 2, 2022
It is well-documented (see 1-6 below) that VSCode doesn't support setups like ours, where multiple tsconfig files coexist in a single directory. Strangely, though, it is only recently that this has become a problem, with VSCode at random intervals forgetting that it's ever heard of `expect` or `describe` (because it's not seeing `tsconfig.test.json`, but taking a while to realize it).

There is an open issue[7] tracking the addition of support for this, but it's been open for a long time, with little movement. In the meantime, this solves the problem by adding placeholder `test/tsconfig.json` files to each package, each pointing to its corresponding `tsconfig.test.ts` file. I went with this approach over simply moving and renaming the existing test tsconfigs because this allows us to stay consistent in having all flavors of tsconfig for a package live at the package root level, and provides an easy way to reverse this workaround, should VSCode ever fix the underlying problem.

[1] angular/angular-cli#5175
[2] microsoft/TypeScript#49210
[3] microsoft/vscode#107750
[4] microsoft/vscode#12463
[5] sillsdev/bible-karaoke#175
[6] microsoft/TypeScript#8435
[7] microsoft/TypeScript#33094
lobsterkatie added a commit to getsentry/sentry-javascript that referenced this issue Jun 3, 2022
It is well-documented (see 1-6 below) that VSCode doesn't support setups like ours, where multiple tsconfig files coexist in a single directory. Strangely, though, it is only recently that this has become a problem, with VSCode at random intervals forgetting that it's ever heard of `expect` or `describe` (because it's not seeing `tsconfig.test.json`, but taking a while to realize it).

There is an open issue[7] tracking the addition of support for this, but it's been open for a long time, with little movement. In the meantime, this solves the problem by adding placeholder `test/tsconfig.json` files to each package, each pointing to its corresponding `tsconfig.test.ts` file. I went with this approach over simply moving and renaming the existing test tsconfigs because this allows us to stay consistent in having all flavors of tsconfig for a package live at the package root level, and provides an easy way to reverse this workaround, should VSCode ever fix the underlying problem.

[1] angular/angular-cli#5175
[2] microsoft/TypeScript#49210
[3] microsoft/vscode#107750
[4] microsoft/vscode#12463
[5] sillsdev/bible-karaoke#175
[6] microsoft/TypeScript#8435
[7] microsoft/TypeScript#33094
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

No branches or pull requests

2 participants