Steps to Reproduce:
npm i -D @types/mochadescribe('test', () => { })
Error: Cannot find name
describe
If I build manually with TS it works.
If I do a typings install --global mocha instead of npm i -D @types/mocha then both VSCode and Webpack work correctly.
Structure
├ spec
├─ index.ts
├ src
├─ index.ts
├ tsconfig.json
├ package.json
├ webpack.config.js
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"sourceMap": false,
"typeRoots": ["node_modules/@types"]
},
"exclude": [
"node_modules"
]
}
webpack.config.js
module.exports = {
entry: {
app: ['babel-polyfill', './src/'],
test: ['babel-polyfill', './spec/'],
},
output: {
path: __dirname,
filename: './dist/[name].js',
},
resolve: {
extensions: ['', '.js', '.ts'],
},
module: {
loaders: [{
test: /\.ts$/, loaders: ['babel-loader', 'ts-loader'], exclude: /node_modules/
}],
}
};
Dependencies:
"devDependencies": {
"@types/mocha": "^2.2.28",
"@types/node": "^4.0.30",
"babel-core": "^6.10.4",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"mocha": "^2.5.3",
"rimraf": "^2.5.3",
"ts-loader": "^0.8.2",
"typescript": "^2.0.0",
"webpack": "^1.13.1"
}
Setting typescript.tsdk on VSCode
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Nightly%20Builds.md#visual-studio-code
Fixed the issue
@brunolm,
I added "typescript.tsdk": "./node_modules/typescript/lib" to my setting.json file but still get errors in VSCode console (althought the project builds without any errors).
I'm having an issue when using Jasmin. It says it cannot find name 'describe' (same for 'it', 'expect'). If I add import {} from 'jasmine'; at the beginning of my spec file the errors disapear from VSCODE console.
Do you might have any ideas?
I'm using VS Code version 1.6.1 and my tsconfig.json file looks like this:
{
"compilerOptions": {
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"noEmitHelpers": true,
"pretty": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"inlineSources": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src",
"typeRoots": [ "node_modules/@types" ],
"strictNullChecks": false
},
"exclude": [
"node_modules"
],
"files": [
"src/index.ts"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
},
"compileOnSave": false,
"buildOnSave": false
}
This issue needs to be reopened.
Most helpful comment
This issue needs to be reopened.