Skip to content

Bug: (Any) string is assignable to numeric templated literal type #40538

Description

@derolf

TypeScript Version:* 4.1.0-dev.20200914

Search Terms:

Templated literal types

Code

typeFoo<Textendsnumber>= `${T}`;constfoo : Foo<number>="bar";<--shouldfailtocompile

Expected behavior:

It should fail to compile since "bar" should not be assignable to Foo<number>.

Actual behavior:

Compiles.

Playground Link:

https://www.typescriptlang.org/play?ts=4.1.0-dev.20200914#code/C4TwDgpgBAYg9nAPAFShAHsCA7AJgZymwFcBbAIwgCcA+KAXigAMASAb2QF8mBuAKADGcbPmBQAhlABcsBIhIVqdRgCJy4qip5A

Related Issues:

#40336

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions