Skip to content

Commit 5d78a74

Browse files
committed
chore: bump typescript
1 parent 52748ee commit 5d78a74

File tree

3 files changed

+45
-33
lines changed

3 files changed

+45
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"acorn-jsx": "~5.3.2",
3838
"microbundle": "^0.15.1",
3939
"prettier": "~3.5.2",
40-
"typescript": "^4.8.4",
40+
"typescript": "^5.7.3",
4141
"test262": "git+https://github.com/tc39/test262.git#dac69563480b9f22709fd49d61a32b3a0513b6b1",
4242
"test262-parser-runner": "^0.5.0",
4343
"vitest": "^3.0.7"

pnpm-lock.yaml

Lines changed: 21 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ function tsPlugin(options?: {
215215
* default kind is undefined
216216
* */
217217
importOrExportOuterKind: string | undefined = undefined;
218+
ecmaVersion: number;
218219

219220
tsParseConstModifier = this.tsParseModifiers.bind(this, {
220221
allowedModifiers: ['const'],
@@ -225,6 +226,8 @@ function tsPlugin(options?: {
225226

226227
constructor(options: Options, input: string, startPos?: number) {
227228
super(options, input, startPos);
229+
// Acorn normalizes this to numbers 3-16 etc, but it's not reflected in the types
230+
this.ecmaVersion = this.options.ecmaVersion as number;
228231
}
229232

230233
// support in Class static
@@ -2699,13 +2702,13 @@ function tsPlugin(options?: {
26992702
forInit?: boolean
27002703
) {
27012704
this.initFunction(node);
2702-
if (this.options.ecmaVersion >= 9 || (this.options.ecmaVersion >= 6 && !isAsync)) {
2705+
if (this.ecmaVersion >= 9 || (this.ecmaVersion >= 6 && !isAsync)) {
27032706
if (this.type === tt.star && statement & FUNC_HANGING_STATEMENT) {
27042707
this.unexpected();
27052708
}
27062709
node.generator = this.eat(tt.star);
27072710
}
2708-
if (this.options.ecmaVersion >= 8) {
2711+
if (this.ecmaVersion >= 8) {
27092712
node.async = !!isAsync;
27102713
}
27112714
if (statement & FUNC_STATEMENT) {
@@ -2799,7 +2802,7 @@ function tsPlugin(options?: {
27992802
if (this.containsEsc) this.raiseRecoverable(this.start, 'Escape sequence in keyword new');
28002803
let node = this.startNode();
28012804
let meta = this.parseIdent(true);
2802-
if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {
2805+
if (this.ecmaVersion >= 6 && this.eat(tt.dot)) {
28032806
node.meta = meta;
28042807
let containsEsc = this.containsEsc;
28052808

@@ -2833,7 +2836,7 @@ function tsPlugin(options?: {
28332836
}
28342837
// ---end
28352838
if (this.eat(tt.parenL))
2836-
node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false);
2839+
node.arguments = this.parseExprList(tt.parenR, this.ecmaVersion >= 8, false);
28372840
else node.arguments = [];
28382841
return this.finishNode(node, 'NewExpression');
28392842
}
@@ -2985,7 +2988,7 @@ function tsPlugin(options?: {
29852988
}
29862989

29872990
parseExportAllDeclaration(node, exports) {
2988-
if (this.options.ecmaVersion >= 11) {
2991+
if (this.ecmaVersion >= 11) {
29892992
if (this.eatContextual('as')) {
29902993
node.exported = this.parseModuleExportName();
29912994
this.checkExport(exports, node.exported, this.lastTokStart);
@@ -3196,7 +3199,7 @@ function tsPlugin(options?: {
31963199
containsEsc = this.containsEsc;
31973200
let id = this.parseIdent(false);
31983201
if (
3199-
this.options.ecmaVersion >= 8 &&
3202+
this.ecmaVersion >= 8 &&
32003203
!containsEsc &&
32013204
id.name === 'async' &&
32023205
!this.canInsertSemicolon() &&
@@ -3220,7 +3223,7 @@ function tsPlugin(options?: {
32203223
forInit
32213224
);
32223225
if (
3223-
this.options.ecmaVersion >= 8 &&
3226+
this.ecmaVersion >= 8 &&
32243227
id.name === 'async' &&
32253228
this.type === tt.name &&
32263229
!containsEsc &&
@@ -3637,7 +3640,6 @@ function tsPlugin(options?: {
36373640
parseClassElement(constructorAllowsSuper) {
36383641
if (this.eat(tt.semi)) return null;
36393642

3640-
const ecmaVersion = this.options.ecmaVersion;
36413643
let node = this.startNode();
36423644
let keyName = '';
36433645
let isGenerator = false;
@@ -3672,7 +3674,7 @@ function tsPlugin(options?: {
36723674
if (this.tsHasSomeModifiers(node, modifiers)) {
36733675
this.raise(this.start, TypeScriptError.StaticBlockCannotHaveModifier);
36743676
}
3675-
if (ecmaVersion >= 13) {
3677+
if (this.ecmaVersion >= 13) {
36763678
super.parseClassStaticBlock(node);
36773679
return node;
36783680
}
@@ -3719,7 +3721,7 @@ function tsPlugin(options?: {
37193721
keyName = 'static';
37203722
}
37213723
}
3722-
if (!keyName && ecmaVersion >= 8 && this.eatContextual('async')) {
3724+
if (!keyName && this.ecmaVersion >= 8 && this.eatContextual('async')) {
37233725
if (
37243726
(this.isClassElementNameStart() || this.type === tt.star) &&
37253727
!this.canInsertSemicolon()
@@ -3730,7 +3732,7 @@ function tsPlugin(options?: {
37303732
}
37313733
}
37323734

3733-
if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(tt.star)) {
3735+
if (!keyName && (this.ecmaVersion >= 9 || !isAsync) && this.eat(tt.star)) {
37343736
isGenerator = true;
37353737
}
37363738
if (!keyName && !isAsync && !isGenerator) {
@@ -3761,7 +3763,7 @@ function tsPlugin(options?: {
37613763
// Parse element value
37623764
if (
37633765
this.isClassMethod() ||
3764-
ecmaVersion < 13 ||
3766+
this.ecmaVersion < 13 ||
37653767
this.type === tt.parenL ||
37663768
kind !== 'method' ||
37673769
isGenerator ||
@@ -3848,7 +3850,7 @@ function tsPlugin(options?: {
38483850
this.enterScope(functionFlags(isAsync, false) | acornScope.SCOPE_ARROW);
38493851
this.initFunction(node);
38503852
const oldMaybeInArrowParameters = this.maybeInArrowParameters;
3851-
if (this.options.ecmaVersion >= 8) node.async = !!isAsync;
3853+
if (this.ecmaVersion >= 8) node.async = !!isAsync;
38523854

38533855
this.yieldPos = 0;
38543856
this.awaitPos = 0;
@@ -4313,8 +4315,8 @@ function tsPlugin(options?: {
43134315
let startPos = this.start,
43144316
startLoc = this.startLoc,
43154317
val,
4316-
allowTrailingComma = this.options.ecmaVersion >= 8;
4317-
if (this.options.ecmaVersion >= 6) {
4318+
allowTrailingComma = this.ecmaVersion >= 8;
4319+
if (this.ecmaVersion >= 6) {
43184320
const oldMaybeInArrowParameters = this.maybeInArrowParameters;
43194321
this.maybeInArrowParameters = true;
43204322
this.next();
@@ -4542,7 +4544,7 @@ function tsPlugin(options?: {
45424544
// possibleAsync always false here, because we would have handled it above.
45434545
node.arguments = this.parseExprList(
45444546
tt.parenR,
4545-
this.options.ecmaVersion >= 8,
4547+
this.ecmaVersion >= 8,
45464548
false,
45474549
refDestructuringErrors
45484550
);
@@ -4594,7 +4596,7 @@ function tsPlugin(options?: {
45944596
}
45954597
}
45964598
// --- end
4597-
let optionalSupported = this.options.ecmaVersion >= 11;
4599+
let optionalSupported = this.ecmaVersion >= 11;
45984600
let optional = optionalSupported && this.eat(tt.questionDot);
45994601
if (noCalls && optional)
46004602
this.raise(
@@ -4634,7 +4636,7 @@ function tsPlugin(options?: {
46344636
this.awaitIdentPos = 0;
46354637
let exprList = this.parseExprList(
46364638
tt.parenR,
4637-
this.options.ecmaVersion >= 8,
4639+
this.ecmaVersion >= 8,
46384640
false,
46394641
refDestructuringErrors
46404642
);
@@ -4834,7 +4836,7 @@ function tsPlugin(options?: {
48344836

48354837
parseClassFunctionParams() {
48364838
const typeParameters = this.tsTryParseTypeParameters(this.tsParseConstModifier);
4837-
let params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true);
4839+
let params = this.parseBindingList(tt.parenR, false, this.ecmaVersion >= 8, true);
48384840
if (typeParameters) params.typeParameters = typeParameters;
48394841

48404842
return params;
@@ -4852,8 +4854,8 @@ function tsPlugin(options?: {
48524854
oldAwaitPos = this.awaitPos,
48534855
oldAwaitIdentPos = this.awaitIdentPos;
48544856
this.initFunction(node);
4855-
if (this.options.ecmaVersion >= 6) node.generator = isGenerator;
4856-
if (this.options.ecmaVersion >= 8) node.async = !!isAsync;
4857+
if (this.ecmaVersion >= 6) node.generator = isGenerator;
4858+
if (this.ecmaVersion >= 8) node.async = !!isAsync;
48574859

48584860
this.yieldPos = 0;
48594861
this.awaitPos = 0;

0 commit comments

Comments
 (0)