Skip to content

Use variable declared as const as literal type #12603

Closed
@Lenne231

Description

@Lenne231

It would be nice to be able to use a variable declared as const as a literal type in a type annotation.

TypeScript Version: 2.0.0

Code

export const INCREMENT = 'INCREMENT';
export const DECREMENT = 'DECREMENT'
export const ADD = 'ADD';

type Action =
      { type: INCREMENT }
    | { type: DECREMENT };

Expected behavior:
No error, type Action is { type: 'INCREMENT' } | { type: 'DECREMENT' }.

Actual behavior:
Error: Cannot find name INCREMENT

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions