You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
as const breaks intra expression inferenceΒ #62220
declarefunctiontest<T,D>(arg: {input: D;produce: (arg: D)=>T;consume: (arg: T)=>number;}): D;constbroken=test({input: 100,produce: (arg)=>arg.toString(),// 'arg' is of type 'unknown'.(18046)consume: (arg)=>arg.length,}asconst);constworking=test({input: 100,produce: (arg)=>arg.toString(),// `arg` inferred as `number`consume: (arg)=>arg.length,});
π Actual behavior
as const is the only difference between those two and its presence breaks assigned parameter type in produce
π Expected behavior
I think as const should not impact inference this way and both should be inferred just OK. It's just that the broken case should infer 100 instead of number for the D type parameter
Activity