我目前有打字稿的問題。我正在嘗試使用關於使用express構建服務器的簡單教程(http://blog.edenmsg.com/angular2-typescript-gulp-and-expressjs/)。 所以我跟着inscructions,用tsd來安裝express。然後我嘗試啓動一飲而盡構建在該文件中所描述的:爲構建以下情況除外:(指數...乾淨,建):吞口和打字稿:node.d.ts不能編譯
gulpfile.js
/**
* Created by alicia on 10/03/2016.
*/
var gulp = require('gulp');
var path = require('path');
var sourcemaps = require('gulp-sourcemaps');
var ts = require('gulp-typescript');
var del = require('del');
var concat = require('gulp-concat')
var runSequence = require('run-sequence');
// SERVER
gulp.task('clean', function(){
return del('dist')
});
gulp.task('build:server', function() {
var tsProject = ts.createProject('server/tsconfig.json');
var tsResult = gulp.src('server/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
return tsResult.js
.pipe(concat('server.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
});
// CLIENT
/*
jsNPMDependencies
*/
var jsNPMDependencies = [
'angular2/bundles/angular2-polyfills.js',
'systemjs/dist/system.src.js',
'rxjs/bundles/Rx.js',
'angular2/bundles/angular2.dev.js',
'angular2/bundles/router.dev.js'
]
gulp.task('build:index', function(){
var mappedPaths = jsNPMDependencies.map(file => {return path.resolve('node_modules', file)})
//Let's copy our head dependencies into a dist/libs
var copyJsNPMDependencies = gulp.src(mappedPaths, {base:'node_modules'})
.pipe(gulp.dest('dist/libs'));
var copyCss = gulp.src('client/css/**/*.css')
.pipe(gulp.dest('dist/css'));
//Let's copy our index into dist
var copyIndex = gulp.src('client/index.html')
.pipe(gulp.dest('dist'));
return [copyJsNPMDependencies, copyCss, copyIndex];
});
gulp.task('build:app', function(){
var tsProject = ts.createProject('client/tsconfig.json');
var tsResult = gulp.src('client/**/*.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/app'))
});
var typescript = require('gulp-tsc');
gulp.task('compile', function(){
gulp.src(['client/**/*.ts'])
.pipe(typescript())
.pipe(gulp.dest('dist/'))
});
gulp.task('build', function(callback){
runSequence('clean', 'build:server',
'build:index',
'build:app',
callback);
});
gulp.task('default', ['build'])
每個任務編譯服務器。 這是我得到的錯誤:
[12:07:43] Starting 'build:server'...
server/typings/node/node.d.ts(1759,52): error TS1005: '=' expected.
server/typings/node/node.d.ts(1760,76): error TS1005: '=' expected.
server/typings/node/node.d.ts(1761,52): error TS1005: '=' expected.
server/typings/node/node.d.ts(1761,96): error TS1005: '=' expected.
server/typings/node/node.d.ts(1771,54): error TS1005: '=' expected.
server/typings/node/node.d.ts(1772,74): error TS1005: '=' expected.
server/typings/node/node.d.ts(1773,54): error TS1005: '=' expected.
server/typings/node/node.d.ts(1773,94): error TS1005: '=' expected.
顯然,問題的根源node.d.ts.到來我真的不知道爲什麼它不工作,即使它是在絕對鍵入的版本。 你對如何提供幫助有什麼想法嗎?
編輯:我也有我的tscongig.json
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"module": "commonjs",
"target": "es6",
"sourceMap": true,
"outDir": "dist",
"declaration": false,
"jsx": "react",
"noImplicitAny": false,
"removeComments": false
},
"exclude": [
"node_modules",
"typings/browser.d.ts",
"typings/browser"
]
}
我試過了,並更改了我的tsconfig.json文件(並將其包含在上面的文章中)。 我也改變了構建:服務器功能。但我仍然有完全相同的問題。我甚至試圖重新導入tsd和所有。但它仍然給出了同樣的錯誤。 – Licia