The Wayback Machine - https://web.archive.org/web/20221224144417/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

Closed
Mr-Andersen opened this issue Oct 6, 2021 · 7 comments · Fixed by #46357
Closed

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

Mr-Andersen opened this issue Oct 6, 2021 · 7 comments · Fixed by #46357
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Milestone

Comments

@Mr-Andersen
Copy link

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)

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Domain: Error Messages The issue relates to error messaging labels Oct 6, 2021
@younes-io
Copy link

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 commented Oct 11, 2021

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

@HarsheetKakar
Copy link
Contributor

HarsheetKakar commented Oct 11, 2021

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

@charan1998
Copy link

charan1998 commented Jan 22, 2022

Anyone working on this? Or can I take this up?

@JoelFickson
Copy link

JoelFickson commented Apr 10, 2022

Was this issue closed? I wanna take it.

@bentongxyz
Copy link
Contributor

bentongxyz commented Apr 28, 2022

Hi there, if this is not being actively worked on right now, may I give this a try?
Thanks!

@JCalmCrasher
Copy link

JCalmCrasher commented May 10, 2022

Hi, @RyanCavanaugh I'm new to TypeScript; I'll like to give this a try.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
10 participants