exclude subdirectories in tsconfig.json

58,826

Solution 1

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

Solution 2

Try with:

 "exclude": [
     "node_modules",
     "public",
     "typings/browser.d.ts",
     "typings/browser/**"
 ]

Solution 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.

Share:
58,826
DNRN
Author by

DNRN

C# developer at Cordura A/S in Århus Denmark. Developing Django pages and playing around with XNA in the spare time :D

Updated on November 10, 2021

Comments

  • DNRN
    DNRN over 2 years

    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.

  • DNRN
    DNRN about 8 years
    OH! I just realised I could build from command line! And not from VS, so this i probaly a problem with my VS TypeScript setup
  • aruno
    aruno about 8 years
    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 this
  • SourceSimian
    SourceSimian about 8 years
    @Simon_Weaver Did you try installing from the link above after you insatlled Update 2?
  • aruno
    aruno about 8 years
    No because it appeared to have a lower version number.
  • coler-j
    coler-j over 4 years
    Where is a reference to this being an issue with typescript, so that we can follow along?
  • sbichenko
    sbichenko over 3 years
    Note that this goes into root config, not into "compilerOptions"
  • Jeremy Moritz
    Jeremy Moritz about 3 years
    I can confirm that this bug still exists in VSCode Version: 1.55.2, circa Apr 2021