0
我用gulp編譯打字稿時幾乎沒有問題。我設置在我tsconfig排除目錄,但我得到* .d.ts錯誤:Typescript express - gulp排除編譯錯誤
typings/browser/ambient/node/index.d.ts(1965,18): error TS2300: Duplicate identifier 'Transform'.
typings/browser/ambient/node/index.d.ts(1987,18): error TS2300: Duplicate identifier 'PassThrough'.
typings/browser/ambient/node/index.d.ts(1992,9): error TS2300: Duplicate identifier 'showHidden'.
typings/browser/ambient/node/index.d.ts(1993,9): error TS2300: Duplicate identifier 'depth'.
typings/browser/ambient/node/index.d.ts(1994,9): error TS2300: Duplicate identifier 'colors'.
typings/browser/ambient/node/index.d.ts(1995,9): error TS2300: Duplicate identifier 'customInspect'.
typings/browser/ambient/node/index.d.ts(2056,5): error TS2300: Duplicate identifier 'export='.
typings/browser/ambient/node/index.d.ts(2064,9): error TS2300: Duplicate identifier 'isRaw'.
typings/browser/ambient/node/index.d.ts(2066,9): error TS2300: Duplicate identifier 'isTTY'.
typings/browser/ambient/node/index.d.ts(2069,9): error TS2300: Duplicate identifier 'columns'.
typings/browser/ambient/node/index.d.ts(2070,9): error TS2300: Duplicate identifier 'rows'.
typings/browser/ambient/node/index.d.ts(2071,9): error TS2300: Duplicate identifier 'isTTY'.
typings/browser/ambient/node/index.d.ts(2078,18): error TS2300: Duplicate identifier 'Domain'.
typings/browser/ambient/serve-static/index.d.ts(85,5): error TS2300: Duplicate identifier 'export='.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/body-parser/index.d.ts(138,5): error TS2300: Duplicate identifier 'export='.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(22,9): error TS2300: Duplicate identifier 'path'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(23,9): error TS2300: Duplicate identifier 'stack'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(81,9): error TS2300: Duplicate identifier 'all'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(82,9): error TS2300: Duplicate identifier 'get'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(83,9): error TS2300: Duplicate identifier 'post'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(84,9): error TS2300: Duplicate identifier 'put'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(85,9): error TS2300: Duplicate identifier 'delete'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(86,9): error TS2300: Duplicate identifier 'patch'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(87,9): error TS2300: Duplicate identifier 'options'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(88,9): error TS2300: Duplicate identifier 'head'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(107,9): error TS2300: Duplicate identifier 'ma
ge'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(108,9): error TS2300: Duplicate identifier 'signed'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(109,9): error TS2300: Duplicate identifier 'expires'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(110,9): error TS2300: Duplicate identifier 'httpOnly'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(111,9): error TS2300: Duplicate identifier 'path'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(112,9): error TS2300: Duplicate identifier 'domain'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(113,9): error TS2300: Duplicate identifier 'secure'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(145,9): error TS2300: Duplicate identifier 'headers'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(242,9): error TS2300: Duplicate identifier 'accepted'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(293,9): error TS2300: Duplicate identifier 'protocol'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(300,9): error TS2300: Duplicate identifier 'secure'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(307,9): error TS2300: Duplicate identifier 'ip'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(317,9): error TS2300: Duplicate identifier 'ips'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(330,9): error TS2300: Duplicate identifier 'subdomains'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(335,9): error TS2300: Duplicate identifier 'path'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(340,9): error TS2300: Duplicate identifier 'hostname'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(345,9): error TS2300: Duplicate identifier 'host'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(352,9): error TS2300: Duplicate identifier 'fresh'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(359,9): error TS2300: Duplicate identifier 'stale'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(364,9): error TS2300: Duplicate identifier 'xhr'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(367,9): error TS2300: Duplicate identifier 'body'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(370,9): error TS2300: Duplicate identifier 'cookies'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(372,9): error TS2300: Duplicate identifier 'method'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(374,9): error TS2300: Duplicate identifier 'params'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(376,9): error TS2300: Duplicate identifier 'user'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(378,9): error TS2300: Duplicate identifier 'authenticatedUser'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(388,9): error TS2300: Duplicate identifier 'query'.
/Users/petrtomasek/Projects/expressTypescript/typings/main/ambient/express-serve-static-core/index.d.ts(390,9): error TS2300: Duplicate identifier 'route'.
這是錯誤的只是一部分,但一切都是從同一個文件夾。 我gulpfile:
var tsProject = ts.createProject('tsconfig.json', { typescript: require('typescript') });
gulp.task('Build_typescript', function() {
return tsProject.src([paths.typescriptDir + "*.ts", "!" + paths.documentRoot + "baseDir.ts", "!" + paths.documentRoot + "_all.d.ts"])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(debug())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("."));
});
與ES5 tsconfig從Angular2:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
//"typings/browser",
//"typings/browser.d.ts"
]
}
我所有的* .d.ts引用我在一個文件中_all.d.ts:
/// <reference path="../node_modules/typescript/lib/typescript.d.ts" />
/// <reference path="../typings/browser.d.ts" />
/// <reference path="../typings/main.d.ts" />
brow SER:
/// <reference path="browser/ambient/body-parser/index.d.ts" />
/// <reference path="browser/ambient/express-serve-static-core/index.d.ts" />
/// <reference path="browser/ambient/express/index.d.ts" />
/// <reference path="browser/ambient/mime/index.d.ts" />
/// <reference path="browser/ambient/node/index.d.ts" />
/// <reference path="browser/ambient/serve-static/index.d.ts" />
主:
/// <reference path="main/ambient/body-parser/index.d.ts" />
/// <reference path="main/ambient/express-serve-static-core/index.d.ts" />
/// <reference path="main/ambient/express/index.d.ts" />
/// <reference path="main/ambient/mime/index.d.ts" />
/// <reference path="main/ambient/node/index.d.ts" />
/// <reference path="main/ambient/serve-static/index.d.ts" />
/// <reference path="main/mongoose/mongoose.d.ts" />
在我的項目,我呼籲refefences對文件的頂部:
/// <reference path="../_all.d.ts" />
import mongoose = require("mongoose");
export var userSchema = new mongoose.Schema({
name: String
});
export interface IUser extends mongoose.Document {
name: string;
}
export var repository = mongoose.model<IUser>("Userma");
我真的不知道,哪裏是問題。代碼沒有其他錯誤(只有這個d.ts文件)。
你能幫助我嗎,怎麼了? 非常感謝!
是的,這是錯誤的評論。我只有這兩條線。沒有任何問題。 –
很好,你解決了這個問題.. –
我沒有。但引用行不是問題。 –