Skip to content

Enum literal cannot contain concatenated string #20784

@evmar

Description

@evmar

TypeScript Version: 2.7.0-dev.20171216 and older

Code

enum Test {
  A = "a very long string value, such that you want to make it " +
    "span multiple lines to meet some column limit"
}

Expected behavior:
Accepted.

Actual behavior:
error TS2352: Type 'string' cannot be converted to type 'Test'.

Adding some 'as Test' annotation didn't seem to work.

Workarounds:

  • put it all on one very long line
  • wrap in parens, add an "as any"

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions