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
In the example below, the cases t7 and t8 cause a TS error.
importtype{Exact}from"type-fest";interfaceA{a: string;b?: Date|null;}functiontestArg<TextendsExact<A,T>>(a: T){returna;}constt1={a: "a"};testArg(t1);// OK - Type of arg correct, no TS errorconstt2={a: "a",b: newDate()};testArg(t2);// OK - Type of arg correct, no TS errorconstt3={a: "a",b: null};testArg(t3);// OK - Type of arg correct, no TS errorconstt4={a: "a",b: undefined};testArg(t4);// OK - Type of arg correct, no TS errorconstt5={a: "a",b: newDate()asDate|null|undefined};testArg(t5);// OK - Type of arg correct, no TS errorconstt6={a: "a",b: nullasnull|undefined};testArg(t6);// OK - Type of arg correct, no TS errorconstt7={a: "a",b: newDate()asDate|undefined};testArg(t7);// Bug - Type of arg correct, but TS errorconstt8={a: "a",b: newDate()asDate|null};testArg(t8);// Bug - Type of arg correct, but TS error
Error at testArg(t7):
error TS2345: Argument of type '{ a: string; b: Date | undefined; }' is not assignable to parameter of type 'ExactObject<A, { a: string; b: Date | undefined; }>'.
Type '{ a: string; b: Date | undefined; }' is not assignable to type '{ a: string; b?: ExactObject<Date, Date | undefined> | null | undefined; }'.
Types of property 'b' are incompatible.
Type 'Date | undefined' is not assignable to type 'ExactObject<Date, Date | undefined> | null | undefined'.
Type 'Date' is not assignable to type 'ExactObject<Date, Date | undefined>'.
Type 'Date' is not assignable to type '{ toString: ExactObject<() => string, never>; toDateString: ExactObject<() => string, never>; toTimeString: ExactObject<() => string, never>; ... 41 more ...; [Symbol.toPrimitive]: ExactObject<...>; }'.
Types of property 'toString' are incompatible.
Type '() => string' is not assignable to type 'ExactObject<() => string, never>'.
Type '() => string' is not assignable to type 'Record<string | number | symbol, never>'.
Index signature for type 'string' is missing in type '() => string'.
Error at testArg(t8):
error TS2345: Argument of type '{ a: string; b: Date | null; }' is not assignable to parameter of type 'ExactObject<A, { a: string; b: Date | null; }>'.
Type '{ a: string; b: Date | null; }' is not assignable to type '{ a: string; b?: ExactObject<Date, Date | null> | null | undefined; }'.
Types of property 'b' are incompatible.
Type 'Date | null' is not assignable to type 'ExactObject<Date, Date | null> | null | undefined'.
Type 'Date' is not assignable to type 'ExactObject<Date, Date | null>'.
Type 'Date' is not assignable to type '{ toString: ExactObject<() => string, never>; toDateString: ExactObject<() => string, never>; toTimeString: ExactObject<() => string, never>; ... 41 more ...; [Symbol.toPrimitive]: ExactObject<...>; }'.
Types of property 'toString' are incompatible.
Type '() => string' is not assignable to type 'ExactObject<() => string, never>'.
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
The funding will be given to active contributors.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
In the example below, the cases
t7
andt8
cause a TS error.Error at
testArg(t7)
:Error at
testArg(t8)
:Upvote & Fund
The text was updated successfully, but these errors were encountered: