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.
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:While this does work:
Expected behavior:
With this
tsconfig.json:{ "compilerOptions": { "target": "ES2017", "allowJs": true, "checkJs": true, "noEmit": true, "strict": false, }, "include": [ "src/**/*.js" ] }I expected
tscto succeed.Actual behavior:
Perhaps this is a known limitation. I can remove the parens. But I thought it might also be a parsing bug.