Closed
Description
TypeScript Version: 3.5.0-dev.20190525
Search Terms:
type substitution is incorrect
Code
const v = { test: { smth: 5 } };
type Field<A extends string, R> = { [K in A]: R } | {}
const f = <A extends string, B extends string, R>(x: { [K in A]: Field<B, R> } | {}): R => ({} as any);
const g = <A extends string, B extends string, R>(x: Field<A, Field<B, R>>): R => ({} as any);
const r1 = f(v); // number
const r2 = g(v); // unknown
Expected behavior:
Both should be number
.
Actual behavior:
unknown
Playground Link:
Link
Related Issues:
Nope.