Closed
Description
TypeScript Version: 2.0.3
Directory structure
project
- public (client stuff)
- scripts
- typings (declaration files installed by typings)
- tsconfig.json (client project)
- server
- tsconfig.json (server project)
- node_modules (contains some @types to be used by server project)
Expected behavior:
When compiling client project, which is under public/scripts
directory, only files under public/scripts
directory should be compiled and referenced.
Actual behavior:
Declaration files in node_modules/@types
are referenced, causing compilation errors. The project itself is specified to use "amd" module system.
Adding following to tsconfig.json doesn't help
{
"exclude": [
"../../node_modules"
"node_modules"
]
}
Examples of compilation error:
../../node_modules/@types/express/index.d.ts(16,30): error TS2307: Cannot find module 'serve-static'.
../../node_modules/@types/node/index.d.ts(73,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'Require', but here has type 'NodeRequire'.
../../node_modules/@types/passport/index.d.ts(28,30): error TS2307: Cannot find module 'express'.
../../node_modules/@types/serve-static/index.d.ts(16,20): error TS2307: Cannot find module 'mime'.
The issue only happens when compiling a project. Compiling files directly works fine, e.g. tsc -t es5 -m amd --jsx react --sourceMap main.ts