Cannot infer Template Literal Type containing ${number} / ${string} · Issue #43060 · microsoft/TypeScript (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@kotarella1110

Description

@kotarella1110

Bug Report

Cannot infer Template Literal Type containing ${number} / ${string}

🔎 Search Terms

🕗 Version & Regression Information

Playground link with relevant code

💻 Code

// ${number} issue type A = T extends ${infer U}.${infer V} ? U | V : never type B = A<test.1024>; // This will be "test" | "1024" as expected type C = A<test.${number}>; // Expected "test" | ${number} or "test" | number but this will be never type D = T extends ${infer U}.${number} ? U : never type E = D<test.1024>; // This will be "test" as expected type F = D<test.${number}>; // Expected "test" but this will be never // ${string} issue type G = T extends ${infer U}.${infer V} ? U | V : never type H = G<test.hoge>; // This will be "test" | "hoge" as expected type I = G<test.${string}>; // Expected "test" | ${string} or "test" | string but this will be never type J = T extends ${infer U}.${string} ? U : never type K = J<test.hoge>; // This will be "test" as expected type L = J<test.${string}>; // Expected "test" but this will be never

🙁 Actual behavior

🙂 Expected behavior