TypeScript Version: nightly (2.1.0-dev.20160905)
Code
I'm not using gulp or other external tools
(the first line is not related to this issue)
[root /data/nodejs/json-env-cli]# tsc -w
error TS2688: Cannot find type definition file for './global.d.ts'.
error TS6059: File '/data/nodejs/json-env-cli/node_modules/typescript/Gulpfile.ts' is not under 'rootDir' '/data/nodejs/json-env-cli/src'. 'rootDir' is expected to contain all source files.
7:56:38 PM - Compilation complete. Watching for file changes.
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitThis": true,
"noImplicitAny": false,
"removeComments": false,
"preserveConstEnums": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": false,
"pretty": true,
"sourceMap": true,
"baseUrl": "./",
"typeRoots": ["typings"],
"types": ["./global.d.ts"],
"lib": ["es6"],
"outDir": "./dist",
"rootDir": "./src"
},
"exclude": ["global.d.ts"]
}
Expected behavior:
ts file in "src" will compile to "dist", without error
Actual behavior:
files compiled but print an error
I am getting this issue also
error TS6059: File '/Users/XXX/projects/syncrow/src/fs_helpers/read_tree.ts' is not under 'rootDir' 'src'. 'rootDir' is expected to contain all source files.
error TS6059: File '/Users/XXX/projects/syncrow/src/utils/test_utils.ts' is not under 'rootDir' 'src'. 'rootDir' is expected to contain all source files.
add node_modules to your exclude list.
if no exclude is specified one, the compiler excludes node_modules, bower_components, <outDir>.
so your exclude should be ["node_module", "./dist", "global.d.ts"]
@jan-osch, i am not sure what is going on in your case. it is either the same issue or a different one, can not just tell from the error messages.
@mhegazy no effect. exclude: ["node_module", "./dist", "global.d.ts"] still report that error.
( by the way, my src/dist file struct )
/data/nodejs/json-env-cli
+ dist/
+ src/
- index.js
+ node_modules/
+ typescript
- Gulpfile.js
- Gulpfile.js.map
+ src/
- index.ts
I finally fixed this by:
move "tsconfig.json" to "src"
change content to:
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": ["es6"],
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitThis": true,
"noImplicitAny": false,
"removeComments": false,
"preserveConstEnums": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": false,
"pretty": true,
"sourceMap": true,
"baseUrl": "./",
"typeRoots": [],
"types": [],
"outDir": "../dist",
"rootDir": "./"
},
"exclude": ["node_module", "./dist", "global.d.ts"]
}
and set script.start in package.json = tsc -w -p src, scripts.build = tsc -p src
now content of src will 1 on 1 map to dist
Most helpful comment
I finally fixed this by:
move "tsconfig.json" to "src"
change content to:
and set
script.startin package.json =tsc -w -p src,scripts.build=tsc -p srcnow content of
srcwill 1 on 1 map todist