Skip to content

Poor error message for computed string enums #25896

@DanielRosenwasser

Description

@DanielRosenwasser

https://twitter.com/larymagal/status/1021741263358443520

As a more basic example:

declare function bar(): string
enum E {
  foo = bar();
}

Currently we give the error

Type 'string' is not assignable to type 'E'.

However, we should give an error like

Only numeric enums can have computed members, but this expression has type 'string'.
  If you do not need exhaustiveness checks, consider using an object literal instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions