Reputation: 26438
I have installed @types/jasmine
as a devDependency.
My gulp task to compile my typescript is like so:
gulp.task('compile:tests', ['compile:typescript', 'clean:tests'], function () {
var project = ts.createProject('tsconfig.json', { typescript: typescript });
var tsResult = gulp.src(['spec/**/*spec.ts'])
.pipe(ts(project));
return tsResult.js
.pipe(gulp.dest('spec/'));
});
and my tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node"
},
"exclude": [
"node_modules"
]
}
but this results in the errors:
spec\linter.spec.ts(7,1): error TS2304: Cannot find name 'describe'.
spec\linter.spec.ts(8,3): error TS2304: Cannot find name 'it'.
spec\linter.spec.ts(17,5): error TS2304: Cannot find name 'expect'.
spec\linter.spec.ts(20,3): error TS2304: Cannot find name 'it'.
How can I get typescript (when used by gulp-typescript) to recognize the @types/...
typings?
Upvotes: 3
Views: 1550
Reputation: 26438
Updated: latest version fixes the issue: install with
npm install gulp-typescript@3
pre gulp-typescript@3: So far my work around has been to manually include all @types typings, like so:
gulp.src(['spec/**/*spec.ts', "./node_modules/@types/**/*.d.ts"])
if you have conflicting versions of typings (here's looking at you @types/node@x
) then you can skip over them to avoid the duplicates:
gulp.src([
paths.source + '**/*.ts',
"node_modules/@types/**/index.d.ts",
"!node_modules/@types/**/node_modules/**/index.d.ts"])
Upvotes: 3
Reputation: 33
The following work for me.
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node"
},
"files": [
"node_modules/@types/**/*.d.ts"
],
"exclude": [
"node_modules"
]
}
nvm, that wont work, neither does using "include" and "exclude" together.
Upvotes: 0
Reputation: 38006
You can use project.src()
instead of gulp.src(['typings-glob', 'sources-glob'])
.
** For some reason, in project I'm working on, transpilation takes ~3 seconds more when project.src()
used, so I stick with the gulp.src
option.
Upvotes: 2