Skip to content
New issue

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

A[] form works, but Array<A> breaks #45641

Open
johan opened this issue Aug 30, 2021 · 3 comments
Open

A[] form works, but Array<A> breaks #45641

johan opened this issue Aug 30, 2021 · 3 comments
Labels
Bug A bug in TypeScript Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Milestone

Comments

@johan
Copy link

johan commented Aug 30, 2021

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.

@MartinJohns
Copy link
Contributor

MartinJohns commented Aug 30, 2021

Related / duplicate: #40298. The exact same behaviour was mentioned in this comment.

@andrewbranch andrewbranch added Bug A bug in TypeScript Help Wanted You can do this labels Aug 30, 2021
@andrewbranch andrewbranch added this to the Backlog milestone Aug 30, 2021
@Uda-Titor
Copy link
Contributor

Can I work on this? This is my first time contributing to Typescript.

@andrewbranch
Copy link
Member

@ryoheiudagawa1995 I would encourage you to search for issues with the "good first issue" label. This issue was actually the inspiration for #45643 😄. It will be unapproachable for someone not already very familiar with the checker.

@DanielRosenwasser DanielRosenwasser added Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". and removed Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". labels Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants