Skip to content

template literals fail to type check as string literals #17595

@spoonscen

Description

@spoonscen

TypeScript Version: 2.4.0

Code

type Foo = 'lol'

const barr: Foo = `lol`
// Type 'string' is not assignable to type '"lol"'.

https://www.typescriptlang.org/play/#src=type%20Foo%20%3D%20'lol'%0A%0Aconst%20barr%3A%20Foo%20%3D%20%60lol%60

Expected behavior:

type Foo = 'lol'

const barr: Foo = `lol`
// No error

Actual behavior:

type Foo = 'lol'

const barr: Foo = `lol`
// Type 'string' is not assignable to type '"lol"'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions