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
TypeScript Version: 3.6.0-dev.20190701, 3.5.2 (Not present in 3.4.5)
Search Terms:
inconsistent error typing order interface
Code
typeA={a: number};typeB={b: number};typeX<T>=({[KinkeyofT]: T[K]}&Record<string,void>)[keyofT];typeP1<T>={data: X<T>};typeP2<T>={data: X<T>};interfaceI<T>{fn<KextendskeyofT>(p1: P1<Pick<T,K>>,p2: P2<Pick<T,K>>): void;}consti: I<A&B>=nullasany;constp2: P2<A>=nullasany;// Commenting out the below line will remove the error on the `const _i: I<A> = i;`i.fn(nullasany,p2);const_i: I<A>=i;
The above code sample is a simplified version of real code in our code base. I tried simplifying it further but thats as far as I got.
Expected behavior:
The i.fn(null as any, p2); should have no effect on the typing of the const _i: I<A> = i; line.
Actual behavior:
When i.fn(null as any, p2); is present, there is an error on const _i: I<A> = i;,
When i.fn(null as any, p2); is removed OR moved after const _i: I<A> = i;, the error disappears.
Error:
test.ts:15:7 - error TS2322: Type 'I<A & B>' is not assignable to type 'I<A>'.
Type 'A' is not assignable to type 'A & B'.
Property 'b' is missing in type 'A' but required in type 'B'.
15 const _i: I<A> = i;
~~
test.ts:2:12
2 type B = { b: number };
~
'b' is declared here.
Found 1 error.
Playground Link:
I was not able to reproduce in the playground. But an empty compilerOptions and tsc will reliably reproduce the error in the listed versions.
v3.4.5 consistently provides no errors
Related Issues:
The text was updated successfully, but these errors were encountered:
TypeScript Version: 3.6.0-dev.20190701, 3.5.2 (Not present in 3.4.5)
Search Terms:
inconsistent error typing order interface
Code
The above code sample is a simplified version of real code in our code base. I tried simplifying it further but thats as far as I got.
Expected behavior:
The
i.fn(null as any, p2);
should have no effect on the typing of theconst _i: I<A> = i;
line.Actual behavior:
When
i.fn(null as any, p2);
is present, there is an error onconst _i: I<A> = i;
,When
i.fn(null as any, p2);
is removed OR moved afterconst _i: I<A> = i;
, the error disappears.Error:
Playground Link:
I was not able to reproduce in the playground. But an empty
compilerOptions
andtsc
will reliably reproduce the error in the listed versions.v3.4.5 consistently provides no errors
Related Issues:
The text was updated successfully, but these errors were encountered: