简体   繁体   中英

TypeDoc can not find Angular2 modules

I am trying to generate doc files by using TypeDoc. When I run TypeDoc with the follwing command:

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

It gives as output:

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"
  ]
}

Is there some kind of parameter I am missing here to include the libs or .d.ts. files?

我尝试了commonjs模块,它起作用了。

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

I use typedoc with angular2 application. Although I run it through gulp-typedoc the passed parameters should be the same. The following gulp task does the job for me:

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,
        }));
});

Hope this helps.

Add the configuration for type definition files in your tsconfig.json and try

"typeRoots": [
  "node_modules/@types" ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM