microsoft / microsoft/TypeScript
Syntax error in a union type which contains a callback type
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.8.3
Search Terms:
- algebraic data types
Expected behavior:
Both b and c definitions are correct
Actual behavior:
Syntax errors:

Texts of errors (from left to right)
Exported variable 'c' has or is using private name ''.(4025)
Type expected.(1110)
';' expected.(1005)
'(' expected.(1005)
Related Issues:
Code
type ArrFunc = () => Array<number>;
let b: Array<number> | number | ArrFunc;
let c: Array<number> | number | () => Array<number>;
Output
"use strict";
let b;
let c;
Array();
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"useDefineForClassFields": false,
"alwaysStrict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"downlevelIteration": false,
"noEmitHelpers": false,
"noLib": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"esModuleInterop": true,
"preserveConstEnums": false,
"removeComments": false,
"skipLibCheck": false,
"checkJs": false,
"allowJs": false,
"declaration": true,
"experimentalDecorators": false,
"emitDecoratorMetadata": false,
"target": "ES2017",
"module": "ESNext"
}
}
Playground Link: Provided
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported syntax errors with the supplied TypeScript definitions for b and c, using the linked Playground or the stated TypeScript 3.8.3 version. Compare the direct callback type in c with the named ArrFunc form in b; done means both definitions compile without the reported errors and the existing compiler behavior remains covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100