Skip to content

Commit b74c7de

Browse files
Refine format according to code review
1 parent 75e3d5e commit b74c7de

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/compiler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6610,8 +6610,8 @@ export class Compiler extends DiagnosticEmitter {
66106610
let overrideInstance = overrideInstances[i];
66116611
if (!overrideInstance.is(CommonFlags.Compiled)) continue; // errored
66126612

6613-
const overrideSignature = overrideInstance.signature;
6614-
const originalSignature = instance.signature;
6613+
let overrideSignature = overrideInstance.signature;
6614+
let originalSignature = instance.signature;
66156615

66166616
if (!overrideSignature.isAssignableTo(originalSignature, true)) {
66176617
this.error(

src/types.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1052,13 +1052,12 @@ export class Signature {
10521052
let thisThisType = this.thisType;
10531053
let targetThisType = target.thisType;
10541054

1055-
if (thisThisType != null && targetThisType != null){
1056-
const compatibleThisType = checkCompatibleOverride ? thisThisType.canExtendOrImplement(targetThisType)
1055+
if (thisThisType && targetThisType) {
1056+
const compatibleThisType = checkCompatibleOverride
1057+
? thisThisType.canExtendOrImplement(targetThisType)
10571058
: targetThisType.isAssignableTo(thisThisType);
1058-
if (!compatibleThisType) {
1059-
return false;
1060-
}
1061-
}else if (thisThisType || targetThisType){
1059+
if (!compatibleThisType) return false;
1060+
} else if (thisThisType || targetThisType) {
10621061
return false;
10631062
}
10641063

tests/compiler/class-member-function-as-parameter.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
class A {
22
foo(): void { }
33
}
4+
45
class B extends A {
56
foo(): void { }
67
}
8+
79
function foo(): void { }
10+
811
function consumeA(callback: (this: A) => void): void { }
912
function consumeB(callback: (this: B) => void): void { }
13+
1014
const a = new A();
1115
const b = new B();
16+
1217
consumeB(a.foo); // shouldn't error
1318
consumeA(foo); // should error
1419
consumeA(b.foo); // should error

0 commit comments

Comments
 (0)