-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type Circularitystackoverflows caused by circularities, or unexpected errors where no circularity appears to existstackoverflows caused by circularities, or unexpected errors where no circularity appears to existEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this
Milestone
Description
Bug Report
🔎 Search Terms
site:github.com inurl:/microsoft/TypeScript/issues/ Array [] normalization syntactic sugar
🕗 Version & Regression Information
This works in 3.9.7, broke in 4.0.5, and remains broken in Nightly.
- This changed between versions 3.9.7 and 4.0.5
⏯ Playground Link
Playground link with relevant code
💻 Code
type R<C> = [C, ...R<C>[]] | number; // works, as expected
type S<C> = [C, ...Array<S<C>>] | number; // fails unexpectedly - should work identically
const r: R<"add"> = ["add", 2, 1];
const s: S<"add"> = ["add", 2, 1];🙁 Actual behavior
The A[] form in the first line works, but the otherwise-identical Array<…> form on the second line breaks with the warning Type alias 'S' circularly references itself.(2456).
🙂 Expected behavior
Both of these should work, and behave identically, as they are merely syntactic sugar for each other.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type Circularitystackoverflows caused by circularities, or unexpected errors where no circularity appears to existstackoverflows caused by circularities, or unexpected errors where no circularity appears to existEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this