Я получаю много "ложных" ошибок, когда моя задача gulp
компилирует мой typescript. Здесь соответствующий gulp task
:
var tsProject = typescript.createProject('tsconfig.json', {noResolve: true});
gulp.task('build-ts', function() {
gulp.src(appDev + '**/*.ts')
.pipe(sourcemaps.init())
.pipe(typescript(tsProject))
.pipe(sourcemaps.write())
//.pipe(jsuglify())
.pipe(gulp.dest(appProd));
gulp.src(appDev + '**/*.+(html|css)')
.pipe(gulp.dest(appProd));
});
И это ошибки, которые я получаю:
[09:38:52] Starting 'default'...
[09:38:52] Finished 'default' after 8.88 ms
ng/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'.
ng/app.component.ts(5,12): error TS2304: Cannot find name 'module'.
ng/app.module.ts(1,26): error TS2307: Cannot find module '@angular/core'.
ng/app.module.ts(2,31): error TS2307: Cannot find module '@angular/platform-browser'.
ng/app.module.ts(3,31): error TS2307: Cannot find module '@angular/common'.
[...]
[09:38:53] TypeScript: 27 semantic errors
[09:38:53] TypeScript: emit succeeded (with errors)
[BS] Proxying: http://0.0.0.0:5000
Моя древовидная структура выглядит так (упрощена):
.
├── gulpfile.js
├── ng
├── node_modules
├── package.json
├── tsconfig.json
├── typings.json
└── web
Все модули, которые не удается найти компилятору Typescript, на самом деле находятся в node_modules
, и мое окончательное приложение отлично работает, несмотря на все ошибки.
Это мой tsconfig.js
:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./app"
},
"filesGlob": [
"./app/**/*.ts",
"!./node_modules/**/*.ts"
],
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
],
"atom": {
"rewriteTsconfig": true
}
}
Как я могу избавиться от этих "ложноположительных" ошибок.