TypeScript Version:
1.8.2
Code
foo.ts
var foo: number = "s";
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5"
},
"exclude": [
"foo.ts"
]
}
Expected behavior:
In an NTVS typescript console application using the above tsconfig.json, and a file foo.ts containing an error, the build and run initiated by Visual Studio should succeed because the file containing the error is excluded.
Actual behavior:
The build fails with an error in foo.ts. Compiling from command line, the build succeeds. Also, if foo.ts is put inside a folder, and the folder is listed in the exclude array, the VS build succeeds.
This is currently breaking projects using the typings tool, because it generates two sets of type definitions, and the other set cannot be excluded.
What version of Visual Studio (2013 / 2015?) are you using?
VS 2015 Pro. Happens with the non-NTVS "HTML Application with Typescript" project as well. I also have TS Tools 1.7.6 installed. If you can't reproduce, I'll try reinstalling some stuff.
Can you give TS 1.8 (https://blogs.msdn.microsoft.com/typescript/2016/02/22/announcing-typescript-1-8-2) a try. tsconfig.json should be supported as the main source of configuration, which was not the case in 1.7.*
Sorry, I have 1.8 installed, but I _also_ have the older version installed. I'll try uninstalling all versions and only installing the newest one.
Removed all TS Tools versions, reinstalled only 1.8.4, the issue remains. Also tested on another machine, same problem.
can you share your build log?
Here's the log (from the output window): http://pastebin.com/iwVEEkS3
Looks like I get the same error if I run the build command from the log in command prompt, that is:
"C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe" --project "C:\dev\test5\tsconfig.json"
However, running without the --project switch, the build completes successfully (and the tsconfig used is the same).
Even more strangely:
C:\dev\test5>"C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe" --project "C:\dev\test5\tsconfig.json"
gives the error but
C:\dev\test5>"C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe" --project "tsconfig.json"
doesn't.
Ok. thanks for the information. i think i have found the issue. some background, tsc.exe is just a wrapper around tsc.js with ChakraCore. The IO operations has a diffrent implementation for tsc.exe and node tsc.js.
Looks like the readDirectory logic in tsc.exe implementation did not exclude files, only directories. i have queued up a fix for it, and should be in the next nightly nugget release: https://www.myget.org/gallery/typescript-preview (see https://github.com/Microsoft/TypeScript/wiki/Nightly-drops#using-nuget-with-msbuild for more information).
FYI, the nightly compiler from NuGet did fix the issue.
thanks @BigDataSamuli!
@mhegazy is this fix out for v1.8.7? I notice it has milestones 1.8.5 and 2.0. I'm running into the same issue using 1.8.7 but before I do more investigation I want to make sure this isn't my problem.
1.8.5 is the same as 1.8.7 (we had an issue with the npm publishing that caused us to publish the same package under different version see https://github.com/Microsoft/TypeScript/issues/7330 ). sorry about the confusion.
There is a note about this in the release notes for 1.8.5: https://github.com/Microsoft/TypeScript/releases/tag/v1.8.7
Oh okay, that makes sense then.
Unfortunately, I'm still seeing the issue. I'll have to do some more research then, thanks for your help.
@jevenson this looks like a different issue then. can you file a new issue and provide some more details on what is going on, and how to reproduce it.
Yeah I definitely will, I need to confirm that it's not my code first. I'll do some more research and report back, creating a new issue if I cannot find a solution.
Looks to be my fault
https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md#exclude
NOTE: exclude should not be used when files or filesGlob are in use. The presence of the files property takes presedence over the exclude property.
I have filesGlob & exclude in my tsconfig
this bug returned on version 1.8.9. I see exactly same duplicate errors which had disappeared on version 1.8.7
This bug also appears to be ignoring node_modules in 1.8.10 even though it is specified in the tsconfig file.
*Note:
This was due to my tsc being stuck on an old version, and that's what VS was using. Fixed it by updating my PATH to use the latest one.
The latest available version 1.8.34 still ignores the tsconfig.json
{ "exclude": [
"node_modules",
"wwwroot"
]
}
I have modules with test directories and .ts code, VS compiles, taking a very long time and ending with failures.
What's the next way to go to solve these long existing problem?
An update on this problem would be nice.
I am struggling with this as well. Anyone figured out a solution?
When you open up command prompt and do tsc -v what version comes up? You might need to change/update your PATH to use the latest version. @FritzHerbers @jamesond
Hi Mark, it says I am using version 1.0.3.0
There you go it should be at least 1.8 and such, your compiler is on Typescript version 1!
Been searching around how to change the path? Can you instruct me on this or point me to some instructions? Thank you Mark.
Go to start, search programs & files bar at the bottom.
Type environment variables click on System Environment variables.
Click on Environmental variables button near the bottom.
There are 2 sections, User variables & System ones (down below)
Find PATH in that lower section, click on PATH, then click Edit.
Copy & paste that long long string into notepad of some sort. Look for 1.0.3.0 in it, update it to the highest version of TS you have. Most likely the tsc will be 1.8 unless you're using TS2@beta.
Your TS compilers can be found: C:\Program Files (x86)\Microsoft SDKs\TypeScript\
That should do it. @jamesond
Awesome thanks Mark! Any idea why VS wont' update to the latest automatically?
That is a good question, well it bases what things to use based on the PATH variable. When updating your global TS npm i -g typescript it doesn't automatically do that, so I guess that's why :(
It's a pain I know, took me quite a while to even figure all of that out!
Yea for sure! Well thank you very much for the info!
With 1.8.34 changeing './wwwroot/jspm_packages/*_/_.d.ts' to './wwwroot/' fixed the duplicate error messages.
Strange, I don't have a tsc.exe in my PATH. But build takes C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8tsc.exe. From where is it called?
To overcome the problem I created a console app tsc.exe and replaced the above file, which does a simple exit 0.
Today I tried "npm i -g typescript" which installs a tsc.cmd pointing to a 1.8.10 version, why isn't the latest 1.8.34 ?
tsc is the compiler itself, I believe that's why the # can be different.
Many programs VSStudio etc, will use this tsc to compile your code that's why it's needed there.
I have a similar situation. Here's how my project is set up:
{
"exclude": [
"node_modules",
"typings"
],
"compilerOptions": {
"target": "ES5"
}
}I turned on MSBuild verbose logging and in the build log I see the following which is what I expect:
1>TscToolExe = tsc.exe
1>TscToolPath = C:\dev\ChromeExtension\chromeext\packages\Microsoft.TypeScript.MSBuild.1.8.11\tools\tsc\
Now here's the weird part: if I do a clean build, then I get all the "Duplicate identifier" errors, which means that the folder wasn't excluded. But if I build again (just build, not rebuild), then the build succeeds.
I tried upgrading to 2.0.3 and the project still doesn't build. However, it seems that with 2.0.3 building twice doesn't work either...
Looks like tsc 2.0.3 is broken here as well. I'm trying to get angular2 aot working and tsc insists on building the *ngfactory.ts files in the aot directory in spite of what I put in excludes. The exludes section:
"exclude": [
"./aot",
"aot",
"aot/app",
"./aot/app",
"*ngfactory.ts",
"node_modules",
"jspm_packages",
"wwwroot",
"wwwroot/lib",
"bin"
]
The strange thing is that wwwroot, and node_modules work just fine, tsc ignores them, but it can't ignore aot for some reason.
Update: Well after reading the docs...
"That was tsconfig.json automatic inclusion. That does not embed module resolution as discussed above. If the compiler identified a file as a target of a module import, it will be included in the compilation regardless if it was excluded in the previous steps."
Which, of course means, exclude doesn't exclude .ts files that were found via import, so moved things around and now a making some progress.
Most helpful comment
this bug returned on version 1.8.9. I see exactly same duplicate errors which had disappeared on version 1.8.7