问题
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?
回答1:
I tried with the commonjs module and it worked.
typedoc --experimentalDecorators --target 'es5' --module 'commonjs' --out doc-destination/ src/
回答2:
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.
回答3:
Add the configuration for type definition files in your tsconfig.json and try
"typeRoots": [
"node_modules/@types" ]
来源:https://stackoverflow.com/questions/35015994/typedoc-can-not-find-angular2-modules