Make sure we have a node for the error in cases of special property assignment
This commit is contained in:
parent
26d5af384c
commit
4546b0dd8e
|
@ -20530,7 +20530,7 @@ namespace ts {
|
|||
errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
|
||||
}
|
||||
|
||||
error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
|
||||
error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
tests/cases/compiler/a.js(14,5): error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property.
|
||||
|
||||
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
// @ts-check
|
||||
class A {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
foo() {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
this.foo = () => 3;
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property.
|
||||
}
|
||||
}
|
||||
|
||||
const i = new B();
|
||||
i.foo();
|
24
tests/cases/compiler/checkJsFiles_noErrorLocation.ts
Normal file
24
tests/cases/compiler/checkJsFiles_noErrorLocation.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
|
||||
// @fileName: a.js
|
||||
// @ts-check
|
||||
class A {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
foo() {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
this.foo = () => 3;
|
||||
}
|
||||
}
|
||||
|
||||
const i = new B();
|
||||
i.foo();
|
Loading…
Reference in a new issue