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
This is the simplest version of this bug I could find:
functionexample<T1>(){letx={foo: <T2>(t2: T2)=>x,bar: (t1: T1)=>x}returnx;}example<number>().foo("hello").bar(1)// Argument of type 'number' is not assignable to parameter of type 'T1'
The call to bar fails to compile. The type is example<number>, so it should compile.
If I try to add type information to x, another compilation error occurs:
Type '{ foo: (t2: T2) => Example; bar: (t1: T1) => Example; }' is not assignable to type 'Example'.
Types of property 'foo' are incompatible.
Type '(t2: T2) => Example' is not assignable to type '(t2: T2) => Example'.
Type 'Example' is not assignable to type 'Example'.
Types of property 'bar' are incompatible.
Type '(t1: T1) => Example' is not assignable to type '(t1: T1) => Example'.
Types of parameters 't1' and 't1' are incompatible.
Type 'T1' is not assignable to type 'T1'.
let x: Example
Interestingly, removing either the foo or bar methods will allow the code to successfully compile:
The error changed in #10676 for 2.0 to instead mention 1, then fully fixed in #13356 for 2.1. Though, I'm not totally sure we have a test for this, given what changed in the latter PR.
Uh oh!
There was an error while loading. Please reload this page.
This is the simplest version of this bug I could find:
The call to
bar
fails to compile. The type isexample<number>
, so it should compile.If I try to add type information to
x
, another compilation error occurs:Interestingly, removing either the
foo
orbar
methods will allow the code to successfully compile:The text was updated successfully, but these errors were encountered: