microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.65k stars 28.67k forks source link

VSCode unable to resolve `extends: "my-npm-tsconfig"`, requires an extra `/tsconfig.json` #131643

Closed fregante closed 2 years ago

fregante commented 3 years ago

Issue Type: Bug

TypeScript can resolve this configuration correctly but VSCode can't

{
    "extends": "@sindresorhus/tsconfig"
}

Clicking it brings up this VSCode error

Unable to read file './node_modules/@sindresorhus/tsconfig.json' (Error: Unable to resolve non-existing file './node_modules/@sindresorhus/tsconfig.json')

The following is clickable in VSCode, but it shouldn't be necessary:

{
    "extends": "@sindresorhus/tsconfig/tsconfig.json"
}

npm package: https://github.com/sindresorhus/tsconfig/blob/640e4bfe1172e27d59bf4d73a2c5df517cc01e1d/package.json#L12

Side note: Both configurations are clickable in WebStorm

VS Code version: Code 1.59.1 (3866c3553be8b268c8a7f8c0482c0c0177aa8bfa, 2021-08-19T11:53:52.479Z) OS version: Darwin x64 20.6.0 Restricted Mode: No

Extensions (18) Extension|Author (truncated)|Version ---|---|--- vscode-css-formatter|aes|1.0.1 sidebar-markdown-notes|ass|1.0.4 vscode-fish|bma|1.0.24 prettier-vscode-standard|bys|0.22.1 vscode-mac-color-picker|dae|1.0.2 vscode-eslint|dba|2.1.23 prettier-vscode|esb|8.1.0 codespaces|Git|1.0.3 remotehub|Git|0.13.4 vscode-github|Kni|0.30.6 dotenv|mik|1.0.1 sublime-keybindings|ms-|4.0.9 ghosttext|ngy|0.0.2 docthis|oou|0.8.2 vscode-fileutils|sle|3.4.5 svelte-vscode|sve|105.3.5 tabnine-vscode|Tab|3.4.22 shellcheck|tim|0.15.2
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 pythonvspyt678:30270856 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyt639:30300192 pythontb:30283811 pythonvspyt551cf:30345471 pythonptprofiler:30281270 vsdfh931cf:30280410 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 pythonvsuse255:30340121 vscod805:30301674 pythonvspyt200:30340761 vscextlang:30333561 binariesv615:30325510 pythonvssor306:30344512 bridge0708:30335490 vstre464cf:30350173 bridge0723:30353136 javagetstartedc:30351792 vsdyn478:30356813 ```
vscodebot[bot] commented 3 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

zardoy commented 2 years ago

Another problem is that VSCode always tries to resolve it from the root node_modules (even if it doesn't exist) of the workspace, absolutely ignoring nearest node_modules. So, even "extends": "@sindresorhus/tsconfig/tsconfig.json" doesn't work in my case.

mjbvz commented 2 years ago

I looked into this but ultimately don't feel it's worth handling given the lack of additional feedback on the issue and complexity it would add to our code

Most tsconfig packages I've found recommend using the full path even if it's not strictly required: https://www.npmjs.com/package/@tsconfig/recommended

zardoy commented 2 years ago

@mjbvz what are you doing??? This is definitely a bug, since it doesnt match TS and webstorm behavior. Please reopen the issue, I already looked at the problem in the past and know the quickfix for it. When I looked at that hardcoded mechanism it looked incredibly stupid, so I cant believe you actually looked at the problem.

mjbvz commented 2 years ago

@zardoy Please submit a PR then

zardoy commented 2 years ago

Aright! I'll try to do it tomorrow