-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationFixedA PR has been merged for this issueA PR has been merged for this issuecheckJsRelates to checking JavaScript using TypeScriptRelates to checking JavaScript using TypeScript
Milestone
Description
TypeScript Version: [email protected]
Search Terms: function arguments grouped union type
Code
I notice that if a union type is grouped with (
and )
it works as a return type but not as an argument type. For example, this does not work:
/**
* @typedef {function((string|undefined)): (string|undefined)} SomeType
*/
While this does work:
/**
* @typedef {function(string|undefined): (string|undefined)} SomeType
*/
Expected behavior:
With this tsconfig.json
:
{
"compilerOptions": {
"target": "ES2017",
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": false,
},
"include": [
"src/**/*.js"
]
}
I expected tsc
to succeed.
Actual behavior:
src/main.js:2:23 - error TS1138: Parameter declaration expected.
2 * @typedef {function((string|undefined)): (string|undefined)} SomeType
~
src/main.js:2:41 - error TS1005: '}' expected.
2 * @typedef {function((string|undefined)): (string|undefined)} SomeType
~
Perhaps this is a known limitation. I can remove the parens. But I thought it might also be a parsing bug.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationFixedA PR has been merged for this issueA PR has been merged for this issuecheckJsRelates to checking JavaScript using TypeScriptRelates to checking JavaScript using TypeScript