mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-02 14:48:32 -05:00
fix(38283): fix incorrect parsing of static modifier (#41127)
This commit is contained in:
@@ -1768,6 +1768,7 @@ namespace ts {
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
return nextTokenCanFollowDefaultKeyword();
|
||||
case SyntaxKind.StaticKeyword:
|
||||
return nextTokenIsOnSameLineAndCanFollowModifier();
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
nextToken();
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
tests/cases/compiler/staticAsIdentifier.ts(2,5): error TS1071: 'static' modifier cannot appear on an index signature.
|
||||
tests/cases/compiler/staticAsIdentifier.ts(12,12): error TS1030: 'static' modifier already seen.
|
||||
tests/cases/compiler/staticAsIdentifier.ts(16,12): error TS1030: 'static' modifier already seen.
|
||||
|
||||
|
||||
==== tests/cases/compiler/staticAsIdentifier.ts (1 errors) ====
|
||||
class C {
|
||||
==== tests/cases/compiler/staticAsIdentifier.ts (2 errors) ====
|
||||
class C1 {
|
||||
static static
|
||||
~~~~~~
|
||||
!!! error TS1071: 'static' modifier cannot appear on an index signature.
|
||||
[x: string]: string;
|
||||
}
|
||||
}
|
||||
|
||||
class C2 {
|
||||
static static
|
||||
m() {}
|
||||
}
|
||||
|
||||
class C3 {
|
||||
static static p: string;
|
||||
~~~~~~
|
||||
!!! error TS1030: 'static' modifier already seen.
|
||||
}
|
||||
|
||||
class C4 {
|
||||
static static foo() {}
|
||||
~~~~~~
|
||||
!!! error TS1030: 'static' modifier already seen.
|
||||
}
|
||||
|
||||
@@ -1,12 +1,43 @@
|
||||
//// [staticAsIdentifier.ts]
|
||||
class C {
|
||||
class C1 {
|
||||
static static
|
||||
[x: string]: string;
|
||||
}
|
||||
}
|
||||
|
||||
class C2 {
|
||||
static static
|
||||
m() {}
|
||||
}
|
||||
|
||||
class C3 {
|
||||
static static p: string;
|
||||
}
|
||||
|
||||
class C4 {
|
||||
static static foo() {}
|
||||
}
|
||||
|
||||
|
||||
//// [staticAsIdentifier.js]
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
var C1 = /** @class */ (function () {
|
||||
function C1() {
|
||||
}
|
||||
return C;
|
||||
return C1;
|
||||
}());
|
||||
var C2 = /** @class */ (function () {
|
||||
function C2() {
|
||||
}
|
||||
C2.prototype.m = function () { };
|
||||
return C2;
|
||||
}());
|
||||
var C3 = /** @class */ (function () {
|
||||
function C3() {
|
||||
}
|
||||
return C3;
|
||||
}());
|
||||
var C4 = /** @class */ (function () {
|
||||
function C4() {
|
||||
}
|
||||
C4.foo = function () { };
|
||||
return C4;
|
||||
}());
|
||||
|
||||
@@ -1,8 +1,35 @@
|
||||
=== tests/cases/compiler/staticAsIdentifier.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(staticAsIdentifier.ts, 0, 0))
|
||||
class C1 {
|
||||
>C1 : Symbol(C1, Decl(staticAsIdentifier.ts, 0, 0))
|
||||
|
||||
static static
|
||||
>static : Symbol(C1.static, Decl(staticAsIdentifier.ts, 0, 10))
|
||||
|
||||
[x: string]: string;
|
||||
>x : Symbol(x, Decl(staticAsIdentifier.ts, 2, 5))
|
||||
}
|
||||
|
||||
class C2 {
|
||||
>C2 : Symbol(C2, Decl(staticAsIdentifier.ts, 3, 1))
|
||||
|
||||
static static
|
||||
>static : Symbol(C2.static, Decl(staticAsIdentifier.ts, 5, 10))
|
||||
|
||||
m() {}
|
||||
>m : Symbol(C2.m, Decl(staticAsIdentifier.ts, 6, 17))
|
||||
}
|
||||
|
||||
class C3 {
|
||||
>C3 : Symbol(C3, Decl(staticAsIdentifier.ts, 8, 1))
|
||||
|
||||
static static p: string;
|
||||
>p : Symbol(C3.p, Decl(staticAsIdentifier.ts, 10, 10))
|
||||
}
|
||||
|
||||
class C4 {
|
||||
>C4 : Symbol(C4, Decl(staticAsIdentifier.ts, 12, 1))
|
||||
|
||||
static static foo() {}
|
||||
>foo : Symbol(C4.foo, Decl(staticAsIdentifier.ts, 14, 10))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,35 @@
|
||||
=== tests/cases/compiler/staticAsIdentifier.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
class C1 {
|
||||
>C1 : C1
|
||||
|
||||
static static
|
||||
>static : any
|
||||
|
||||
[x: string]: string;
|
||||
>x : string
|
||||
}
|
||||
|
||||
class C2 {
|
||||
>C2 : C2
|
||||
|
||||
static static
|
||||
>static : any
|
||||
|
||||
m() {}
|
||||
>m : () => void
|
||||
}
|
||||
|
||||
class C3 {
|
||||
>C3 : C3
|
||||
|
||||
static static p: string;
|
||||
>p : string
|
||||
}
|
||||
|
||||
class C4 {
|
||||
>C4 : C4
|
||||
|
||||
static static foo() {}
|
||||
>foo : () => void
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
class C {
|
||||
class C1 {
|
||||
static static
|
||||
[x: string]: string;
|
||||
}
|
||||
}
|
||||
|
||||
class C2 {
|
||||
static static
|
||||
m() {}
|
||||
}
|
||||
|
||||
class C3 {
|
||||
static static p: string;
|
||||
}
|
||||
|
||||
class C4 {
|
||||
static static foo() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user