TypeScript/tests/baselines/reference/classUpdateTests.errors.txt
Josh Goldberg 541e553163
Specific diagnostic suggestions for unexpected keyword or identifier (#43005)
Error message improvement for unexpected tokens in the following situations:

* A word was parsed that seems to have a low edit distance from a known common keyword
* A word was parsed that seems to be a known common keyword and a name _without_ a space in-between
* Parsing in a particular type of node (mostly a class property declaration) got a different word or token than expected

___

* Specific diagnostic suggestions for unexpected keywords or identifier

* Don't reach into there, that's not allowed

* Improved error when there is already an initializer

* Specific module error message for invalid template literal strings

* Skip 'unexpected keyword or identifier' diagnostics for declare nodes

* Improve error for function calls in type positions

* Switch class properties to old diagnostic

* Corrected errors in class members and reused existing textToKeywordObj map

* Corrected more baselines from the merge

* Update src/compiler/parser.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Mostly addressed feedback

* Clarified function call type message

* Split up and clarified parsing vs error functions

* Swap interface name complaints back, and skip new errors on unknown (invalid) tokens

* Used tokenToString, not a raw semicolon

* Inline getExpressionText helper

* Remove remarks in src/compiler/parser.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-07-14 13:50:55 -07:00

180 lines
6.2 KiB
Plaintext

tests/cases/compiler/classUpdateTests.ts(34,2): error TS2377: Constructors for derived classes must contain a 'super' call.
tests/cases/compiler/classUpdateTests.ts(43,18): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
tests/cases/compiler/classUpdateTests.ts(63,7): error TS2415: Class 'L' incorrectly extends base class 'G'.
Property 'p1' is private in type 'L' but not in type 'G'.
tests/cases/compiler/classUpdateTests.ts(69,7): error TS2415: Class 'M' incorrectly extends base class 'G'.
Property 'p1' is private in type 'M' but not in type 'G'.
tests/cases/compiler/classUpdateTests.ts(70,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
tests/cases/compiler/classUpdateTests.ts(93,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(95,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(99,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(101,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(105,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(105,10): error TS1434: Unexpected keyword or identifier.
tests/cases/compiler/classUpdateTests.ts(105,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/classUpdateTests.ts(107,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(111,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(111,11): error TS1434: Unexpected keyword or identifier.
tests/cases/compiler/classUpdateTests.ts(111,15): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or statement expected.
==== tests/cases/compiler/classUpdateTests.ts (18 errors) ====
//
// test codegen for instance properties
//
class A {
public p1 = 0;
private p2 = 0;
p3;
}
class B {
public p1 = 0;
private p2 = 0;
p3;
constructor() {}
}
class C {
constructor(public p1=0, private p2=0, p3=0) {}
}
//
// test requirements for super calls
//
class D { // NO ERROR
}
class E extends D { // NO ERROR
public p1 = 0;
}
class F extends E {
constructor() {} // ERROR - super call required
~~~~~~~~~~~~~~~~
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
}
class G extends D {
public p1 = 0;
constructor() { super(); } // NO ERROR
}
class H {
constructor() { super(); } // ERROR - no super call allowed
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
}
class I extends Object {
constructor() { super(); } // ERROR - no super call allowed
}
class J extends G {
constructor(public p1:number) {
super(); // NO ERROR
}
}
class K extends G {
constructor(public p1:number) { // ERROR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var i = 0;
~~~~~~~~~~~~
super();
~~~~~~~~~~
}
~~
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
}
class L extends G {
~
!!! error TS2415: Class 'L' incorrectly extends base class 'G'.
!!! error TS2415: Property 'p1' is private in type 'L' but not in type 'G'.
constructor(private p1:number) {
super(); // NO ERROR
}
}
class M extends G {
~
!!! error TS2415: Class 'M' incorrectly extends base class 'G'.
!!! error TS2415: Property 'p1' is private in type 'M' but not in type 'G'.
constructor(private p1:number) { // ERROR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var i = 0;
~~~~~~~~~~~~
super();
~~~~~~~~~~
}
~~
!!! error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers.
}
//
// test this reference in field initializers
//
class N {
public p1 = 0;
public p2 = this.p1;
constructor() {
this.p2 = 0;
}
}
//
// test error on property declarations within class constructors
//
class O {
constructor() {
public p1 = 0; // ERROR
~~~~~~
!!! error TS1128: Declaration or statement expected.
}
}
~
!!! error TS1128: Declaration or statement expected.
class P {
constructor() {
private p1 = 0; // ERROR
~~~~~~~
!!! error TS1128: Declaration or statement expected.
}
}
~
!!! error TS1128: Declaration or statement expected.
class Q {
constructor() {
public this.p1 = 0; // ERROR
~~~~~~
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS1434: Unexpected keyword or identifier.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
}
}
~
!!! error TS1128: Declaration or statement expected.
class R {
constructor() {
private this.p1 = 0; // ERROR
~~~~~~~
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS1434: Unexpected keyword or identifier.
~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
}
}
~
!!! error TS1128: Declaration or statement expected.