The Wayback Machine - https://web.archive.org/web/20211022005433/https://github.com/microsoft/TypeScript/issues/46246
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

Unhelpful error message when interface ... extends number #46246

Open
Mr-Andersen opened this issue Oct 6, 2021 · 3 comments · May be fixed by #46357
Open

Unhelpful error message when interface ... extends number #46246

Mr-Andersen opened this issue Oct 6, 2021 · 3 comments · May be fixed by #46357

Comments

@Mr-Andersen
Copy link

@Mr-Andersen Mr-Andersen commented Oct 6, 2021

Bug Report

🔎 Search Terms

interface extends only refers to a type

🕗 Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about interface extension

Playground Link

Playground link with relevant code

💻 Code

export interface MessageId extends number {}

🙁 Actual behavior

error TS2693: 'number' only refers to a type, but is being used as a value here.

🙂 Expected behavior

Informative error about why an interface cannot extend number (or string -- the error is the same besides the type name)

@younes-io
Copy link

@younes-io younes-io commented Oct 10, 2021

I would think of a message like: an interface cannot extend a primitive type like 'number'; an interface can only extend named types and classes

What do you think?

@PurityLake
Copy link

@PurityLake PurityLake commented Oct 11, 2021

Is this issue being worked on? I would like to look into this as a first issue.

@HarsheetKakar
Copy link

@HarsheetKakar HarsheetKakar commented Oct 11, 2021

I was actually working on it, sorry I forgot to mention that earlier

@HarsheetKakar HarsheetKakar linked a pull request that will close this issue Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants