Skip to content

Give more helpful error when trying to set default values on an interface #5173

Description

Today I spent a moment scratching my head at the following snippet:

interface Foo {
    bar: number = 5;
}

"Of course!" I say now, I was trying to set a default value on an interface, which makes no sense. TypeScript didn't see that this might be something I would do, and instead gave me a syntax error:

Error TS1005: ';' expected.
Error TS1131: Property or signature expected.
Error TS1128: Declaration or statement expected.

Would it be possible to get a more useful error message for this case (and potentially cases like this?)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions