Skip to content

Commit cea03b7

Browse files
fix #2727:
class member function type is assigned to a normal function type
1 parent 382aabe commit cea03b7

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ export class Signature {
10631063
} else {
10641064
// check `this` type (invariant)
10651065
if (thisThisType) {
1066-
if (targetThisType != targetThisType) return false;
1066+
if (targetThisType == null) return false;
10671067
} else if (targetThisType) {
10681068
return false;
10691069
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"asc_flags": [
3+
],
4+
"stderr": [
5+
"TS2322: Type '(this: class-member-function-as-parameter/C, i32) => i32' is not assignable to type '(i32) => i32'."
6+
]
7+
}
8+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class C {
2+
aa:i32 = 1;
3+
callback(a: i32): i32 {
4+
return this.aa + a + 3;
5+
}
6+
}
7+
8+
function expectCallback(c1: (arg0: i32) => i32): i32 {
9+
return c1(4);
10+
}
11+
12+
export function fut(): i32 {
13+
const c1 = new C();
14+
return expectCallback(c1.callback);
15+
}
16+

0 commit comments

Comments
 (0)