TypeScript Version: 3.6.0-dev.20190602 (seems to work with 20190601)
Search Terms:
Code
// @noImplicitAny: true
interface I {
a: string;
b: string;
}
declare function compare(a: I, b: I): number;
function test() {
const result = [];
result.push({foo: true, a: 'a', b: 'b'});
// ~~~~~~~~~ error here
result.sort(compare); // commenting out this line makes the error disappear
}
Expected behavior:
No error
Actual behavior:
Argument of type '(a: I, b: I) => number' is not assignable to parameter of type '(a: { foo: boolean; a: string; b: string; }, b: { foo: boolean; a: string; b: string; }) => number'.
Types of parameters 'a' and 'a' are incompatible.
Type '{ foo: boolean; a: string; b: string; }' is not assignable to type 'I'.
Object literal may only specify known properties, and 'foo' does not exist in type 'I'.
Maybe the error makes sense with strictNullChecks enabled (which is off in the above example), but then the location is completely off
Playground Link:
Related Issues:
The only two changes in that version are #31711 and #31687. /cc @ahejlsberg
TypeScript Version: 3.6.0-dev.20190602 (seems to work with 20190601)
Search Terms:
Code
Expected behavior:
No error
Actual behavior:
Maybe the error makes sense with
strictNullChecksenabled (which is off in the above example), but then the location is completely offPlayground Link:
Related Issues:
The only two changes in that version are #31711 and #31687. /cc @ahejlsberg