I use the new lib option in tsconfig.json to explicitly set the built-in type definitions I want to use in my project:
{
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "es5",
"lib": [ "es2015.promise", "es2015.core", "es2015.collection", "es5", "dom" ],
"module": "commonjs",
"rootDir": "src",
"outDir": "lib",
"noEmitOnError": true,
"sourceMap": true,
"declaration": true,
},
"exclude": [
"node_modules",
"lib"
]
}
Unfortunately typedoc doesn't support this:
$ typedoc --out doc src
Error: Unknown option `lib.0`.
Error: Unknown option `lib.1`.
Error: Unknown option `lib.2`.
Error: Unknown option `lib.3`.
Error: Unknown option `lib.4`.
For now I reverted back to using external type definitions for the needed ES2015 features so I'm able to use TypeDoc but it would be nice if TypeDoc could support this useful new feature.
This is a remaining issues following #234. PR #308 ignored this option to allow TypeDoc to run but PRs to enable lib support are very welcome.
@aciccarello Any ETA on a fixing release? I cannot run typedoc anymore on TS 2.0
@unsafecode As far as I know no one is working on it. There is no active maintainer of this project so fixes/features are entirely community driven.
It seems the fix has been merged but there is no new release. I tried to install from master branch to get it:
npm install -g https://github.com/TypeStrong/typedoc.git#master
Installing works but running does not:
$ typedoc
module.js:457
throw err;
^
Error: Cannot find module '../lib/cli.js'
at Function.Module._resolveFilename (module.js:455:15)
Since typedoc 0.5.1 the "lib" option is silently ignored and typedoc now complains about the missing type definitions. I found a simple but ugly workaround (No pull request for this) to fix this (At least for me). Insert these lines into bin/typedoc so the lib settings are converted to command line parameters (Directly referencing the .d.ts files of typescript):
var path = require("path");
var tsconfigPath = path.resolve(process.cwd(), "tsconfig.json");
var tsconfig = require(tsconfigPath);
if (tsconfig.compilerOptions && tsconfig.compilerOptions.lib) {
tsconfig.compilerOptions.lib.forEach(function(lib) {
process.argv.push("node_modules/typescript/lib/lib." + lib + ".d.ts");
});
}
As I said this is just an ugly "works for me" workaround and I just mention it in case it is useful for someone else waiting for a real fix for this issue.
Does anyone know if this was fixed in #359?
Any update on this one ??? lib is not taken in account yet, why this is not assigned to anyone?
You can also manually include the lib files in your include section of your typescript config file. A less hackier version than modifying the binary.
"include": [
"../node_modules/typedoc/node_modules/typescript/lib/lib.dom.d.ts",
"../node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts",
"../node_modules/typedoc/node_modules/typescript/lib/lib.es2015.core.d.ts",
"../node_modules/typedoc/node_modules/typescript/lib/lib.es2015.collection.d.ts",
"../node_modules/typedoc/node_modules/typescript/lib/lib.es2015.reflect.d.ts",
"../node_modules/typedoc/node_modules/typescript/lib/lib.es2015.iterable.d.ts",
"../node_modules/typedoc/node_modules/typescript/lib/lib.es2015.promise.d.ts",
"../node_modules/typedoc/node_modules/typescript/lib/lib.es2015.symbol.d.ts",
Thanks. I will try it later.
Yohei Onishi
2017-03-22 12:37 GMT+09:00 Blake Embrey notifications@github.com:
Closed #315 https://github.com/TypeStrong/typedoc/issues/315 via #449
https://github.com/TypeStrong/typedoc/pull/449.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/TypeStrong/typedoc/issues/315#event-1009772955, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAY5A8mqncTbpcxVebrcrnuiMpwpzx4uks5roJeXgaJpZM4KeKRP
.
@blakeembrey , @nicknisi -- Is the lib option (specifically) supported via any command line args? Gulp-typedoc is basically a passthrough for command line options, and while I'm using lib in my tsconfig, I'm not sure if I can pipe that into that plugin anymore.
@brphelps It's not specifically supported via the command line currently, but it is something that should probably be supported. When set via command line args, it does pass through to TypeScript, but it doesn't get the conversion to the correct filename. Currently, typedoc --lib dom,es2015 passes to TypeScript as ['dom', 'es2015'], but it should be passed as ['lib.dom.d.ts, 'lib.es2015.d.ts'].
FYI, this seems to work for my project, not sure if it is universal or not:
lib: ["lib.dom.d.ts", "lib.es2015.d.ts"],
When using tsconfig.json the shorthand lib: ['es2015'] options are parsed correctly. However, as @nicknisi noted, the CLI arguments are not parsed correctly and the lib d.ts files are not found. The simplest solution would be to have TypeDoc map the lib options to their declaration files. However, a better solution would be to defer to TypeScript's mapping of lib options.
A workaround for this issue is to use the full declaration file name (e.g. --lib lib.es2015.d.ts) when passing lib options via the command line.
Passing TS options (like lib) through the command line should not be required in the vast majority of cases. We support reading a tsconfig.json file, which is where TS options should really be set.
I'm not worried about requiring the full declaration file name on the command line. In the 100 or so projects that I've looked at that use TypeDoc, none pass lib options through the CLI. I don't think the extra complexity in the option parsing code to handle shorthand names is worth it.
Most helpful comment
Any update on this one ??? lib is not taken in account yet, why this is not assigned to anyone?