-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Description
π Search Terms
It may be a bug or a feature, I am not sure.
I used the branded type technique and expected it to guard it from similar nested types, but got no error.
π Version & Regression Information
all the versions (also in 7)
β― Playground Link
π» Code
declare const __brand: unique symbol;
export type Branded<T, B extends string> = T & { readonly [__brand]: B };
type Apple = Branded<string, 'Apple'>;
type Orange = Branded<string, 'Orange'>;
type A = Record<Apple, Record<Orange, true>>;
type B = Record<Orange, Record<Apple, true>>;
const a: A = {};
function foo(input: B) {
return;
}
// Sould error
foo(a);Note:
- It works for an array
- It also doesn't work for simpler, non-nested records for example Record<Apple, number>.
π Actual behavior
foo(a) passes
π Expected behavior
foo(a) should error
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels