Я следил за быстрым запуском на угловом сайте. Я пытаюсь получить мое свойство настройки gulpfile, чтобы перекрыть мой тип ввода внутри моего проекта Visual Studio aspnetcore. Я использую машинописную версию 1.8.10, а не бета-версию 2.0, которая имеет решение, размещенное для нее в другом месте на SO.Угловые 2 Ошибки типа текста
Я получаю 70 из этих ошибок при запуске "TS2" задачу:
C:/путь/к/мой/проект/Quickstart/node_modules/@ Угловое/общие/SRC/трубы/async_pipe. d.ts (41,38): ошибка TS2304: Не удается найти имя «Promise». c: /path/to/my/project/Quickstart/node_modules/@angular/compiler/src/compile_metadata.d.ts (347,20): ошибка TS2304: Не удается найти имя «Установить». c: /path/to/my/project/Quickstart/node_modules/@angular/compiler/src/compile_metadata.d.ts (348,15): ошибка TS2304: Не удается найти имя «Установить». c: /path/to/my/project/Quickstart/node_modules/@angular/compiler/src/directive_normalizer.d.ts (19,100): ошибка TS2304: Не удается найти имя «Promise».
Мои Gulpfile.js:
var ts = require("gulp-typescript");
var gulp = require('gulp');
var clean = require("gulp-clean");
// Delete the dist directory
gulp.task("clean", function() {
return gulp.src(destPath)
.pipe(clean());
});
gulp.task("scriptsNStyles",() => {
gulp.src([
"core-js/client/**",
"systemjs/dist/system.src.js",
"reflect-metadata/**",
"rxjs/**",
"zone.js/dist/**",
"@angular/**",
"jquery/dist/jquery.*js"
], {
cwd: "node_modules/**"
})
.pipe(gulp.dest("./wwwroot/lib"));
});
var tsProject = ts.createProject("./tsconfig.json");
gulp.task("ts", function (done) {
//var tsResult = tsProject.src()
var paths = {
scripts: ['./wwwroot/app/*.ts']
};
gulp.src(paths.scripts).pipe(gulp.dest('wwwroot/app'));
});
gulp.task('ts2', function (done) {
var tsResult = gulp.src([
"wwwroot/app/*.ts"
])
.pipe(ts(tsProject), undefined, ts.reporter.fullReporter());
return tsResult.js.pipe(gulp.dest('./wwwroot/app'));
});
gulp.task("watch", ["watch.ts"]);
gulp.task("watch.ts", ["ts"], function() {
return gulp.watch("./wwwroot/app/*.ts", ["ts"]);
});
gulp.task("default", ["scriptsNStyles", "watch"]);
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/index",
"typings/index.d.ts",
"wwwroot/lib"
],
"compileOnSave": true
}
package.json:
{
"version": "1.0.0",
"name": "asp.net",
"scripts": {
"postinstall": "typings install",
"typings": "typings"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0-rc.7",
"@angular/compiler": "2.0.0-rc.7",
"@angular/compiler-cli": "0.6.1",
"@angular/core": "2.0.0-rc.7",
"@angular/forms": "2.0.0-rc.7",
"@angular/http": "2.0.0-rc.7",
"@angular/platform-browser": "2.0.0-rc.7",
"@angular/platform-browser-dynamic": "2.0.0-rc.7",
"@angular/router": "3.0.0-rc.3",
"@angular/upgrade": "2.0.0-rc.7",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"zone.js": "^0.6.21",
"angular2-in-memory-web-api": "0.0.19",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"typescript": "^1.8.10",
"gulp": "^3.9.1",
"path": "^0.12.7",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-typescript": "^2.13.6",
"typings": "^1.3.1",
"gulp-tsc": "^1.2.0"
}
}
Typings.json:
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160602141332",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160621231320"
}
}
Transpilation, похоже, работает, но мне не нравятся ошибки. Как это исправить?
Это проблема с не найденными типами. Вот аналогичный вопрос. https://stackoverflow.com/questions/35660498/angular-2-cant-find-promise-map-set-and-iterator/38876022#38876022 Похоже, вам, вероятно, нужны типы «core-js» –
Можете ли вы опубликовать код для вашего typings.json? –
Я столкнулся с этой проблемой за корпоративными прокси-фильтрами. В моем случае типизация не может быть установлена из-за необходимости доступа через SSL. Если вы обнаружите, что это проблема, я могу объяснить, как обойти ее. Хотя здесь есть много вопросов, которые решают эту проблему. – ethesx