exclude subdirectories in tsconfig.json
Asked Answered
E

4

45

I have installed TypeScript 1.8.2, and using Visual Studio 2015. I have a simple project where I have problems excluding folders from the tsconfig.json file. The problem is I would like to exclude the file typings/browser.d.ts and the folder typings/browser. But this is not the case?

I have no problems excluding a subfolder, but not a sub-subfolder?

[NOTE] I just realized the problem is only when I build from Visual Studio! If i build with tsc from the command line, there's no problem. Could I have another version of TypeScript in Visual Studio? How can I check this?

This is my tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "public",
    "typings/browser",
    "typings/browser.d.ts"
  ]
}

I have a bigger project, where I use jspm and need to exclude the jspm package folder, which is located as a subfolder to public.

Edaedacious answered 26/2, 2016 at 9:25 Comment(2)
I have exactly the same problem, with a project that was working flawlessly in visual studio 2015 before I installed the typescript 1.8.2 toolchain for visual studio. I suspect this is a visual studio tooling bug rather than a setup issue.Alyciaalyda
I actually moved from VS 2015 to atom, because of this. And because VS 2015 crashed a bit to too often. Which is sad I like to work in VS..Edaedacious
A
2

I just installed and tested the latest version of TypeScript for Visual Studio 2015 (1.8.6 at the moment), and I can confirm that this problem has been fixed in the latest release.

https://www.microsoft.com/en-us/download/details.aspx?id=48593

[Edit] Be sure to also do an npm update -g typescript

Alyciaalyda answered 2/3, 2016 at 16:22 Comment(3)
this doesn't seem to take effect in VS 2015 Update 2 RC. Even though it has installed it keeps showing 1.8.2 from within Extensions manager. I'm hoping Update 2 RTM (which is now available) will fix thisParsee
@Parsee Did you try installing from the link above after you insatlled Update 2?Alyciaalyda
No because it appeared to have a lower version number.Parsee
A
47

Try with:

 "exclude": [
     "node_modules",
     "public",
     "typings/browser.d.ts",
     "typings/browser/**"
 ]
Amphidiploid answered 26/2, 2016 at 9:27 Comment(3)
OH! I just realised I could build from command line! And not from VS, so this i probaly a problem with my VS TypeScript setupEdaedacious
Note that this goes into root config, not into "compilerOptions"Hardenberg
Why is this needed? Node Modules folder doesn't require ** but the browser folder needs it?Chifforobe
B
3

Looks like this is a problem with typescript being unable to exclude paths/patterns that belong to deeper dir structure. Its still a problem with "typescript@^3.4.5".

To fix this I started cleaning my Dist dir with "rimraf dist" before every test run.

"test:unit": "npm run clean && stencil test --spec --snapshot",

I know its a hack, but works.

Botel answered 9/8, 2019 at 10:49 Comment(2)
Where is a reference to this being an issue with typescript, so that we can follow along?Royroyal
I can confirm that this bug still exists in VSCode Version: 1.55.2, circa Apr 2021Cockalorum
A
2

I just installed and tested the latest version of TypeScript for Visual Studio 2015 (1.8.6 at the moment), and I can confirm that this problem has been fixed in the latest release.

https://www.microsoft.com/en-us/download/details.aspx?id=48593

[Edit] Be sure to also do an npm update -g typescript

Alyciaalyda answered 2/3, 2016 at 16:22 Comment(3)
this doesn't seem to take effect in VS 2015 Update 2 RC. Even though it has installed it keeps showing 1.8.2 from within Extensions manager. I'm hoping Update 2 RTM (which is now available) will fix thisParsee
@Parsee Did you try installing from the link above after you insatlled Update 2?Alyciaalyda
No because it appeared to have a lower version number.Parsee
H
0

I am using ts V4.1.3 with webStorm 2021 and an exclude like exclude:[server/**] in tsconfig.json appeared to not be excluding, however I found it was only compiling if I opened one of the ts files in the editor.

I turned off WebStorm/File/Settings/Languages../TypeScript/Recompile On Changes and all is ok, ie it does not compile any ts files at any level in the server directory.

Humectant answered 9/11, 2021 at 21:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.