You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
jsconfig Not Picked Up When tsconfig is Present #15869
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue
That is actually by design. tsconfig.json is always given preference, and if it is not applicable it is skipped. i would like to get more user input on this before making a decision whether to change the current design or not.
I have a large project written in Javascript that we want to migrate to TypeScript. The process will be slow and take a long time but meantime all import aliases are broken on javascript for this reason. It'd be nice if VSCode would implement aliases on both file types or at least fallback to jsconfig.json on .js files.
Reacted by chaosforfun, Christopher X Gerber, dkocich, Irislm, Nick Breaton, Jonathon, Dina, Douglas Gaskell, mimaty-lifull, Rohit and 12 more
I have a mixed JS/TS codebase, and I need to specify a paths object in order to get my Webpack aliases to work with VS Code, but I don't want to display TS errors in JS files. Is there way to achieve this?
My first thought was to have a both a jsconfig.json and a tsconfig.json, but apparently having the former present is the same as specifying allowJs: true in the latter?
I have a mixed JS/TS codebase, and I need to specify a paths object in order to get my Webpack aliases to work with VS Code, but I don't want to display TS errors in JS files. Is there way to achieve this?
My first thought was to have a both a jsconfig.json and a tsconfig.json, but apparently having the former present is the same as specifying allowJs: true in the latter?
Ya VSCode will ignore jsconfig.json when tsconfig.json is present. The way to make paths resolution (or aliases) work is to simply set allowJs: true in tsconfig.json and delete jsconfig.json as it won't be used.
Same here. I use tsconfig because it's a TypeScript project. But also have Node scripts in JavaScript and want the "checkJs" feature. In subfolder "tools", it works. But I also have some js-files in root. I think both files can work since one config file is for ts-files and the other one for js-files. ... I don't want tsconfig allowJs. It's a different setup. 🤔
If both jsconfig and tsconfig are present in the same folder, then at least jsconfig should apply for .js files in globs excluded by tsconfig but matching the jsconfig. Currently these appear as "No jsconfig" in VSCode.
It's only logical that you'd want a source TS project parallel and separate from the target compiled JS project. Having allowJs: true in tsconfig won't do because the compiled JS is a separate project (you don't want errors because of duplicate definitions) and you need a jsconfig to get rid of certain errors (since not every option is supported by js/ts.implicitProjectConfig). Requiring jsconfig in a sub-folder is terrible because it won't work for all cases, so you'd have to mess with the user's desired folder structure.
Honestly, it should really just allow them in parallel.
If possible, ideally, it could even go as far as allowing e.g.: tsconfig.json + jsconfig.json + Proj.tsconfig.json + Other Proj.tsconfig.json + Other Proj.jsconfig.json
Then users have full flexibility. If you have to disallow using the same file in multiple projects, then raise errors on the file. If not, just show "Multiple TS configs" in VSCode in this case.
Without necessarily addressing the current status of this issue, the workaround I'd suggest is to create both a tsconfig.ts.json and a tsconfig.js.json (or jsconfig.json if you really want), and a solution-style tsconfig.json that references them both.
// tsconfig.json{// Include no files for a "solution-style" config."files": [],"references": [{"path": "./tsconfig.ts.json"},{"path": "./tsconfig.js.json"},]}
I 100% agree. I was just bit by this when trying to start adding ts into a legacy js project. Everything seemed to be going smoothly right up until I realized my intellisense and "jump to source" broke for the subpath imports in the .js files. The tsconfig file is tightly scoped to the new ts files (via "includes"), so the fact that the .js files no longer read from the "paths" defined in the jsconfig really caught me off-guard.
What I would expect to happen in that situation is that the tsconfig is applied first, and any remaining files not included by it fall back to the jsconfig. It seems that the current flow for a file f is:
if tsconfig exists:
if tsconfig includes f:
apply tsconfig
else:
if jsconfig includes f:
apply jsconfig
What I would find much more intuitive is
if tsconfig exists AND tsconfig includes f:
apply tsconfig
else if jsconfig includes f:
apply jsconfig
This way the tsconfig is always preferred, but the jsconfig is still respected on the files the tsconfig doesn't cover.
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue
Activity
mhegazy commentedon May 16, 2017
That is actually by design. tsconfig.json is always given preference, and if it is not applicable it is skipped. i would like to get more user input on this before making a decision whether to change the current design or not.
mjbvz commentedon May 16, 2017
Thanks Mohamed Hegazy (@mhegazy).
Can you take a look at microsoft/vscode#26550 (comment) and see if there are other ways to address the issue Triplesnail was running into
firelizzard18 commentedon Apr 2, 2018
Mohamed Hegazy (@mhegazy) I use different compilers for JS and TS so it's pretty frustrating that I can't specify the compiler options separately.
Add a work-around for vs code microsoft/TypeScript#15869
gersongoulart commentedon Nov 15, 2019
I have a large project written in Javascript that we want to migrate to TypeScript. The process will be slow and take a long time but meantime all import aliases are broken on javascript for this reason. It'd be nice if VSCode would implement aliases on both file types or at least fallback to
jsconfig.jsonon .js files.kallebornemark commentedon Dec 18, 2019
I have a mixed JS/TS codebase, and I need to specify a
pathsobject in order to get my Webpack aliases to work with VS Code, but I don't want to display TS errors in JS files. Is there way to achieve this?My first thought was to have a both a
jsconfig.jsonand atsconfig.json, but apparently having the former present is the same as specifyingallowJs: truein the latter?a1isaeed commentedon Apr 28, 2020
Ya VSCode will ignore jsconfig.json when tsconfig.json is present. The way to make paths resolution (or aliases) work is to simply set
allowJs: truein tsconfig.json and delete jsconfig.json as it won't be used.See: microsoft/vscode#41890 (comment)
infacto commentedon Oct 1, 2020
Same here. I use tsconfig because it's a TypeScript project. But also have Node scripts in JavaScript and want the "checkJs" feature. In subfolder "tools", it works. But I also have some js-files in root. I think both files can work since one config file is for ts-files and the other one for js-files. ... I don't want tsconfig allowJs. It's a different setup. 🤔
AlfishSoftware commentedon Apr 25, 2023
If both
jsconfigandtsconfigare present in the same folder, then at leastjsconfigshould apply for .js files in globs excluded bytsconfigbut matching thejsconfig. Currently these appear as "No jsconfig" in VSCode.It's only logical that you'd want a source TS project parallel and separate from the target compiled JS project. Having
allowJs: trueintsconfigwon't do because the compiled JS is a separate project (you don't want errors because of duplicate definitions) and you need ajsconfigto get rid of certain errors (since not every option is supported byjs/ts.implicitProjectConfig). Requiringjsconfigin a sub-folder is terrible because it won't work for all cases, so you'd have to mess with the user's desired folder structure.Honestly, it should really just allow them in parallel.
If possible, ideally, it could even go as far as allowing e.g.:
tsconfig.json+jsconfig.json+Proj.tsconfig.json+Other Proj.tsconfig.json+Other Proj.jsconfig.jsonThen users have full flexibility. If you have to disallow using the same file in multiple projects, then raise errors on the file. If not, just show "Multiple TS configs" in VSCode in this case.
DanielRosenwasser commentedon Feb 8, 2024
Without necessarily addressing the current status of this issue, the workaround I'd suggest is to create both a
tsconfig.ts.jsonand atsconfig.js.json(orjsconfig.jsonif you really want), and a solution-styletsconfig.jsonthat references them both.thislooksfun commentedon Feb 8, 2024
I 100% agree. I was just bit by this when trying to start adding ts into a legacy js project. Everything seemed to be going smoothly right up until I realized my intellisense and "jump to source" broke for the subpath imports in the .js files. The tsconfig file is tightly scoped to the new ts files (via
"includes"), so the fact that the .js files no longer read from the"paths"defined in the jsconfig really caught me off-guard.What I would expect to happen in that situation is that the tsconfig is applied first, and any remaining files not
included by it fall back to the jsconfig. It seems that the current flow for a filefis:What I would find much more intuitive is
This way the tsconfig is always preferred, but the jsconfig is still respected on the files the tsconfig doesn't cover.
sheetalkamat commentedon Jun 18, 2024
This should be fixed by #57196