Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 未定义类型脚本模块_Typescript - Fatal编程技术网

Typescript 未定义类型脚本模块

Typescript 未定义类型脚本模块,typescript,Typescript,我正在升级到Angular2 RC1,在一个非常简单的typescript服务器上突然出现以下错误: 我已经安装了我认为需要的打字机,我正在使用gulp构建它: typings.json: { "ambientDependencies": { "es6-collections": "registry:dt/es6-collections#0.5.1+20160316155526", "es6-promise": "registry:dt/es6-promise#0.0.0+2016

我正在升级到Angular2 RC1,在一个非常简单的typescript服务器上突然出现以下错误:

我已经安装了我认为需要的打字机,我正在使用gulp构建它: typings.json:

{
  "ambientDependencies": {
  "es6-collections": "registry:dt/es6-collections#0.5.1+20160316155526",
  "es6-promise": "registry:dt/es6-promise#0.0.0+20160423074304",
  "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
  "express": "registry:dt/express#4.0.0+20160317120654",
  "express-serve-static-core": "registry:dt/express-serve-static-core#0.0.0+20160322035842",
  "node": "registry:dt/node#4.0.0+20160505172921",
  "require": "registry:dt/require#2.1.20+20160316155526",
  "serve-static": "registry:dt/serve-static#0.0.0+20160501131543"
  }
}
代理构建的gulp任务:

gulp.task('build:proxy', function () {
    var tsProject = ts.createProject('tsconfig.json');
    var tsResult = gulp.src(['proxy/**/*.ts','!proxy/typings/**/*.*'])
        .pipe(sourcemaps.init())
        .pipe(ts(tsProject))
    return tsResult.js
        .pipe(concat('proxy.js'))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('dist'))
});
和tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "proxy/typings/main",
    "proxy/typings/main.d.ts"
  ],
  "buildOnSave": false,
  "disableCompileOnSave": true,
  "compileOnSave" : false
}    

因为一切看起来都像以前一样,所以我将导入内容保持不变,例如
import express=require('express')
。我似乎不知道该怎么做才能把这些模块放进去。

在代理文件夹中放置一个新的main.d.ts,其中包含以下内容

 /// <reference path="./typings/main.d.ts" />
//

我回答了GitHub问题()。总之,您需要更正
gulp.src()
调用,使其不忽略所有打字,而只忽略主打字或浏览器打字。例如,
gulp.src(['proxy/***/.ts','!proxy/typings/main/**','!proxy/typings/main.d.ts']

您是否检查了
打字/main.d.ts
?您的源ts文件是否驻留在proxy\\ts文件中?@Zen是的,看起来不错!@MadhuRanjan在proxy文件夹中只有一个名为proxy.ts的ts文件。我也尝试过将所有内容移动到根文件夹,但问题相同。尝试过,我得到了重复的标识符(还尝试从tsconfig中排除打字中的main.d.ts,但仍然得到重复错误)。我对您发布的
npm
软件包有疑问。您是否愿意帮助解决此问题?以下是链接: