Closed
Description
TypeScript Version: 2.0.3
Transferring my project from 1.8.10 to 2.0.3 ran me into a bunch of issues all similar to the following simplified code example (test.ts):
class X<T> {
bla(x:()=>T|Z<T>) {
}
}
class Y<T> {
bla(x:()=>T) {
}
}
class Z<T> {
}
function doBla<T>(In:T) {
const x:X<T>|Y<T>|T = new X();
if ((<X<T>|Y<T>>x).bla) (<X<T>|Y<T>>x).bla(()=>{return In;}); //<= compiles in 1.8.10, but fails in 2.0.3
}
Expected behavior: compiles (as on tsc 1.8.10)
Actual behavior: does not compile on 2.0.3, see below
mk@mk-actifsource:~/tmp$ tsc -v
Version 1.8.10
mk@mk-actifsource:~/tmp$ tsc test.ts
mk@mk-actifsource:~/tmp$ node_modules/.bin/tsc -v
Version 2.0.3
mk@mk-actifsource:~/tmp$ node_modules/.bin/tsc test.ts
src/test.ts(20,26): error TS2349: Cannot invoke an expression whose type lacks a call signature.
I tried to search for similar issues and found #7294, however I am not sure about relevance of that issue.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
ahejlsberg commentedon Oct 24, 2016
This is the same issue as #10025.
0815fox commentedon Oct 24, 2016
However, #10025 states milestone 2.0.2 - this report is for 2.0.3. Is it really the same issue, which is not yet completely fixed, or just related?
ahejlsberg commentedon Oct 24, 2016
It is the same issue, and it is unfortunately an actual breaking change. As mentioned in the comments for #10025, it happened to work in some cases (including yours) because of aggressive subtype reduction, but we need a different approach to actually fix the issue in the general case.
0815fox commentedon Oct 25, 2016
For others finding this ticket: the currently open ticket handling that case seems to be #9104.
BUT: #9104 is itself market as DUPLICATE as well, however, I cannot find, which "not closed" ticket #9104 actually duplicates.
Can you give us a pointer, which open ticket handles the type inference issue?