-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19149 from Kingwl/fix-incorrect-super-without-bas…
…e-class fix super call from class that has no basetype but with same symbol (#19068)
- Loading branch information
Showing
6 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...elines/reference/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
tests/cases/conformance/es6/classDeclaration/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts(5,9): error TS2335: 'super' can only be referenced in a derived class. | ||
|
||
|
||
==== tests/cases/conformance/es6/classDeclaration/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts (1 errors) ==== | ||
interface Foo extends Array<number> {} | ||
|
||
class Foo { | ||
constructor() { | ||
super(); // error | ||
~~~~~ | ||
!!! error TS2335: 'super' can only be referenced in a derived class. | ||
} | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//// [superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts] | ||
interface Foo extends Array<number> {} | ||
|
||
class Foo { | ||
constructor() { | ||
super(); // error | ||
} | ||
} | ||
|
||
|
||
//// [superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.js] | ||
var Foo = /** @class */ (function () { | ||
function Foo() { | ||
_this = _super.call(this) || this; // error | ||
} | ||
return Foo; | ||
}()); |
13 changes: 13 additions & 0 deletions
13
...baselines/reference/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
=== tests/cases/conformance/es6/classDeclaration/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts === | ||
interface Foo extends Array<number> {} | ||
>Foo : Symbol(Foo, Decl(superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts, 0, 0), Decl(superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts, 0, 38)) | ||
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) | ||
|
||
class Foo { | ||
>Foo : Symbol(Foo, Decl(superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts, 0, 0), Decl(superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts, 0, 38)) | ||
|
||
constructor() { | ||
super(); // error | ||
} | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
...s/baselines/reference/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
=== tests/cases/conformance/es6/classDeclaration/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts === | ||
interface Foo extends Array<number> {} | ||
>Foo : Foo | ||
>Array : T[] | ||
|
||
class Foo { | ||
>Foo : Foo | ||
|
||
constructor() { | ||
super(); // error | ||
>super() : void | ||
>super : any | ||
} | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
...nce/es6/classDeclaration/superCallFromClassThatHasNoBaseTypeButWithSameSymbolInterface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
interface Foo extends Array<number> {} | ||
|
||
class Foo { | ||
constructor() { | ||
super(); // error | ||
} | ||
} |