Closed
Description
π Search Terms
inference types texts template literal types generic constraint string
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
interface NMap {
1: "A";
2: "B";
3: "C";
4: "D";
}
declare const g: <T extends 1 | 2 | 3>(x: `${T}`) => NMap[T];
type G1 = <T extends 1 | 2 | 3>(x: `${T}`) => NMap[T];
const g1: G1 = g; // should be ok
type G2 = <T extends 1 | 2 | 3 | 4>(x: `${T}`) => NMap[T];
const g2: G2 = g; // should error
type G3 = <T extends 1 | 2>(x: `${T}`) => NMap[T];
const g3: G3 = g; // should be ok
π Actual behavior
All of those assignments fail
π Expected behavior
Only the second assignment should fail
Additional information about the issue
Originally reported by @gabritto here: #56659 (comment)
Metadata
Metadata
Assignees
Labels
No labels
Activity
const
template literal #54648