Skip to content

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

Closed
@derolf

Description

@derolf

TypeScript Version:* 4.1.0-dev.20200914

Search Terms:

Templated literal types

Code

type Foo<T extends number> = `${T}`;
const foo : Foo<number> = "bar";                                 <-- should fail to compile

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

Metadata

Metadata

Assignees

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