-
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.
Fix ASI after get/set keyword (#60225)
- Loading branch information
Showing
4 changed files
with
134 additions
and
1 deletion.
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
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/canFollowGetSetKeyword.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,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. | ||
}; |
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,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*/]; | ||
}); } | ||
}; |
17 changes: 17 additions & 0 deletions
17
tests/cases/conformance/classes/propertyMemberDeclarations/canFollowGetSetKeyword.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,17 @@ | ||
// @noTypesAndSymbols: true | ||
class A { | ||
get | ||
*x() {} | ||
} | ||
class B { | ||
set | ||
*x() {} | ||
} | ||
const c = { | ||
get | ||
*x() {} | ||
}; | ||
const d = { | ||
set | ||
*x() {} | ||
}; |