Fix ASI after get/set keyword (#60225)
This commit is contained in:
Родитель
03c5a37cfb
Коммит
bd1641f769
|
@ -2779,10 +2779,12 @@ namespace Parser {
|
|||
case SyntaxKind.DefaultKeyword:
|
||||
return nextTokenCanFollowDefaultKeyword();
|
||||
case SyntaxKind.StaticKeyword:
|
||||
nextToken();
|
||||
return canFollowModifier();
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
nextToken();
|
||||
return canFollowModifier();
|
||||
return canFollowGetOrSetKeyword();
|
||||
default:
|
||||
return nextTokenIsOnSameLineAndCanFollowModifier();
|
||||
}
|
||||
|
@ -2813,6 +2815,11 @@ namespace Parser {
|
|||
|| isLiteralPropertyName();
|
||||
}
|
||||
|
||||
function canFollowGetOrSetKeyword(): boolean {
|
||||
return token() === SyntaxKind.OpenBracketToken
|
||||
|| isLiteralPropertyName();
|
||||
}
|
||||
|
||||
function nextTokenCanFollowDefaultKeyword(): boolean {
|
||||
nextToken();
|
||||
return token() === SyntaxKind.ClassKeyword
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
error TS2318: Cannot find global type 'IterableIterator'.
|
||||
canFollowGetSetKeyword.ts(10,5): error TS18004: No value exists in scope for the shorthand property 'get'. Either declare one or provide an initializer.
|
||||
canFollowGetSetKeyword.ts(11,5): error TS1005: ',' expected.
|
||||
canFollowGetSetKeyword.ts(14,5): error TS18004: No value exists in scope for the shorthand property 'set'. Either declare one or provide an initializer.
|
||||
canFollowGetSetKeyword.ts(15,5): error TS1005: ',' expected.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'IterableIterator'.
|
||||
==== canFollowGetSetKeyword.ts (4 errors) ====
|
||||
class A {
|
||||
get
|
||||
*x() {}
|
||||
}
|
||||
class B {
|
||||
set
|
||||
*x() {}
|
||||
}
|
||||
const c = {
|
||||
get
|
||||
~~~
|
||||
!!! error TS18004: No value exists in scope for the shorthand property 'get'. Either declare one or provide an initializer.
|
||||
*x() {}
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
};
|
||||
const d = {
|
||||
set
|
||||
~~~
|
||||
!!! error TS18004: No value exists in scope for the shorthand property 'set'. Either declare one or provide an initializer.
|
||||
*x() {}
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
};
|
|
@ -0,0 +1,76 @@
|
|||
//// [tests/cases/conformance/classes/propertyMemberDeclarations/canFollowGetSetKeyword.ts] ////
|
||||
|
||||
//// [canFollowGetSetKeyword.ts]
|
||||
class A {
|
||||
get
|
||||
*x() {}
|
||||
}
|
||||
class B {
|
||||
set
|
||||
*x() {}
|
||||
}
|
||||
const c = {
|
||||
get
|
||||
*x() {}
|
||||
};
|
||||
const d = {
|
||||
set
|
||||
*x() {}
|
||||
};
|
||||
|
||||
//// [canFollowGetSetKeyword.js]
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var A = /** @class */ (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.x = function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
}); };
|
||||
return A;
|
||||
}());
|
||||
var B = /** @class */ (function () {
|
||||
function B() {
|
||||
}
|
||||
B.prototype.x = function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
}); };
|
||||
return B;
|
||||
}());
|
||||
var c = {
|
||||
get: get,
|
||||
x: function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
}); }
|
||||
};
|
||||
var d = {
|
||||
set: set,
|
||||
x: function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
}); }
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
// @noTypesAndSymbols: true
|
||||
class A {
|
||||
get
|
||||
*x() {}
|
||||
}
|
||||
class B {
|
||||
set
|
||||
*x() {}
|
||||
}
|
||||
const c = {
|
||||
get
|
||||
*x() {}
|
||||
};
|
||||
const d = {
|
||||
set
|
||||
*x() {}
|
||||
};
|
Загрузка…
Ссылка в новой задаче