We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optional, isOptional, argument, parameter, flags, JSDoc
Expected isOptional flag to be set for arguments, marked as optional with JSDoc (@param {type} [arg]).
isOptional
@param {type} [arg]
Argument is required, but it's type gets union'ed with undefined.
undefined
// index.js /** * @param {number} [arg] */ export function foo(arg) {}
// tsconfig.json { "compilerOptions": { "allowJs": true, "checkJs": true, "strict": true, "declaration": true, "declarationDir": "./types", "emitDeclarationOnly": true }, "exclude": ["node_modules"] }
./node_modules/.bin/typedoc index.js --json docs.json cat docs.json
Output:
Info: JSON written to ./docs.json { "id": 0, "name": "undefined", "kind": 1, "kindString": "Project", "flags": {}, "originalName": "", "children": [ { "id": 1, "name": "foo", "kind": 64, "kindString": "Function", "flags": {}, "sources": [ { "fileName": "index.js", "line": 4, "character": 16 } ], "signatures": [ { "id": 2, "name": "foo", "kind": 4096, "kindString": "Call signature", "flags": {}, "comment": {}, "parameters": [ { "id": 3, "name": "arg", "kind": 32768, "kindString": "Parameter", "flags": {}, "type": { "type": "union", "types": [ { "type": "intrinsic", "name": "undefined" }, { "type": "intrinsic", "name": "number" } ] } } ], "type": { "type": "intrinsic", "name": "void" } } ] } ], "groups": [ { "title": "Functions", "kind": 64, "children": [ 1 ] } ], "sources": [ { "fileName": "index.js", "line": 4, "character": 0 } ] }
Works correctly when used with declarations generated by tsc:
tsc
./node_modules/.bin/tsc --project tsconfig.json ./node_modules/.bin/typedoc types/index.d.ts --json docs.json cat docs.json
"parameters": [ { "id": 3, "name": "arg", "kind": 32768, "kindString": "Parameter", "flags": { "isOptional": true }, "type": { "type": "intrinsic", "name": "number" } } ],
// generated types/index.d.ts /** * @param {number} [arg] */ export function foo(arg?: number | undefined): void;
The text was updated successfully, but these errors were encountered:
isConst
357c9b7
Successfully merging a pull request may close this issue.
Search terms
optional, isOptional, argument, parameter, flags, JSDoc
Expected Behavior
Expected
isOptional
flag to be set for arguments, marked as optional with JSDoc (@param {type} [arg]
).Actual Behavior
Argument is required, but it's type gets union'ed with
undefined
.Steps to reproduce the bug
Output:
Works correctly when used with declarations generated by
tsc
:Environment
The text was updated successfully, but these errors were encountered: