Skip to content

Evaluate compile-time constants #31352

Closed as not planned
Closed as not planned
@n0izn0iz

Description

@n0izn0iz

TypeScript Version: 3.5.0-dev.20190511

Search Terms:

compile-time operations numerical constants

Code

main.ts

const TWO: 2 = 1 + 1;

Expected behavior:

Transpiles without error

Actual behavior:

$> tsc main.ts

main.ts:1:7 - error TS2322: Type 'number' is not assignable to type '2'.

Playground Link:

https://www.typescriptlang.org/play/#src=const%20TWO%3A%202%20%3D%201%20%2B%201%3B

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    SuggestionAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it adds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions