TypeDoc找不到Angular2模块

时间:2016-01-26 14:20:03

标签: angular typescript typedoc

我正在尝试使用TypeDoc生成doc文件。当我使用以下命令运行TypeDoc时:

/node_modules/.bin/typedoc --module system --target ES5 --exclude *.spec.ts* --experimentalDecorators --out typedoc app/ --ignoreCompilerErrors

它作为输出:

Using TypeScript 1.6.2 from /development/node_modules/typedoc/node_modules/typescript/lib
Error: /development/app/angular2/app.ts(1)
 Cannot find module 'angular2/core'.
Error: /development/app/angular2/app.ts(2)
 Cannot find module 'angular2/upgrade'.
Error: /development/app/angular2/app.ts(3)
 Cannot find module 'angular2/platform/browser'.
Error: /development/app/angular2/app.ts(5)

tsconfig.json

{
  "compilerOptions": {
    "target": "ES5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ]
}

我是否缺少某些参数来包含libs或.d.ts.文件?

3 个答案:

答案 0 :(得分:3)

我尝试使用commonjs模块并且工作正常。

typedoc --experimentalDecorators --target 'es5' --module 'commonjs' --out doc-destination/ src/

答案 1 :(得分:1)

我在angular2应用程序中使用typedoc。虽然我通过gulp-typedoc运行它,但传递的参数应该是相同的。以下gulp任务为我完成了这项工作:

gulp.task("doc", function() {
    return gulp
        .src(["./myproject/**/*.ts"])
        .pipe(typedoc({ 
            // TypeScript options (see typescript docs) 
            module: "commonjs", 
            target: "es5",
            includeDeclarations: false,
            experimentalDecorators: true,

            // Output options (see typedoc docs) 
            out: "./docs", 

            // TypeDoc options (see typedoc docs) 
            name: "MyProject", 
            ignoreCompilerErrors: false,
            excludeExternals:true,
            version: true,
        }));
});

希望这有帮助。

答案 2 :(得分:0)

在tsconfig.json中添加类型定义文件的配置,然后尝试

"typeRoots": [
  "node_modules/@types" ]
相关问题