In my Typescript 2.2.1 project in Visual Studio 2015 Update 3, I am getting hundreds of errors in the error list like:
Cannot write file \'C:/{{my-project
I had the same issue. In my case it was caused, because I had two files with the same name in one module: index.ts index.tsx.
I renamed one of them and the problem got fixed.
Set outDir.
"outDir": "./",
this hint is that if you don't set outDir, then the output will be placed directly next to the input file. After allowJs, the JavaScript file will also be compiled. Then, the compiled JavaScript file will overwrite your source file. It’s just reminding you of this.
I solved this by removing "declaration": true
from my tsconfig.json file. Though now I don't have declarations anymore so that didn't help.
In my instance, I was using the outDir option but not excluding the destination directory from the inputs:
// Bad
{
"compileOnSave": true,
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es5",
"allowUnreachableCode": false,
"noImplicitReturns": true,
"noImplicitAny": true,
"typeRoots": [ "./typings" ],
"outFile": "./built/combined.js"
},
"include": [
"./**/*"
],
"exclude": [
"./plugins/**/*",
"./typings/**/*"
]
}
All we have to do is exclude the files in the outDir:
// Good
{
"compileOnSave": true,
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es5",
"allowUnreachableCode": false,
"noImplicitReturns": true,
"noImplicitAny": true,
"typeRoots": [ "./typings" ],
"outFile": "./built/combined.js"
},
"include": [
"./**/*"
],
"exclude": [
"./plugins/**/*",
"./typings/**/*",
"./built/**/*" // This is what fixed it!
]
}
In my case due to developing a library and an app at the same time...
Moving a file, which has an import from the library, from the app to the library, resulted that the file that is now in the library would import stuff from its own dist folder..
Funny thing is.. this is actually refactoring at its best.. it kept the correct reference to the file :)
set allowJS: true
is not woI set outDir : true
, it's work