@danielx/civet 0.11.1 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.mjs CHANGED
@@ -1071,6 +1071,60 @@ function literalType(literal) {
1071
1071
  children: [t]
1072
1072
  };
1073
1073
  }
1074
+ function typeOfExpression(expression) {
1075
+ let t;
1076
+ if (!isASTNodeObject(expression)) {
1077
+ return;
1078
+ }
1079
+ switch (expression.type) {
1080
+ case "Literal": {
1081
+ switch (expression.subtype) {
1082
+ case "NullLiteral": {
1083
+ return;
1084
+ }
1085
+ default: {
1086
+ t = literalType(expression);
1087
+ }
1088
+ }
1089
+ ;
1090
+ break;
1091
+ }
1092
+ case "RegularExpressionLiteral":
1093
+ case "TemplateLiteral": {
1094
+ t = literalType(expression);
1095
+ break;
1096
+ }
1097
+ case "Identifier": {
1098
+ if (expression.name === "undefined") {
1099
+ return;
1100
+ }
1101
+ }
1102
+ case "MemberExpression": {
1103
+ t = {
1104
+ type: "TypeTypeof",
1105
+ children: ["typeof ", expression],
1106
+ expression
1107
+ };
1108
+ break;
1109
+ }
1110
+ default: {
1111
+ return;
1112
+ }
1113
+ }
1114
+ return t;
1115
+ }
1116
+ function typeSuffixForExpression(expression) {
1117
+ const t = typeOfExpression(expression);
1118
+ if (!(t != null)) {
1119
+ return;
1120
+ }
1121
+ return {
1122
+ type: "TypeSuffix",
1123
+ ts: true,
1124
+ t,
1125
+ children: [": ", t]
1126
+ };
1127
+ }
1074
1128
  function makeNumericLiteral(n) {
1075
1129
  const s = n.toString();
1076
1130
  return {
@@ -1948,11 +2002,14 @@ function gatherBindingPatternTypeSuffix(pattern) {
1948
2002
  const results1 = [];
1949
2003
  for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
1950
2004
  const elem = ref7[i7];
1951
- let { typeSuffix } = elem;
2005
+ let { typeSuffix, initializer } = elem;
1952
2006
  typeSuffix ??= elem.binding?.typeSuffix;
1953
2007
  if (typeSuffix) {
1954
2008
  count++;
1955
2009
  }
2010
+ if (initializer != null) {
2011
+ typeSuffix ??= typeSuffixForExpression(trimFirstSpace(initializer.expression));
2012
+ }
1956
2013
  let typeElement = [typeSuffix?.t, elem.delim];
1957
2014
  if (typeSuffix?.optional) {
1958
2015
  typeElement[0] = parenthesizeType(typeElement[0]);
@@ -1987,11 +2044,14 @@ function gatherBindingPatternTypeSuffix(pattern) {
1987
2044
  const results2 = [];
1988
2045
  for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
1989
2046
  const prop = ref8[i8];
1990
- let { typeSuffix } = prop;
2047
+ let { typeSuffix, initializer } = prop;
1991
2048
  typeSuffix ??= prop.value?.typeSuffix;
1992
2049
  if (typeSuffix) {
1993
2050
  count++;
1994
2051
  }
2052
+ if (initializer != null) {
2053
+ typeSuffix ??= typeSuffixForExpression(trimFirstSpace(initializer.expression));
2054
+ }
1995
2055
  typeSuffix ??= {
1996
2056
  type: "TypeSuffix",
1997
2057
  ts: true,
@@ -2852,20 +2912,7 @@ function wrapTypeInApplication(t, id, raw) {
2852
2912
  }
2853
2913
  function implicitFunctionBlock(f) {
2854
2914
  if (f.abstract || f.block || f.signature?.optional) return;
2855
- const { name, parent } = f;
2856
- let ancestor = parent;
2857
- let child = f;
2858
- if (ancestor?.type === "ExportDeclaration") {
2859
- child = ancestor;
2860
- ancestor = ancestor.parent;
2861
- }
2862
- const expressions = ancestor?.expressions ?? ancestor?.elements;
2863
- const currentIndex = expressions?.findIndex(([, def]) => def === child);
2864
- let following = currentIndex >= 0 && expressions[currentIndex + 1]?.[1];
2865
- if (following?.type === "ExportDeclaration") {
2866
- following = following.declaration;
2867
- }
2868
- if (f.type === following?.type && name != null && name === following.name) {
2915
+ if (followingOverloads(f).length) {
2869
2916
  f.ts = true;
2870
2917
  } else {
2871
2918
  const block = makeEmptyBlock();
@@ -2875,6 +2922,66 @@ function implicitFunctionBlock(f) {
2875
2922
  f.ts = false;
2876
2923
  }
2877
2924
  }
2925
+ function overloadsInDirection(f, direction) {
2926
+ if (!(f.name != null)) {
2927
+ return [];
2928
+ }
2929
+ let ancestor = f.parent;
2930
+ let child = f;
2931
+ if (ancestor?.type === "ExportDeclaration") {
2932
+ child = ancestor;
2933
+ ancestor = ancestor.parent;
2934
+ }
2935
+ if (!(ancestor?.type === "BlockStatement")) {
2936
+ return [];
2937
+ }
2938
+ const { expressions } = ancestor;
2939
+ let index = findChildIndex(expressions, child);
2940
+ if (!(index >= 0)) {
2941
+ return [];
2942
+ }
2943
+ if (direction < 0) {
2944
+ const results1 = [];
2945
+ while (--index >= 0) {
2946
+ let candidate = expressions[index][1];
2947
+ if (!candidate) {
2948
+ break;
2949
+ }
2950
+ if (candidate.type === "ExportDeclaration") {
2951
+ candidate = candidate.declaration;
2952
+ }
2953
+ if (!(candidate && candidate.type === f.type && candidate.name === f.name)) {
2954
+ break;
2955
+ }
2956
+ results1.push(candidate);
2957
+ }
2958
+ ;
2959
+ return results1;
2960
+ } else {
2961
+ const results2 = [];
2962
+ while (++index < expressions.length) {
2963
+ let candidate = expressions[index][1];
2964
+ if (!candidate) {
2965
+ break;
2966
+ }
2967
+ if (candidate.type === "ExportDeclaration") {
2968
+ candidate = candidate.declaration;
2969
+ }
2970
+ if (!(candidate && candidate.type === f.type && candidate.name === f.name)) {
2971
+ break;
2972
+ }
2973
+ results2.push(candidate);
2974
+ }
2975
+ ;
2976
+ return results2;
2977
+ }
2978
+ }
2979
+ function precedingOverloads(f) {
2980
+ return overloadsInDirection(f, -1);
2981
+ }
2982
+ function followingOverloads(f) {
2983
+ return overloadsInDirection(f, 1);
2984
+ }
2878
2985
  function processReturn(f, implicitReturns) {
2879
2986
  let { returnType } = f.signature;
2880
2987
  if (returnType && returnType.optional) {
@@ -3092,19 +3199,23 @@ function patternBindings(pattern) {
3092
3199
  function assignResults(node, collect) {
3093
3200
  if (!node) return;
3094
3201
  switch (node.type) {
3095
- case "BlockStatement":
3202
+ case "BlockStatement": {
3096
3203
  if (node.expressions.length) {
3097
3204
  let ref5;
3098
3205
  assignResults((ref5 = node.expressions)[ref5.length - 1], collect);
3099
3206
  } else {
3100
3207
  node.expressions.push(["", collect("void 0"), ";"]);
3208
+ updateParentPointers(node);
3101
3209
  }
3102
3210
  return;
3103
- case "CaseBlock":
3104
- node.clauses.forEach((clause) => {
3105
- return assignResults(clause, collect);
3106
- });
3211
+ }
3212
+ case "CaseBlock": {
3213
+ for (let ref6 = node.clauses, i4 = 0, len3 = ref6.length; i4 < len3; i4++) {
3214
+ const clause = ref6[i4];
3215
+ assignResults(clause, collect);
3216
+ }
3107
3217
  return;
3218
+ }
3108
3219
  case "WhenClause":
3109
3220
  case "DefaultClause":
3110
3221
  case "PatternClause": {
@@ -3130,7 +3241,8 @@ function assignResults(node, collect) {
3130
3241
  if (exp.type === "LabelledStatement") {
3131
3242
  exp = exp.statement;
3132
3243
  }
3133
- let ref6;
3244
+ let ref7;
3245
+ let ref8;
3134
3246
  let m1;
3135
3247
  switch (exp.type) {
3136
3248
  case "BreakStatement":
@@ -3142,18 +3254,19 @@ function assignResults(node, collect) {
3142
3254
  return;
3143
3255
  }
3144
3256
  case "Declaration": {
3145
- let ref7;
3257
+ let ref9;
3146
3258
  if (exp.bindings?.length) {
3147
- ref7 = patternAsValue((ref6 = exp.bindings)[ref6.length - 1].pattern);
3259
+ ref9 = patternAsValue((ref7 = exp.bindings)[ref7.length - 1].pattern);
3148
3260
  } else {
3149
- ref7 = "void 0";
3261
+ ref9 = "void 0";
3150
3262
  }
3151
3263
  ;
3152
- const value = ref7;
3264
+ const value = ref9;
3153
3265
  exp.children.push([
3154
3266
  "",
3155
3267
  [";", collect(value)]
3156
3268
  ]);
3269
+ updateParentPointers(exp);
3157
3270
  return;
3158
3271
  }
3159
3272
  case "FunctionExpression": {
@@ -3162,6 +3275,7 @@ function assignResults(node, collect) {
3162
3275
  "",
3163
3276
  [";", collect(exp.id)]
3164
3277
  ]);
3278
+ updateParentPointers(exp);
3165
3279
  return;
3166
3280
  }
3167
3281
  break;
@@ -3177,7 +3291,7 @@ function assignResults(node, collect) {
3177
3291
  if (exp.expressions.some(isExit)) {
3178
3292
  return;
3179
3293
  }
3180
- assignResults(exp.expressions[exp.expressions.length - 1], collect);
3294
+ assignResults((ref8 = exp.expressions)[ref8.length - 1], collect);
3181
3295
  return;
3182
3296
  }
3183
3297
  case "IfStatement": {
@@ -3187,6 +3301,7 @@ function assignResults(node, collect) {
3187
3301
  } else {
3188
3302
  braceBlock(exp.then);
3189
3303
  exp.children.push([" else {", collect("void 0"), "}"]);
3304
+ updateParentPointers(exp);
3190
3305
  }
3191
3306
  return;
3192
3307
  }
@@ -3195,15 +3310,15 @@ function assignResults(node, collect) {
3195
3310
  return;
3196
3311
  }
3197
3312
  case "SwitchStatement": {
3198
- for (let ref8 = exp.caseBlock.clauses, i4 = 0, len3 = ref8.length; i4 < len3; i4++) {
3199
- const clause = ref8[i4];
3313
+ for (let ref10 = exp.caseBlock.clauses, i5 = 0, len4 = ref10.length; i5 < len4; i5++) {
3314
+ const clause = ref10[i5];
3200
3315
  assignResults(clause, collect);
3201
3316
  }
3202
3317
  return;
3203
3318
  }
3204
3319
  case "TryStatement": {
3205
- for (let ref9 = exp.blocks, i5 = 0, len4 = ref9.length; i5 < len4; i5++) {
3206
- const block = ref9[i5];
3320
+ for (let ref11 = exp.blocks, i6 = 0, len5 = ref11.length; i6 < len5; i6++) {
3321
+ const block = ref11[i6];
3207
3322
  assignResults(block, collect);
3208
3323
  }
3209
3324
  return;
@@ -3215,6 +3330,7 @@ function assignResults(node, collect) {
3215
3330
  const semi2 = exp.children.lastIndexOf(";");
3216
3331
  if (0 <= semi2 && semi2 < exp.children.length - 1) {
3217
3332
  exp.children.splice(semi2 + 1, 1 / 0, ...[collect(exp.children.slice(semi2 + 1))]);
3333
+ updateParentPointers(exp);
3218
3334
  return;
3219
3335
  }
3220
3336
  ;
@@ -3224,7 +3340,11 @@ function assignResults(node, collect) {
3224
3340
  if (node[node.length - 1]?.type === "SemicolonDelimiter") {
3225
3341
  return;
3226
3342
  }
3343
+ const parent = node[1].parent;
3227
3344
  node[1] = collect(node[1]);
3345
+ if (parent != null) {
3346
+ updateParentPointers(parent);
3347
+ }
3228
3348
  }
3229
3349
  function insertReturn(node) {
3230
3350
  if (!node) return;
@@ -3255,9 +3375,9 @@ function insertReturn(node) {
3255
3375
  insertReturn(node.block);
3256
3376
  if (!isExit(node.block)) {
3257
3377
  const comment = hasTrailingComment(node.block.expressions);
3258
- let ref10;
3378
+ let ref12;
3259
3379
  node.block.expressions.push([
3260
- comment ? (ref10 = node.block.expressions)[ref10.length - 1][0] || "\n" : "",
3380
+ comment ? (ref12 = node.block.expressions)[ref12.length - 1][0] || "\n" : "",
3261
3381
  wrapWithReturn(void 0, node, !comment)
3262
3382
  ]);
3263
3383
  }
@@ -3283,7 +3403,7 @@ function insertReturn(node) {
3283
3403
  if (exp.type === "LabelledStatement") {
3284
3404
  exp = exp.statement;
3285
3405
  }
3286
- let ref11;
3406
+ let ref13;
3287
3407
  let m3;
3288
3408
  switch (exp.type) {
3289
3409
  case "BreakStatement":
@@ -3295,14 +3415,14 @@ function insertReturn(node) {
3295
3415
  return;
3296
3416
  }
3297
3417
  case "Declaration": {
3298
- let ref12;
3418
+ let ref14;
3299
3419
  if (exp.bindings?.length) {
3300
- ref12 = [" ", patternAsValue((ref11 = exp.bindings)[ref11.length - 1].pattern)];
3420
+ ref14 = [" ", patternAsValue((ref13 = exp.bindings)[ref13.length - 1].pattern)];
3301
3421
  } else {
3302
- ref12 = [];
3422
+ ref14 = [];
3303
3423
  }
3304
3424
  ;
3305
- const value = ref12;
3425
+ const value = ref14;
3306
3426
  const parent = outer.parent;
3307
3427
  const index = findChildIndex(parent?.expressions, outer);
3308
3428
  assert.notEqual(index, -1, "Could not find declaration in parent");
@@ -3362,15 +3482,15 @@ function insertReturn(node) {
3362
3482
  return;
3363
3483
  }
3364
3484
  case "SwitchStatement": {
3365
- for (let ref13 = exp.caseBlock.clauses, i6 = 0, len5 = ref13.length; i6 < len5; i6++) {
3366
- const clause = ref13[i6];
3485
+ for (let ref15 = exp.caseBlock.clauses, i7 = 0, len6 = ref15.length; i7 < len6; i7++) {
3486
+ const clause = ref15[i7];
3367
3487
  insertReturn(clause);
3368
3488
  }
3369
3489
  return;
3370
3490
  }
3371
3491
  case "TryStatement": {
3372
- for (let ref14 = exp.blocks, i7 = 0, len6 = ref14.length; i7 < len6; i7++) {
3373
- const block = ref14[i7];
3492
+ for (let ref16 = exp.blocks, i8 = 0, len7 = ref16.length; i8 < len7; i8++) {
3493
+ const block = ref16[i8];
3374
3494
  insertReturn(block);
3375
3495
  }
3376
3496
  return;
@@ -3622,9 +3742,9 @@ function iterationDefaultBody(statement) {
3622
3742
  }
3623
3743
  const reduction = statement.type === "ForStatement" && statement.reduction;
3624
3744
  function fillBlock(expression) {
3625
- let ref15;
3745
+ let ref17;
3626
3746
  let m5;
3627
- if (m5 = (ref15 = block.expressions)[ref15.length - 1], Array.isArray(m5) && m5.length >= 2 && typeof m5[1] === "object" && m5[1] != null && "type" in m5[1] && m5[1].type === "EmptyStatement" && "implicit" in m5[1] && m5[1].implicit === true) {
3747
+ if (m5 = (ref17 = block.expressions)[ref17.length - 1], Array.isArray(m5) && m5.length >= 2 && typeof m5[1] === "object" && m5[1] != null && "type" in m5[1] && m5[1].type === "EmptyStatement" && "implicit" in m5[1] && m5[1].implicit === true) {
3628
3748
  block.expressions.pop();
3629
3749
  }
3630
3750
  block.expressions.push(expression);
@@ -3694,8 +3814,8 @@ function processParams(f) {
3694
3814
  function append2(p) {
3695
3815
  (rest ? after : before).push(p);
3696
3816
  }
3697
- for (let ref16 = parameters.parameters, i8 = 0, len7 = ref16.length; i8 < len7; i8++) {
3698
- const param = ref16[i8];
3817
+ for (let ref18 = parameters.parameters, i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
3818
+ const param = ref18[i9];
3699
3819
  switch (param.type) {
3700
3820
  case "ThisType": {
3701
3821
  if (tt) {
@@ -3707,8 +3827,8 @@ function processParams(f) {
3707
3827
  } else {
3708
3828
  tt = trimFirstSpace(param);
3709
3829
  if (before.length || rest) {
3710
- let ref17;
3711
- let delim = (ref17 = tt.children)[ref17.length - 1];
3830
+ let ref19;
3831
+ let delim = (ref19 = tt.children)[ref19.length - 1];
3712
3832
  if (Array.isArray(delim)) {
3713
3833
  delim = delim[delim.length - 1];
3714
3834
  }
@@ -3895,19 +4015,16 @@ function processParams(f) {
3895
4015
  const classExpressions = ancestor.body.expressions;
3896
4016
  let index2 = findChildIndex(classExpressions, f);
3897
4017
  assert.notEqual(index2, -1, "Could not find constructor in class");
3898
- let m7;
3899
- while (m7 = classExpressions[index2 - 1]?.[1], typeof m7 === "object" && m7 != null && "type" in m7 && m7.type === "MethodDefinition" && "name" in m7 && m7.name === "constructor") {
3900
- index2--;
3901
- }
4018
+ index2 -= precedingOverloads(f).length;
3902
4019
  const fStatement = classExpressions[index2];
3903
- for (let ref18 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
3904
- const parameter = ref18[i9];
4020
+ for (let ref20 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i10 = 0, len9 = ref20.length; i10 < len9; i10++) {
4021
+ const parameter = ref20[i10];
3905
4022
  const { accessModifier } = parameter;
3906
4023
  if (!(accessModifier || parameter.typeSuffix)) {
3907
4024
  continue;
3908
4025
  }
3909
- for (let ref19 = gatherRecursive(parameter, ($15) => $15.type === "AtBinding"), i10 = 0, len9 = ref19.length; i10 < len9; i10++) {
3910
- const binding = ref19[i10];
4026
+ for (let ref21 = gatherRecursive(parameter, ($15) => $15.type === "AtBinding"), i11 = 0, len10 = ref21.length; i11 < len10; i11++) {
4027
+ const binding = ref21[i11];
3911
4028
  const typeSuffix = binding.parent?.typeSuffix;
3912
4029
  if (!(accessModifier || typeSuffix)) {
3913
4030
  continue;
@@ -3945,8 +4062,8 @@ function processParams(f) {
3945
4062
  decl: "const"
3946
4063
  }));
3947
4064
  }
3948
- for (let ref20 = splices, i11 = 0, len10 = ref20.length; i11 < len10; i11++) {
3949
- const binding = ref20[i11];
4065
+ for (let ref22 = splices, i12 = 0, len11 = ref22.length; i12 < len11; i12++) {
4066
+ const binding = ref22[i12];
3950
4067
  assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
3951
4068
  prefix.push(makeNode({
3952
4069
  type: "Declaration",
@@ -3993,13 +4110,14 @@ function findSuperCall(block) {
3993
4110
  }
3994
4111
  function processSignature(f) {
3995
4112
  const { block, signature } = f;
4113
+ let addAsync = false;
4114
+ let addGenerator = false;
3996
4115
  if (!f.async?.length && hasAwait(block)) {
3997
4116
  if (f.async != null) {
3998
- f.async.push("async ");
3999
- signature.modifier.async = true;
4117
+ addAsync = true;
4000
4118
  } else {
4001
- for (let ref21 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
4002
- const a = ref21[i12];
4119
+ for (let ref23 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i13 = 0, len12 = ref23.length; i13 < len12; i13++) {
4120
+ const a = ref23[i13];
4003
4121
  const i = findChildIndex(a.parent, a);
4004
4122
  a.parent.children.splice(i + 1, 0, {
4005
4123
  type: "Error",
@@ -4010,11 +4128,10 @@ function processSignature(f) {
4010
4128
  }
4011
4129
  if (!f.generator?.length && hasYield(block)) {
4012
4130
  if (f.generator != null) {
4013
- f.generator.push("*");
4014
- signature.modifier.generator = true;
4131
+ addGenerator = true;
4015
4132
  } else {
4016
- for (let ref22 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
4017
- const y = ref22[i13];
4133
+ for (let ref24 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i14 = 0, len13 = ref24.length; i14 < len13; i14++) {
4134
+ const y = ref24[i14];
4018
4135
  const i = y.children.findIndex(($19) => $19.type === "Yield");
4019
4136
  y.children.splice(i + 1, 0, {
4020
4137
  type: "Error",
@@ -4023,17 +4140,28 @@ function processSignature(f) {
4023
4140
  }
4024
4141
  }
4025
4142
  }
4026
- if (signature.modifier.async && !signature.modifier.generator && signature.returnType && !isPromiseType(signature.returnType.t)) {
4027
- replaceNode(
4028
- signature.returnType.t,
4029
- wrapTypeInPromise(signature.returnType.t),
4030
- signature.returnType
4031
- );
4143
+ for (let ref25 = [f, ...precedingOverloads(f)], i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
4144
+ const overload = ref25[i15];
4145
+ if (addAsync && overload.async != null && !overload.async.length) {
4146
+ overload.async.push("async ");
4147
+ overload.signature.modifier.async = true;
4148
+ }
4149
+ if (addGenerator && overload.generator != null && !overload.generator.length) {
4150
+ overload.generator.push("*");
4151
+ overload.signature.modifier.generator = true;
4152
+ }
4153
+ if (overload.signature.modifier.async && !overload.signature.modifier.generator && overload.signature.returnType && !isPromiseType(overload.signature.returnType.t)) {
4154
+ replaceNode(
4155
+ overload.signature.returnType.t,
4156
+ wrapTypeInPromise(overload.signature.returnType.t),
4157
+ overload.signature.returnType
4158
+ );
4159
+ }
4032
4160
  }
4033
4161
  }
4034
4162
  function processFunctions(statements, config2) {
4035
- for (let ref23 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
4036
- const f = ref23[i14];
4163
+ for (let ref26 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i16 = 0, len15 = ref26.length; i16 < len15; i16++) {
4164
+ const f = ref26[i16];
4037
4165
  if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
4038
4166
  implicitFunctionBlock(f);
4039
4167
  }
@@ -4092,9 +4220,9 @@ function expressionizeIteration(exp) {
4092
4220
  }
4093
4221
  let done;
4094
4222
  if (!async) {
4095
- let ref24;
4096
- if ((ref24 = blockContainingStatement(exp)) && typeof ref24 === "object" && "block" in ref24 && "index" in ref24) {
4097
- const { block: parentBlock, index } = ref24;
4223
+ let ref27;
4224
+ if ((ref27 = blockContainingStatement(exp)) && typeof ref27 === "object" && "block" in ref27 && "index" in ref27) {
4225
+ const { block: parentBlock, index } = ref27;
4098
4226
  statements[0][0] = parentBlock.expressions[index][0];
4099
4227
  parentBlock.expressions.splice(index, index + 1 - index, ...statements);
4100
4228
  updateParentPointers(parentBlock);
@@ -4111,8 +4239,8 @@ function expressionizeIteration(exp) {
4111
4239
  }
4112
4240
  }
4113
4241
  function processIterationExpressions(statements) {
4114
- for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
4115
- const s = ref25[i15];
4242
+ for (let ref28 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i17 = 0, len16 = ref28.length; i17 < len16; i17++) {
4243
+ const s = ref28[i17];
4116
4244
  expressionizeIteration(s);
4117
4245
  }
4118
4246
  }
@@ -4135,13 +4263,13 @@ function processCoffeeDo(ws, expression) {
4135
4263
  if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "ArrowFunction" || typeof expression === "object" && expression != null && "type" in expression && expression.type === "FunctionExpression") {
4136
4264
  let { parameters } = expression;
4137
4265
  const parameterList = parameters.parameters;
4138
- const results1 = [];
4139
- for (let i16 = 0, len15 = parameterList.length; i16 < len15; i16++) {
4140
- let parameter = parameterList[i16];
4266
+ const results3 = [];
4267
+ for (let i18 = 0, len17 = parameterList.length; i18 < len17; i18++) {
4268
+ let parameter = parameterList[i18];
4141
4269
  if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
4142
- let ref26;
4143
- if (ref26 = parameter.initializer) {
4144
- const initializer = ref26;
4270
+ let ref29;
4271
+ if (ref29 = parameter.initializer) {
4272
+ const initializer = ref29;
4145
4273
  args.push(initializer.expression, parameter.delim);
4146
4274
  parameter = {
4147
4275
  ...parameter,
@@ -4154,10 +4282,10 @@ function processCoffeeDo(ws, expression) {
4154
4282
  ));
4155
4283
  }
4156
4284
  }
4157
- results1.push(parameter);
4285
+ results3.push(parameter);
4158
4286
  }
4159
4287
  ;
4160
- const newParameterList = results1;
4288
+ const newParameterList = results3;
4161
4289
  const newParameters = {
4162
4290
  ...parameters,
4163
4291
  parameters: newParameterList,
@@ -4271,8 +4399,9 @@ function unbraceBlock(block) {
4271
4399
  if (block.bare) {
4272
4400
  return;
4273
4401
  }
4402
+ let m;
4274
4403
  let ref;
4275
- if (block.children[0] === " {" && (ref = block.children)[ref.length - 1] === "}") {
4404
+ if ((m = block.children[0], m === " {" || m === "{") && (ref = block.children)[ref.length - 1] === "}") {
4276
4405
  block.children.shift();
4277
4406
  block.children.pop();
4278
4407
  block.bare = true;
@@ -4308,17 +4437,6 @@ function makeEmptyBlock() {
4308
4437
  empty: true
4309
4438
  };
4310
4439
  }
4311
- function makeBlockFragment() {
4312
- const expressions = [];
4313
- return {
4314
- type: "BlockStatement",
4315
- children: expressions,
4316
- parent: void 0,
4317
- expressions,
4318
- bare: false,
4319
- root: false
4320
- };
4321
- }
4322
4440
  function replaceBlockExpression(node, child, replacement) {
4323
4441
  let found = false;
4324
4442
  const { expressions } = node;
@@ -4364,22 +4482,44 @@ function hoistRefDecs(statements) {
4364
4482
  });
4365
4483
  }
4366
4484
  function insertHoistDec(block, node, dec) {
4367
- const { expressions } = block;
4368
- const index = findChildIndex(expressions, node);
4485
+ const statement = ["", dec, ";"];
4486
+ insertBeforeInBlock(block, node, statement);
4487
+ }
4488
+ function insertBeforeInBlock(block, node, ...statements) {
4489
+ const index = findChildIndex(block.expressions, node);
4369
4490
  if (index < 0) {
4370
- throw new Error("Couldn't find expression in block for hoistable declaration.");
4491
+ throw new Error("insertBeforeInBlock couldn't find existing statement in block");
4492
+ }
4493
+ insertBlockStatements(block, index, ...statements);
4494
+ }
4495
+ function insertBlockStatements(block, index, ...statements) {
4496
+ if (!statements.length) {
4497
+ return;
4371
4498
  }
4372
- const statement = [expressions[index][0], dec, ";"];
4373
- expressions[index][0] = "";
4374
- expressions.splice(index, 0, statement);
4375
- updateParentPointers(dec, block);
4499
+ const { expressions } = block;
4500
+ const before = expressions[index];
4501
+ if (statements[0][0] && before?.[0]) {
4502
+ if (!Array.isArray(statements[0][0])) {
4503
+ statements[0][0] = [statements[0][0]];
4504
+ }
4505
+ if (!Array.isArray(before[0])) {
4506
+ before[0] = [before[0]];
4507
+ }
4508
+ statements[0][0] = [...before[0], ...statements[0][0]];
4509
+ } else {
4510
+ statements[0][0] ||= before?.[0];
4511
+ }
4512
+ before[0] = "";
4513
+ expressions.splice(index, 0, ...statements);
4514
+ updateParentPointers(block);
4515
+ braceBlock(block);
4376
4516
  }
4377
4517
  function processBlocks(statements) {
4378
4518
  insertSemicolon(statements);
4379
4519
  for (let ref1 = gatherRecursive(statements, ($) => $.type === "BlockStatement"), i2 = 0, len12 = ref1.length; i2 < len12; i2++) {
4380
4520
  const block = ref1[i2];
4381
- let m;
4382
- if (block.unwrapObject && block.expressions.length === 1 && (m = block.expressions[0][1], typeof m === "object" && m != null && "type" in m && m.type === "ParenthesizedExpression" && "implicit" in m && m.implicit === true && "expression" in m && typeof m.expression === "object" && m.expression != null && "type" in m.expression && m.expression.type === "ObjectExpression")) {
4521
+ let m1;
4522
+ if (block.unwrapObject && block.expressions.length === 1 && (m1 = block.expressions[0][1], typeof m1 === "object" && m1 != null && "type" in m1 && m1.type === "ParenthesizedExpression" && "implicit" in m1 && m1.implicit === true && "expression" in m1 && typeof m1.expression === "object" && m1.expression != null && "type" in m1.expression && m1.expression.type === "ObjectExpression")) {
4383
4523
  const object = block.expressions[0][1].expression;
4384
4524
  if (!(() => {
4385
4525
  let results = true;
@@ -4398,8 +4538,8 @@ function processBlocks(statements) {
4398
4538
  for (let ref2 = object.properties, i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
4399
4539
  const i = i3;
4400
4540
  const prop = ref2[i3];
4401
- let m1;
4402
- if (m1 = prop.name, typeof m1 === "object" && m1 != null && "type" in m1 && m1.type === "ComputedPropertyName" && "implicit" in m1 && m1.implicit === true) {
4541
+ let m2;
4542
+ if (m2 = prop.name, typeof m2 === "object" && m2 != null && "type" in m2 && m2.type === "ComputedPropertyName" && "implicit" in m2 && m2.implicit === true) {
4403
4543
  replaceNode(prop.name, prop.name.expression, prop);
4404
4544
  }
4405
4545
  if (prop.delim?.implicit) {
@@ -4492,8 +4632,8 @@ function needsPrecedingSemicolon(exp) {
4492
4632
  function blockContainingStatement(exp) {
4493
4633
  let child = exp;
4494
4634
  let parent = exp.parent;
4495
- let m2;
4496
- while (parent != null && (m2 = parent.type, m2 === "StatementExpression" || m2 === "PipelineExpression" || m2 === "UnwrappedExpression")) {
4635
+ let m3;
4636
+ while (parent != null && (m3 = parent.type, m3 === "StatementExpression" || m3 === "PipelineExpression" || m3 === "UnwrappedExpression")) {
4497
4637
  child = parent;
4498
4638
  parent = parent.parent;
4499
4639
  }
@@ -5446,22 +5586,23 @@ function processDeclarations(statements) {
5446
5586
  if (typeSuffix && typeSuffix.optional) {
5447
5587
  if (initializer && !typeSuffix.t) {
5448
5588
  const expression = trimFirstSpace(initializer.expression);
5449
- let m;
5450
- if (m = expression.type, m === "Identifier" || m === "MemberExpression") {
5451
- typeSuffix.children.push(": ", typeSuffix.t = {
5452
- type: "TypeTypeof",
5453
- children: ["typeof ", expression],
5454
- expression
5455
- });
5456
- } else if (expression.type === "Literal" || expression.type === "RegularExpressionLiteral" || expression.type === "TemplateLiteral") {
5457
- typeSuffix.children.push(": ", typeSuffix.t = literalType(expression));
5458
- } else {
5589
+ typeSuffix.t = typeOfExpression(expression);
5590
+ if (!(typeSuffix.t != null)) {
5459
5591
  spliceChild(binding, typeSuffix, 1, {
5460
5592
  type: "Error",
5461
- message: `Optional type can only be inferred from literals or member expressions, not ${expression.type}`
5593
+ message: (() => {
5594
+ if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Literal" && "subtype" in expression && expression.subtype === "NullLiteral") {
5595
+ return "Optional type can't be inferred from null";
5596
+ } else if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "Identifier" && "name" in expression && expression.name === "undefined") {
5597
+ return "Optional type can't be inferred from undefined";
5598
+ } else {
5599
+ return `Optional type can only be inferred from literals or member expressions, not ${expression.type}`;
5600
+ }
5601
+ })()
5462
5602
  });
5463
5603
  continue;
5464
5604
  }
5605
+ typeSuffix.children.push(": ", typeSuffix.t);
5465
5606
  }
5466
5607
  if (typeSuffix.t) {
5467
5608
  convertOptionalType(typeSuffix);
@@ -5502,16 +5643,16 @@ function processDeclarations(statements) {
5502
5643
  function prependStatementExpressionBlock(initializer, statement) {
5503
5644
  let { expression: exp } = initializer;
5504
5645
  let ws;
5505
- if (Array.isArray(exp)) {
5646
+ if (Array.isArray(exp) && exp.length === 2 && isWhitespaceOrEmpty(exp[0])) {
5506
5647
  ws = exp[0];
5507
5648
  exp = exp[1];
5508
5649
  }
5509
5650
  if (!(typeof exp === "object" && exp != null && "type" in exp && exp.type === "StatementExpression" || typeof exp === "object" && exp != null && "type" in exp && exp.type === "SpreadElement" && "expression" in exp && typeof exp.expression === "object" && exp.expression != null && "type" in exp.expression && exp.expression.type === "StatementExpression")) {
5510
5651
  return;
5511
5652
  }
5512
- const pre = [];
5513
5653
  const statementExp = exp.statement;
5514
5654
  const blockStatement = [ws || "", statementExp, ";"];
5655
+ const pre = [blockStatement];
5515
5656
  let ref;
5516
5657
  if (statementExp.type === "IterationExpression") {
5517
5658
  if (statementExp.async || statementExp.generator) {
@@ -5527,8 +5668,7 @@ function prependStatementExpressionBlock(initializer, statement) {
5527
5668
  assignResults(blockStatement, (resultNode) => {
5528
5669
  return makeNode({
5529
5670
  type: "AssignmentExpression",
5530
- children: [ref, " = ", resultNode],
5531
- parent: statement2
5671
+ children: [ref, " = ", resultNode]
5532
5672
  });
5533
5673
  });
5534
5674
  const refDec = {
@@ -5545,8 +5685,7 @@ function prependStatementExpressionBlock(initializer, statement) {
5545
5685
  assignResults(blockStatement, (resultNode) => {
5546
5686
  return makeNode({
5547
5687
  type: "AssignmentExpression",
5548
- children: [ref, " = ", resultNode],
5549
- parent: statement
5688
+ children: [ref, " = ", resultNode]
5550
5689
  });
5551
5690
  });
5552
5691
  const refDec = {
@@ -5555,8 +5694,12 @@ function prependStatementExpressionBlock(initializer, statement) {
5555
5694
  };
5556
5695
  pre.unshift(["", refDec, ";"]);
5557
5696
  }
5558
- statement.children.unshift(...pre, blockStatement);
5559
- updateParentPointers(blockStatement, statement);
5697
+ let ref3;
5698
+ if (!((ref3 = blockContainingStatement(statement)) && typeof ref3 === "object" && "block" in ref3 && "index" in ref3)) {
5699
+ throw new Error("Couldn't find block in prependStatementExpressionBlock");
5700
+ }
5701
+ const { block, index } = ref3;
5702
+ insertBlockStatements(block, index, ...pre);
5560
5703
  return ref;
5561
5704
  }
5562
5705
  function processDeclarationCondition(condition, rootCondition, parent) {
@@ -5655,8 +5798,8 @@ function processDeclarationConditionStatement(s) {
5655
5798
  if (conditions.length) {
5656
5799
  let children = condition.children;
5657
5800
  if (s.negated) {
5658
- let m1;
5659
- if (!(m1 = condition.expression, typeof m1 === "object" && m1 != null && "type" in m1 && m1.type === "UnaryExpression" && "children" in m1 && Array.isArray(m1.children) && len2(m1.children, 2) && Array.isArray(m1.children[0]) && len2(m1.children[0], 1) && m1.children[0][0] === "!" && typeof m1.children[1] === "object" && m1.children[1] != null && "type" in m1.children[1] && m1.children[1].type === "ParenthesizedExpression")) {
5801
+ let m;
5802
+ if (!(m = condition.expression, typeof m === "object" && m != null && "type" in m && m.type === "UnaryExpression" && "children" in m && Array.isArray(m.children) && len2(m.children, 2) && Array.isArray(m.children[0]) && len2(m.children[0], 1) && m.children[0][0] === "!" && typeof m.children[1] === "object" && m.children[1] != null && "type" in m.children[1] && m.children[1].type === "ParenthesizedExpression")) {
5660
5803
  throw new Error("Unsupported negated condition");
5661
5804
  }
5662
5805
  ;
@@ -5686,11 +5829,11 @@ function processDeclarationConditionStatement(s) {
5686
5829
  ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
5687
5830
  updateParentPointers(ancestor);
5688
5831
  braceBlock(ancestor);
5689
- let ref3;
5832
+ let ref4;
5690
5833
  switch (s.type) {
5691
5834
  case "IfStatement": {
5692
- if (ref3 = s.else?.block) {
5693
- const elseBlock = ref3;
5835
+ if (ref4 = s.else?.block) {
5836
+ const elseBlock = ref4;
5694
5837
  if (elseBlock.bare && !elseBlock.semicolon) {
5695
5838
  elseBlock.children.push(elseBlock.semicolon = ";");
5696
5839
  }
@@ -5742,38 +5885,19 @@ function processDeclarationConditionStatement(s) {
5742
5885
  if (!blockPrefix) {
5743
5886
  return;
5744
5887
  }
5745
- const newCondition = {
5746
- type: "ParenthesizedExpression",
5747
- children: ["(", ref2, ")"],
5748
- expression: ref2,
5749
- parent: s
5750
- };
5751
- s.children = s.children.map(function(c) {
5752
- if (c === s.condition) {
5753
- return newCondition;
5754
- } else {
5755
- return c;
5756
- }
5757
- });
5758
- s.condition = newCondition;
5759
- updateParentPointers(s);
5760
- if (statementDeclaration) {
5761
- const block = makeEmptyBlock();
5762
- replaceBlockExpression(s.parent, s, block);
5763
- block.expressions.push(["", s]);
5764
- s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix);
5765
- s.parent = block;
5766
- } else {
5767
- const block = blockWithPrefix([["", [{
5888
+ replaceNode(s.condition, parenthesizeExpression(ref2), s);
5889
+ if (!statementDeclaration) {
5890
+ const declStatement = ["", [{
5768
5891
  type: "Declaration",
5769
5892
  children: ["let ", ...condition.expression.children]
5770
- }], ";"], ...blockPrefix], makeEmptyBlock());
5771
- updateParentPointers(block, s.parent);
5772
- replaceBlockExpression(s.parent, s, block);
5773
- block.expressions.push(["", s]);
5774
- s.parent = block;
5775
- }
5776
- ;
5893
+ }], ";"];
5894
+ blockPrefix.unshift(declStatement);
5895
+ }
5896
+ const block = blockWithPrefix(blockPrefix, makeEmptyBlock());
5897
+ updateParentPointers(block, s.parent);
5898
+ replaceBlockExpression(s.parent, s, block);
5899
+ block.expressions.push(["", s]);
5900
+ s.parent = block;
5777
5901
  break;
5778
5902
  }
5779
5903
  }
@@ -5781,12 +5905,12 @@ function processDeclarationConditionStatement(s) {
5781
5905
  function dynamizeFromClause(from) {
5782
5906
  from = from.slice(1);
5783
5907
  from = trimFirstSpace(from);
5784
- let ref4;
5785
- if (ref4 = from[from.length - 1]?.assertion) {
5786
- const assert2 = ref4;
5787
- let ref5;
5788
- ref5 = from[from.length - 1];
5789
- ref5.children = ref5.children.filter((a2) => a2 !== assert2);
5908
+ let ref5;
5909
+ if (ref5 = from[from.length - 1]?.assertion) {
5910
+ const assert2 = ref5;
5911
+ let ref6;
5912
+ ref6 = from[from.length - 1];
5913
+ ref6.children = ref6.children.filter((a2) => a2 !== assert2);
5790
5914
  from.push(", {", assert2.keyword, ":", assert2.object, "}");
5791
5915
  }
5792
5916
  return ["(", ...from, ")"];
@@ -5795,20 +5919,20 @@ function dynamizeImportDeclaration(decl) {
5795
5919
  const { imports } = decl;
5796
5920
  let { star, binding, specifiers } = imports;
5797
5921
  const justDefault = binding && !specifiers && !star;
5798
- let ref6;
5922
+ let ref7;
5799
5923
  {
5800
5924
  if (binding) {
5801
5925
  if (specifiers) {
5802
- ref6 = makeRef();
5926
+ ref7 = makeRef();
5803
5927
  } else {
5804
- ref6 = binding;
5928
+ ref7 = binding;
5805
5929
  }
5806
5930
  } else {
5807
- ref6 = convertNamedImportsToObject(imports, true);
5931
+ ref7 = convertNamedImportsToObject(imports, true);
5808
5932
  }
5809
5933
  }
5810
5934
  ;
5811
- const pattern = ref6;
5935
+ const pattern = ref7;
5812
5936
  const c = "const";
5813
5937
  const expression = [
5814
5938
  justDefault ? "(" : void 0,
@@ -6799,7 +6923,7 @@ function processForInOf($0) {
6799
6923
  var concatAssign2 = (lhs, rhs) => (rhs?.[Symbol.isConcatSpreadable] ?? Array.isArray(rhs) ? lhs.push.apply(lhs, rhs) : lhs.push(rhs), lhs);
6800
6924
  function findDecs(statements) {
6801
6925
  const declarations = gatherNodes(statements, ($) => $.type === "Declaration");
6802
- const declarationNames = declarations.flatMap((d) => d.names);
6926
+ const declarationNames = declarations.flatMap(($1) => $1.names);
6803
6927
  const globals = getConfig().globals || [];
6804
6928
  return new Set(globals.concat(declarationNames));
6805
6929
  }
@@ -6807,16 +6931,16 @@ function createConstLetDecs(statements, scopes, letOrConst) {
6807
6931
  function findVarDecs(statements2, decs) {
6808
6932
  const declarationNames = gatherRecursive(statements2, (node) => {
6809
6933
  return node.type === "Declaration" && node.children && node.children.length > 0 && node.children[0].token && node.children[0].token.startsWith("var") || node.type === "FunctionExpression";
6810
- }).filter((node) => node.type === "Declaration").flatMap((node) => node.names);
6934
+ }).filter(($2) => $2.type === "Declaration").flatMap(($3) => $3.names);
6811
6935
  return new Set(declarationNames);
6812
6936
  }
6813
6937
  let declaredIdentifiers = findVarDecs(statements);
6814
6938
  function hasDec(name) {
6815
- return declaredIdentifiers.has(name) || scopes.some(($1) => $1.has(name));
6939
+ return declaredIdentifiers.has(name) || scopes.some(($4) => $4.has(name));
6816
6940
  }
6817
6941
  function gatherBlockOrOther(statement) {
6818
- return gatherNodes(statement, (s) => s.type === "BlockStatement" || s.type === "AssignmentExpression" || s.type === "Declaration").flatMap((node) => {
6819
- if (node.type == "BlockStatement") {
6942
+ return gatherNodes(statement, ($5) => $5.type === "BlockStatement" || $5.type === "AssignmentExpression" || $5.type === "Declaration").flatMap((node) => {
6943
+ if (node.type === "BlockStatement") {
6820
6944
  return node.bare ? gatherBlockOrOther(node.expressions) : node;
6821
6945
  } else if (node.children && node.children.length) {
6822
6946
  return [...gatherBlockOrOther(node.children), node];
@@ -6828,16 +6952,18 @@ function createConstLetDecs(statements, scopes, letOrConst) {
6828
6952
  let currentScope = /* @__PURE__ */ new Set();
6829
6953
  scopes.push(currentScope);
6830
6954
  const fnNodes = gatherNodes(statements, isFunction);
6831
- const forNodes = gatherNodes(statements, (s) => s.type === "ForStatement");
6955
+ const forNodes = gatherNodes(statements, ($6) => $6.type === "ForStatement");
6832
6956
  let targetStatements = [];
6833
- for (const statement of statements) {
6957
+ for (let i1 = 0, len3 = statements.length; i1 < len3; i1++) {
6958
+ const statement = statements[i1];
6834
6959
  const nodes = gatherBlockOrOther(statement);
6835
6960
  let undeclaredIdentifiers = [];
6836
- for (const node of nodes) {
6837
- if (node.type == "BlockStatement") {
6961
+ for (let i2 = 0, len12 = nodes.length; i2 < len12; i2++) {
6962
+ const node = nodes[i2];
6963
+ if (node.type === "BlockStatement") {
6838
6964
  let block = node;
6839
- let fnNode = fnNodes.find((fnNode2) => fnNode2.block === block);
6840
- let forNode = forNodes.find((forNode2) => forNode2.block === block);
6965
+ let fnNode = fnNodes.find(($7) => $7.block === block);
6966
+ let forNode = forNodes.find(($8) => $8.block === block);
6841
6967
  if (fnNode != null) {
6842
6968
  scopes.push(new Set(fnNode.parameters.names));
6843
6969
  createConstLetDecs(block.expressions, scopes, letOrConst);
@@ -6851,21 +6977,26 @@ function createConstLetDecs(statements, scopes, letOrConst) {
6851
6977
  }
6852
6978
  continue;
6853
6979
  }
6854
- if (node.names == null) continue;
6855
- let names = node.names.filter((name) => !hasDec(name));
6856
- if (node.type == "AssignmentExpression") {
6980
+ if (!(node.names != null)) {
6981
+ continue;
6982
+ }
6983
+ const names = node.names.filter((name) => !hasDec(name));
6984
+ if (node.type === "AssignmentExpression") {
6857
6985
  undeclaredIdentifiers.push(...names);
6858
6986
  }
6859
- names.forEach((name) => currentScope.add(name));
6987
+ for (let i3 = 0, len22 = names.length; i3 < len22; i3++) {
6988
+ const name = names[i3];
6989
+ currentScope.add(name);
6990
+ }
6860
6991
  }
6861
- if (undeclaredIdentifiers.length > 0) {
6992
+ if (undeclaredIdentifiers.length) {
6862
6993
  let indent = statement[0];
6863
- let firstIdentifier = gatherNodes(statement[1], (node) => node.type == "Identifier")[0];
6864
- if (undeclaredIdentifiers.length == 1 && statement[1].type == "AssignmentExpression" && statement[1].names.length == 1 && statement[1].names[0] == undeclaredIdentifiers[0] && firstIdentifier && firstIdentifier.names == undeclaredIdentifiers[0] && gatherNodes(statement[1], (node) => node.type === "ObjectBindingPattern").length == 0) {
6994
+ let firstIdentifier = gatherNodes(statement[1], ($9) => $9.type === "Identifier")[0];
6995
+ if (undeclaredIdentifiers.length === 1 && statement[1].type === "AssignmentExpression" && statement[1].names.length === 1 && statement[1].names[0] === undeclaredIdentifiers[0] && firstIdentifier && firstIdentifier.names == undeclaredIdentifiers[0] && gatherNodes(statement[1], ($10) => $10.type === "ObjectBindingPattern").length === 0) {
6865
6996
  statement[1].children.unshift([`${letOrConst} `]);
6866
6997
  } else {
6867
6998
  let tail = "\n";
6868
- if (gatherNodes(indent, (node) => node.token && node.token.endsWith("\n")).length > 0) {
6999
+ if (gatherNodes(indent, ($11) => $11.token && $11.token.endsWith("\n")).length) {
6869
7000
  tail = void 0;
6870
7001
  }
6871
7002
  targetStatements.push([indent, {
@@ -6882,17 +7013,17 @@ function createConstLetDecs(statements, scopes, letOrConst) {
6882
7013
  }
6883
7014
  function createVarDecs(block, scopes, pushVar) {
6884
7015
  function hasDec(name) {
6885
- return scopes.some(($2) => $2.has(name));
7016
+ return scopes.some(($12) => $12.has(name));
6886
7017
  }
6887
7018
  function findAssignments(statements2, decs2) {
6888
- let assignmentStatements2 = gatherNodes(statements2, ($3) => $3.type === "AssignmentExpression");
7019
+ let assignmentStatements2 = gatherNodes(statements2, ($13) => $13.type === "AssignmentExpression");
6889
7020
  if (assignmentStatements2.length) {
6890
7021
  concatAssign2(
6891
7022
  assignmentStatements2,
6892
7023
  findAssignments(assignmentStatements2.map((s) => s.children), decs2)
6893
7024
  );
6894
7025
  }
6895
- return assignmentStatements2.filter(($4) => !($4.parent?.type === "CoffeeClassPublic"));
7026
+ return assignmentStatements2.filter(($14) => !($14.parent?.type === "CoffeeClassPublic"));
6896
7027
  }
6897
7028
  pushVar ??= (name) => {
6898
7029
  varIds.push(name);
@@ -6903,7 +7034,7 @@ function createVarDecs(block, scopes, pushVar) {
6903
7034
  scopes.push(decs);
6904
7035
  const varIds = [];
6905
7036
  const assignmentStatements = findAssignments(statements, scopes);
6906
- const undeclaredIdentifiers = assignmentStatements.flatMap(($5) => $5?.names || []);
7037
+ const undeclaredIdentifiers = assignmentStatements.flatMap(($15) => $15?.names || []);
6907
7038
  undeclaredIdentifiers.filter((x, i, a) => {
6908
7039
  if (!hasDec(x)) return a.indexOf(x) === i;
6909
7040
  return;
@@ -8069,24 +8200,20 @@ function processAssignments(statements) {
8069
8200
  continue;
8070
8201
  }
8071
8202
  let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
8072
- let block;
8073
8203
  let ref13;
8074
8204
  let ref14;
8075
8205
  if (blockContainingStatement(exp) && !(ref13 = $1[$1.length - 1])?.[ref13.length - 1]?.special && !isShortCircuitOp((ref14 = $1[$1.length - 1])?.[ref14.length - 1])) {
8076
- block = makeBlockFragment();
8077
8206
  let ref15;
8078
8207
  if (ref15 = prependStatementExpressionBlock(
8079
8208
  { type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
8080
- block
8209
+ exp
8081
8210
  )) {
8082
8211
  const ref = ref15;
8083
- exp.children = exp.children.map(($7) => $7 === $2 ? ref : $7);
8212
+ replaceNode($2, ref, exp);
8084
8213
  $2 = ref;
8085
- } else {
8086
- block = void 0;
8087
8214
  }
8088
8215
  }
8089
- if ($1.some(($8) => $8[$8.length - 1].special)) {
8216
+ if ($1.some(($7) => $7[$7.length - 1].special)) {
8090
8217
  if ($1.length !== 1) throw new Error("Only one assignment with id= is allowed");
8091
8218
  const [, lhs, , op] = $1[0];
8092
8219
  const { call, omitLhs } = op;
@@ -8158,7 +8285,7 @@ function processAssignments(statements) {
8158
8285
  break;
8159
8286
  } else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") {
8160
8287
  processBindingPatternLHS(lhs, tail);
8161
- gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
8288
+ gatherRecursiveAll(lhs, ($8) => $8.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
8162
8289
  }
8163
8290
  }
8164
8291
  i--;
@@ -8190,7 +8317,7 @@ function processAssignments(statements) {
8190
8317
  }
8191
8318
  if (refsToDeclare.size) {
8192
8319
  if (exp.hoistDec) {
8193
- exp.hoistDec.children.push([...refsToDeclare].map(($10) => [",", $10]));
8320
+ exp.hoistDec.children.push([...refsToDeclare].map(($9) => [",", $9]));
8194
8321
  } else {
8195
8322
  exp.hoistDec = {
8196
8323
  type: "Declaration",
@@ -8205,11 +8332,6 @@ function processAssignments(statements) {
8205
8332
  if (index < 0) throw new Error("Assertion error: exp not in AssignmentExpression");
8206
8333
  exp.children.splice(index + 1, 0, ...tail);
8207
8334
  }
8208
- if (block) {
8209
- replaceNode(exp, block);
8210
- block.expressions.push(["", exp]);
8211
- exp.parent = block;
8212
- }
8213
8335
  }
8214
8336
  }
8215
8337
  function unchainOptionalMemberExpression(exp, ref, innerExp) {
@@ -8298,7 +8420,7 @@ function attachPostfixStatementAsExpression(exp, post) {
8298
8420
  }
8299
8421
  function processTypes(node) {
8300
8422
  const results1 = [];
8301
- for (let ref17 = gatherRecursiveAll(node, ($11) => $11.type === "TypeUnary"), i8 = 0, len7 = ref17.length; i8 < len7; i8++) {
8423
+ for (let ref17 = gatherRecursiveAll(node, ($10) => $10.type === "TypeUnary"), i8 = 0, len7 = ref17.length; i8 < len7; i8++) {
8302
8424
  const unary = ref17[i8];
8303
8425
  let suffixIndex = unary.suffix.length - 1;
8304
8426
  const results2 = [];
@@ -8426,7 +8548,7 @@ function processTypes(node) {
8426
8548
  return results1;
8427
8549
  }
8428
8550
  function processStatementExpressions(statements) {
8429
- for (let ref19 = gatherRecursiveAll(statements, ($12) => $12.type === "StatementExpression"), i9 = 0, len8 = ref19.length; i9 < len8; i9++) {
8551
+ for (let ref19 = gatherRecursiveAll(statements, ($11) => $11.type === "StatementExpression"), i9 = 0, len8 = ref19.length; i9 < len8; i9++) {
8430
8552
  const exp = ref19[i9];
8431
8553
  const { maybe, statement } = exp;
8432
8554
  if ((maybe || statement.type === "ThrowStatement") && blockContainingStatement(exp)) {
@@ -8574,11 +8696,11 @@ function processBreaksContinues(statements) {
8574
8696
  }
8575
8697
  }
8576
8698
  function processCoffeeClasses(statements) {
8577
- for (let ref23 = gatherRecursiveAll(statements, ($13) => $13.type === "ClassExpression"), i11 = 0, len10 = ref23.length; i11 < len10; i11++) {
8699
+ for (let ref23 = gatherRecursiveAll(statements, ($12) => $12.type === "ClassExpression"), i11 = 0, len10 = ref23.length; i11 < len10; i11++) {
8578
8700
  const ce = ref23[i11];
8579
8701
  const { expressions } = ce.body;
8580
8702
  const indent = expressions[0]?.[0] ?? "\n";
8581
- const autoBinds = expressions.filter(($14) => $14[1]?.autoBind);
8703
+ const autoBinds = expressions.filter(($13) => $13[1]?.autoBind);
8582
8704
  if (autoBinds.length) {
8583
8705
  let construct;
8584
8706
  for (const [, c] of expressions) {
@@ -8627,17 +8749,17 @@ function processCoffeeClasses(statements) {
8627
8749
  })()
8628
8750
  );
8629
8751
  }
8630
- const public_static_function_assignments = expressions.filter(($15) => $15[1]?.type === "CoffeeClassPublic" && $15[1].assignment?.expression?.type === "FunctionExpression").map(($16) => $16[1].assignment);
8752
+ const public_static_function_assignments = expressions.filter(($14) => $14[1]?.type === "CoffeeClassPublic" && $14[1].assignment?.expression?.type === "FunctionExpression").map(($15) => $15[1].assignment);
8631
8753
  for (const public_static_function_assignment of public_static_function_assignments) {
8632
8754
  const id = public_static_function_assignment.lhs[0][1];
8633
8755
  replaceNode(public_static_function_assignment, convertFunctionToMethod(id, public_static_function_assignment.expression));
8634
8756
  }
8635
- const public_static_arrow_function_assignments = expressions.filter(($17) => $17[1]?.type === "CoffeeClassPublic" && $17[1].assignment?.expression?.type === "ArrowFunction").map(($18) => $18[1].assignment);
8757
+ const public_static_arrow_function_assignments = expressions.filter(($16) => $16[1]?.type === "CoffeeClassPublic" && $16[1].assignment?.expression?.type === "ArrowFunction").map(($17) => $17[1].assignment);
8636
8758
  for (const public_static_arrow_function_assignment of public_static_arrow_function_assignments) {
8637
8759
  const id = public_static_arrow_function_assignment.lhs[0][1];
8638
8760
  replaceNode(public_static_arrow_function_assignment, convertArrowFunctionToMethod(id, public_static_arrow_function_assignment.expression));
8639
8761
  }
8640
- const privates = expressions.filter(($19) => $19[1]?.type === "CoffeeClassPrivate");
8762
+ const privates = expressions.filter(($18) => $18[1]?.type === "CoffeeClassPrivate");
8641
8763
  if (!privates.length) {
8642
8764
  continue;
8643
8765
  }
@@ -8702,7 +8824,7 @@ function processProgram(root) {
8702
8824
  root.topLevelYield ? "*" : void 0
8703
8825
  );
8704
8826
  statements = [["", rootIIFE]];
8705
- root.children = root.children.map(($20) => $20 === root.expressions ? statements : $20);
8827
+ root.children = root.children.map(($19) => $19 === root.expressions ? statements : $19);
8706
8828
  root.expressions = statements;
8707
8829
  }
8708
8830
  hoistRefDecs(statements);
@@ -8733,9 +8855,9 @@ async function processProgramAsync(root) {
8733
8855
  await processComptime(statements);
8734
8856
  }
8735
8857
  function processRepl(root, rootIIFE) {
8736
- const topBlock = gatherRecursive(rootIIFE, ($21) => $21.type === "BlockStatement")[0];
8858
+ const topBlock = gatherRecursive(rootIIFE, ($20) => $20.type === "BlockStatement")[0];
8737
8859
  let i = 0;
8738
- for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($22) => $22.type === "Declaration"), i14 = 0, len12 = ref24.length; i14 < len12; i14++) {
8860
+ for (let ref24 = gatherRecursiveWithinFunction(topBlock, ($21) => $21.type === "Declaration"), i14 = 0, len12 = ref24.length; i14 < len12; i14++) {
8739
8861
  const decl = ref24[i14];
8740
8862
  if (!decl.names?.length) {
8741
8863
  continue;
@@ -8749,7 +8871,7 @@ function processRepl(root, rootIIFE) {
8749
8871
  root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
8750
8872
  }
8751
8873
  }
8752
- for (let ref25 = gatherRecursive(topBlock, ($23) => $23.type === "FunctionExpression"), i15 = 0, len13 = ref25.length; i15 < len13; i15++) {
8874
+ for (let ref25 = gatherRecursive(topBlock, ($22) => $22.type === "FunctionExpression"), i15 = 0, len13 = ref25.length; i15 < len13; i15++) {
8753
8875
  const func = ref25[i15];
8754
8876
  if (func.name && func.parent?.type === "BlockStatement") {
8755
8877
  if (func.parent === topBlock) {
@@ -8762,7 +8884,7 @@ function processRepl(root, rootIIFE) {
8762
8884
  }
8763
8885
  }
8764
8886
  }
8765
- for (let ref26 = gatherRecursiveWithinFunction(topBlock, ($24) => $24.type === "ClassExpression"), i16 = 0, len14 = ref26.length; i16 < len14; i16++) {
8887
+ for (let ref26 = gatherRecursiveWithinFunction(topBlock, ($23) => $23.type === "ClassExpression"), i16 = 0, len14 = ref26.length; i16 < len14; i16++) {
8766
8888
  const classExp = ref26[i16];
8767
8889
  let m8;
8768
8890
  if (classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 === "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) {
@@ -8774,7 +8896,7 @@ function processRepl(root, rootIIFE) {
8774
8896
  function processPlaceholders(statements) {
8775
8897
  const placeholderMap = /* @__PURE__ */ new Map();
8776
8898
  const liftedIfs = /* @__PURE__ */ new Set();
8777
- for (let ref27 = gatherRecursiveAll(statements, ($25) => $25.type === "Placeholder"), i17 = 0, len15 = ref27.length; i17 < len15; i17++) {
8899
+ for (let ref27 = gatherRecursiveAll(statements, ($24) => $24.type === "Placeholder"), i17 = 0, len15 = ref27.length; i17 < len15; i17++) {
8778
8900
  const exp = ref27[i17];
8779
8901
  let ancestor;
8780
8902
  if (exp.subtype === ".") {
@@ -9059,7 +9181,7 @@ function typeOfJSXFragment(node, config2) {
9059
9181
  if (type.length === 1) {
9060
9182
  return type[0];
9061
9183
  } else {
9062
- type = type.flatMap(($26) => [$26, ", "]);
9184
+ type = type.flatMap(($25) => [$25, ", "]);
9063
9185
  type.pop();
9064
9186
  return ["[", type, "]"];
9065
9187
  }
@@ -9099,12 +9221,16 @@ var grammar = {
9099
9221
  CommaDelimiter,
9100
9222
  OptionalCommaDelimiter,
9101
9223
  ArgumentList,
9224
+ PostfixedArgumentList,
9102
9225
  NestedArguments,
9103
9226
  NestedArgumentList,
9104
9227
  NestedArgument,
9105
9228
  SingleLineArgumentExpressions,
9106
9229
  WArgumentPart,
9230
+ SingleLinePostfixedArgumentExpressions,
9231
+ WPostfixedArgumentPart,
9107
9232
  ArgumentPart,
9233
+ PostfixedArgumentPart,
9108
9234
  BinaryOpExpression,
9109
9235
  BinaryOpNotDedented,
9110
9236
  BinaryOpRHS,
@@ -9124,6 +9250,7 @@ var grammar = {
9124
9250
  Tuple,
9125
9251
  NWTypePostfix,
9126
9252
  UpdateExpression,
9253
+ UpdateExpressionPattern,
9127
9254
  UpdateExpressionSymbol,
9128
9255
  AssignmentExpression,
9129
9256
  NonPipelineAssignmentExpression,
@@ -9259,7 +9386,7 @@ var grammar = {
9259
9386
  OperatorPrecedence,
9260
9387
  OperatorAssociativity,
9261
9388
  ThinArrowFunction,
9262
- Arrow,
9389
+ ThinArrow,
9263
9390
  ExplicitBlock,
9264
9391
  EmptyBracedContent,
9265
9392
  ImplicitNestedBlock,
@@ -9486,6 +9613,7 @@ var grammar = {
9486
9613
  Debugger,
9487
9614
  MaybeNestedNonPipelineExpression,
9488
9615
  MaybeNestedPostfixedExpression,
9616
+ MaybeNestedPostfixedCommaExpression,
9489
9617
  NestedPostfixedExpressionNoTrailing,
9490
9618
  MaybeNestedExpression,
9491
9619
  MaybeParenNestedExpression,
@@ -10243,7 +10371,7 @@ var $R71 = (0, import_lib2.$R)(new RegExp("#(?!##(?!#))([^\\r\\n]*)", "suy"));
10243
10371
  var $R72 = (0, import_lib2.$R)(new RegExp("[^]*?###", "suy"));
10244
10372
  var $R73 = (0, import_lib2.$R)(new RegExp("###(?!#)", "suy"));
10245
10373
  var $R74 = (0, import_lib2.$R)(new RegExp("\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\/", "suy"));
10246
- var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t\\/\\\\])", "suy"));
10374
+ var $R75 = (0, import_lib2.$R)(new RegExp("(?=[ \\t\\/\\\\#])", "suy"));
10247
10375
  var $R76 = (0, import_lib2.$R)(new RegExp("(?=\\s|\\/|#)", "suy"));
10248
10376
  var $R77 = (0, import_lib2.$R)(new RegExp("(?!\\p{ID_Continue})", "suy"));
10249
10377
  var $R78 = (0, import_lib2.$R)(new RegExp("[=:]", "suy"));
@@ -10501,7 +10629,7 @@ var ImplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(ApplicationSt
10501
10629
  function ImplicitArguments(ctx, state2) {
10502
10630
  return (0, import_lib2.$EVENT)(ctx, state2, "ImplicitArguments", ImplicitArguments$0);
10503
10631
  }
10504
- var ExplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(ArgumentList, (0, import_lib2.$E)((0, import_lib2.$S)(__, Comma)))), __, RestoreAll, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10632
+ var ExplicitArguments$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, AllowAll, (0, import_lib2.$E)((0, import_lib2.$S)(PostfixedArgumentList, (0, import_lib2.$E)((0, import_lib2.$S)(__, Comma)))), __, RestoreAll, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10505
10633
  var open = $1;
10506
10634
  var args = $3;
10507
10635
  var ws = $4;
@@ -10639,6 +10767,35 @@ var ArgumentList$$ = [ArgumentList$0, ArgumentList$1, ArgumentList$2];
10639
10767
  function ArgumentList(ctx, state2) {
10640
10768
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ArgumentList", ArgumentList$$);
10641
10769
  }
10770
+ var PostfixedArgumentList$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(EOS), PostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, (0, import_lib2.$N)(EOS), (0, import_lib2.$E)(_), PostfixedArgumentPart)), (0, import_lib2.$S)(CommaDelimiter, NestedArguments), (0, import_lib2.$Q)((0, import_lib2.$S)(OptionalCommaDelimiter, NestedArguments))), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10771
+ return [
10772
+ $2,
10773
+ ...$3.flatMap(([comma, eos, ws, arg]) => [comma, prepend(ws, arg)]),
10774
+ ...Array.isArray($4[1]) ? [$4[0], ...$4[1]] : $4,
10775
+ ...$5.flatMap(
10776
+ ([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
10777
+ )
10778
+ ];
10779
+ });
10780
+ var PostfixedArgumentList$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(NestedArguments, (0, import_lib2.$Q)((0, import_lib2.$S)(OptionalCommaDelimiter, NestedArguments))), function($skip, $loc, $0, $1, $2) {
10781
+ if (!Array.isArray($1)) $1 = [$1];
10782
+ return [
10783
+ ...trimFirstSpace($1),
10784
+ ...$2.flatMap(
10785
+ ([comma, args]) => Array.isArray(args) ? [comma, ...args] : [comma, args]
10786
+ )
10787
+ ];
10788
+ });
10789
+ var PostfixedArgumentList$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, (0, import_lib2.$E)(_), PostfixedArgumentPart))), function($skip, $loc, $0, $1, $2, $3) {
10790
+ return [
10791
+ prepend($1, $2),
10792
+ ...$3.flatMap(([comma, ws, arg]) => [comma, prepend(ws, arg)])
10793
+ ];
10794
+ });
10795
+ var PostfixedArgumentList$$ = [PostfixedArgumentList$0, PostfixedArgumentList$1, PostfixedArgumentList$2];
10796
+ function PostfixedArgumentList(ctx, state2) {
10797
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedArgumentList", PostfixedArgumentList$$);
10798
+ }
10642
10799
  var NestedArguments$0 = NestedBulletedArray;
10643
10800
  var NestedArguments$1 = NestedImplicitObjectLiteral;
10644
10801
  var NestedArguments$2 = NestedArgumentList;
@@ -10654,7 +10811,7 @@ var NestedArgumentList$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(PushIndent,
10654
10811
  function NestedArgumentList(ctx, state2) {
10655
10812
  return (0, import_lib2.$EVENT)(ctx, state2, "NestedArgumentList", NestedArgumentList$0);
10656
10813
  }
10657
- var NestedArgument$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedImplicitPropertyDefinition), Nested, (0, import_lib2.$N)(Bullet), SingleLineArgumentExpressions, ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10814
+ var NestedArgument$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedImplicitPropertyDefinition), Nested, (0, import_lib2.$N)(Bullet), SingleLinePostfixedArgumentExpressions, ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
10658
10815
  var indent = $2;
10659
10816
  var args = $4;
10660
10817
  var comma = $5;
@@ -10677,6 +10834,18 @@ var WArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$
10677
10834
  function WArgumentPart(ctx, state2) {
10678
10835
  return (0, import_lib2.$EVENT)(ctx, state2, "WArgumentPart", WArgumentPart$0);
10679
10836
  }
10837
+ var SingleLinePostfixedArgumentExpressions$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(WPostfixedArgumentPart, (0, import_lib2.$Q)((0, import_lib2.$S)((0, import_lib2.$S)((0, import_lib2.$E)(_), Comma), WPostfixedArgumentPart))), function($skip, $loc, $0, $1, $2) {
10838
+ return [$1, ...$2.flat()];
10839
+ });
10840
+ function SingleLinePostfixedArgumentExpressions(ctx, state2) {
10841
+ return (0, import_lib2.$EVENT)(ctx, state2, "SingleLinePostfixedArgumentExpressions", SingleLinePostfixedArgumentExpressions$0);
10842
+ }
10843
+ var WPostfixedArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixedArgumentPart), function($skip, $loc, $0, $1, $2) {
10844
+ return prepend($1, $2);
10845
+ });
10846
+ function WPostfixedArgumentPart(ctx, state2) {
10847
+ return (0, import_lib2.$EVENT)(ctx, state2, "WPostfixedArgumentPart", WPostfixedArgumentPart$0);
10848
+ }
10680
10849
  var ArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(DotDotDot, Expression), function($skip, $loc, $0, $1, $2) {
10681
10850
  var spread = $1;
10682
10851
  var expression = $2;
@@ -10701,6 +10870,30 @@ var ArgumentPart$$ = [ArgumentPart$0, ArgumentPart$1];
10701
10870
  function ArgumentPart(ctx, state2) {
10702
10871
  return (0, import_lib2.$EVENT_C)(ctx, state2, "ArgumentPart", ArgumentPart$$);
10703
10872
  }
10873
+ var PostfixedArgumentPart$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(DotDotDot, PostfixedExpression), function($skip, $loc, $0, $1, $2) {
10874
+ var spread = $1;
10875
+ var expression = $2;
10876
+ return {
10877
+ type: "Argument",
10878
+ children: $0,
10879
+ expression,
10880
+ spread
10881
+ };
10882
+ });
10883
+ var PostfixedArgumentPart$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PostfixedExpression, (0, import_lib2.$E)(DotDotDot)), function($skip, $loc, $0, $1, $2) {
10884
+ var expression = $1;
10885
+ var spread = $2;
10886
+ return {
10887
+ type: "Argument",
10888
+ children: spread ? [spread, expression] : [expression],
10889
+ expression,
10890
+ spread
10891
+ };
10892
+ });
10893
+ var PostfixedArgumentPart$$ = [PostfixedArgumentPart$0, PostfixedArgumentPart$1];
10894
+ function PostfixedArgumentPart(ctx, state2) {
10895
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedArgumentPart", PostfixedArgumentPart$$);
10896
+ }
10704
10897
  var BinaryOpExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(UnaryExpression, (0, import_lib2.$Q)(BinaryOpRHS)), function($skip, $loc, $0, $1, $2) {
10705
10898
  if (!$2.length) return $1;
10706
10899
  return processBinaryOpExpression($0);
@@ -10733,10 +10926,13 @@ var BinaryOpRHS$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(BinaryOp, RHS), fun
10733
10926
  var BinaryOpRHS$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(NewlineBinaryOpAllowed, NotDedentedBinaryOp, WRHS), function($skip, $loc, $0, $1, $2, $3) {
10734
10927
  var op = $2;
10735
10928
  var rhs = $3;
10929
+ if (op[1].token === ">" && op[0].length === 0) return $skip;
10736
10930
  return [...op, ...rhs];
10737
10931
  });
10738
- var BinaryOpRHS$3 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function(value) {
10739
- return value[1];
10932
+ var BinaryOpRHS$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), SingleLineBinaryOpRHS), function($skip, $loc, $0, $1, $2) {
10933
+ const [ws1, op] = $2;
10934
+ if (op.token === ">" && !ws1.length) return $skip;
10935
+ return $2;
10740
10936
  });
10741
10937
  var BinaryOpRHS$$ = [BinaryOpRHS$0, BinaryOpRHS$1, BinaryOpRHS$2, BinaryOpRHS$3];
10742
10938
  function BinaryOpRHS(ctx, state2) {
@@ -10930,6 +11126,12 @@ var UpdateExpression$$ = [UpdateExpression$0, UpdateExpression$1];
10930
11126
  function UpdateExpression(ctx, state2) {
10931
11127
  return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpression", UpdateExpression$$);
10932
11128
  }
11129
+ var UpdateExpressionPattern$0 = NamedBindingPattern;
11130
+ var UpdateExpressionPattern$1 = UpdateExpression;
11131
+ var UpdateExpressionPattern$$ = [UpdateExpressionPattern$0, UpdateExpressionPattern$1];
11132
+ function UpdateExpressionPattern(ctx, state2) {
11133
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "UpdateExpressionPattern", UpdateExpressionPattern$$);
11134
+ }
10933
11135
  var UpdateExpressionSymbol$0 = (0, import_lib2.$TV)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L9, 'UpdateExpressionSymbol "++"'), (0, import_lib2.$EXPECT)($L10, 'UpdateExpressionSymbol "--"')), function($skip, $loc, $0, $1) {
10934
11136
  return { $loc, token: $1 };
10935
11137
  });
@@ -10993,7 +11195,7 @@ var NonPipelineAssignmentExpressionTail$$ = [NonPipelineAssignmentExpressionTail
10993
11195
  function NonPipelineAssignmentExpressionTail(ctx, state2) {
10994
11196
  return (0, import_lib2.$EVENT_C)(ctx, state2, "NonPipelineAssignmentExpressionTail", NonPipelineAssignmentExpressionTail$$);
10995
11197
  }
10996
- var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, UpdateExpression, WAssignmentOp)), MaybeNestedExpression), function($skip, $loc, $0, $1, $2) {
11198
+ var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, UpdateExpressionPattern, WAssignmentOp)), MaybeNestedExpression), function($skip, $loc, $0, $1, $2) {
10997
11199
  $1 = $1.map((x) => [x[0], x[1], ...x[2]]);
10998
11200
  $0 = [$1, $2];
10999
11201
  return {
@@ -11010,7 +11212,7 @@ var ActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib
11010
11212
  function ActualAssignment(ctx, state2) {
11011
11213
  return (0, import_lib2.$EVENT)(ctx, state2, "ActualAssignment", ActualAssignment$0);
11012
11214
  }
11013
- var NonPipelineActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, UpdateExpression, WAssignmentOp)), MaybeNestedNonPipelineExpression), function($skip, $loc, $0, $1, $2) {
11215
+ var NonPipelineActualAssignment$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, UpdateExpressionPattern, WAssignmentOp)), MaybeNestedNonPipelineExpression), function($skip, $loc, $0, $1, $2) {
11014
11216
  $1 = $1.map((x) => [x[0], x[1], ...x[2]]);
11015
11217
  $0 = [$1, $2];
11016
11218
  return {
@@ -11189,8 +11391,14 @@ var PipelineExpressionBody$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Pipeline
11189
11391
  ...rest.map(([nested, line]) => [nested, ...line]).flat()
11190
11392
  ];
11191
11393
  });
11192
- var PipelineExpressionBody$1 = (0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, Pipe, __, PipelineTailItem));
11193
- var PipelineExpressionBody$$ = [PipelineExpressionBody$0, PipelineExpressionBody$1];
11394
+ var PipelineExpressionBody$1 = (0, import_lib2.$T)((0, import_lib2.$S)(NewlineBinaryOpAllowed, (0, import_lib2.$P)((0, import_lib2.$S)(NotDedented, Pipe, __, PipelineTailItem))), function(value) {
11395
+ return value[1];
11396
+ });
11397
+ var PipelineExpressionBody$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NewlineBinaryOpAllowed), PipelineExpressionBodySameLine), function($skip, $loc, $0, $1, $2) {
11398
+ if (!$2.length) return $skip;
11399
+ return $2;
11400
+ });
11401
+ var PipelineExpressionBody$$ = [PipelineExpressionBody$0, PipelineExpressionBody$1, PipelineExpressionBody$2];
11194
11402
  function PipelineExpressionBody(ctx, state2) {
11195
11403
  return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineExpressionBody", PipelineExpressionBody$$);
11196
11404
  }
@@ -11221,8 +11429,9 @@ var PipelineTailItem$3 = (0, import_lib2.$TS)((0, import_lib2.$S)(NWTypePostfix,
11221
11429
  body: [" ", $1, ...$2]
11222
11430
  });
11223
11431
  });
11224
- var PipelineTailItem$4 = (0, import_lib2.$T)((0, import_lib2.$S)(PipelineHeadItem), function(value) {
11225
- return value[0];
11432
+ var PipelineTailItem$4 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidNewlineBinaryOp, (0, import_lib2.$E)(PipelineHeadItem), RestoreNewlineBinaryOp), function($skip, $loc, $0, $1, $2, $3) {
11433
+ if (!$2) return $skip;
11434
+ return $2;
11226
11435
  });
11227
11436
  var PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3, PipelineTailItem$4];
11228
11437
  function PipelineTailItem(ctx, state2) {
@@ -11678,7 +11887,7 @@ var FieldDefinition$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CoffeeClassesEn
11678
11887
  };
11679
11888
  }
11680
11889
  });
11681
- var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment, MaybeNestedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
11890
+ var FieldDefinition$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertReadonly, ClassElementName, (0, import_lib2.$E)(TypeSuffix), __, ConstAssignment, MaybeNestedPostfixedCommaExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
11682
11891
  var readonly = $1;
11683
11892
  var id = $2;
11684
11893
  var typeSuffix = $3;
@@ -11819,9 +12028,8 @@ var LeftHandSideExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impo
11819
12028
  expression
11820
12029
  };
11821
12030
  });
11822
- var LeftHandSideExpression$1 = NamedBindingPattern;
11823
- var LeftHandSideExpression$2 = CallExpression;
11824
- var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
12031
+ var LeftHandSideExpression$1 = CallExpression;
12032
+ var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1];
11825
12033
  function LeftHandSideExpression(ctx, state2) {
11826
12034
  return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
11827
12035
  }
@@ -13276,14 +13484,21 @@ var OperatorAssociativity$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
13276
13484
  function OperatorAssociativity(ctx, state2) {
13277
13485
  return (0, import_lib2.$EVENT)(ctx, state2, "OperatorAssociativity", OperatorAssociativity$0);
13278
13486
  }
13279
- var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Async, _)), ArrowParameters, (0, import_lib2.$E)(ReturnTypeSuffix), (0, import_lib2.$E)(_), Arrow, (0, import_lib2.$C)(BracedObjectSingleLineStatements, NoCommaBracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
13487
+ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(Async, _)), ArrowParameters, (0, import_lib2.$E)(ReturnTypeSuffix), (0, import_lib2.$E)(_), ThinArrow, (0, import_lib2.$C)(BracedObjectSingleLineStatements, NoCommaBracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
13280
13488
  var async = $1;
13281
13489
  var parameters = $2;
13282
13490
  var returnType = $3;
13491
+ var ws = $4;
13283
13492
  var arrow = $5;
13284
13493
  var block = $6;
13285
13494
  if (!async) async = [];
13286
13495
  const generator = [];
13496
+ if ((!parameters.implicit || returnType || ws) && !block.bare) {
13497
+ const [first, ...rest] = block.children;
13498
+ if (first === " {" || first?.[0]?.token === " ") {
13499
+ block = { ...block, children: [first.slice(1), ...rest] };
13500
+ }
13501
+ }
13287
13502
  return {
13288
13503
  type: "FunctionExpression",
13289
13504
  id: void 0,
@@ -13308,6 +13523,7 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
13308
13523
  generator,
13309
13524
  parameters,
13310
13525
  returnType,
13526
+ ws,
13311
13527
  block
13312
13528
  ]
13313
13529
  };
@@ -13315,11 +13531,11 @@ var ThinArrowFunction$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
13315
13531
  function ThinArrowFunction(ctx, state2) {
13316
13532
  return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrowFunction", ThinArrowFunction$0);
13317
13533
  }
13318
- var Arrow$0 = (0, import_lib2.$TV)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L35, 'Arrow "->"'), (0, import_lib2.$EXPECT)($L36, 'Arrow "\u2192"')), function($skip, $loc, $0, $1) {
13534
+ var ThinArrow$0 = (0, import_lib2.$TV)((0, import_lib2.$C)((0, import_lib2.$EXPECT)($L35, 'ThinArrow "->"'), (0, import_lib2.$EXPECT)($L36, 'ThinArrow "\u2192"')), function($skip, $loc, $0, $1) {
13319
13535
  return { $loc, token: "->" };
13320
13536
  });
13321
- function Arrow(ctx, state2) {
13322
- return (0, import_lib2.$EVENT)(ctx, state2, "Arrow", Arrow$0);
13537
+ function ThinArrow(ctx, state2) {
13538
+ return (0, import_lib2.$EVENT)(ctx, state2, "ThinArrow", ThinArrow$0);
13323
13539
  }
13324
13540
  var ExplicitBlock$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), OpenBrace, AllowAll, (0, import_lib2.$E)((0, import_lib2.$C)(NestedBlockStatements, SingleLineStatements, EmptyBracedContent)), RestoreAll, __, CloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
13325
13541
  var ws1 = $1;
@@ -15439,26 +15655,37 @@ var PostfixedNoCommaStatement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(NoCom
15439
15655
  function PostfixedNoCommaStatement(ctx, state2) {
15440
15656
  return (0, import_lib2.$EVENT)(ctx, state2, "PostfixedNoCommaStatement", PostfixedNoCommaStatement$0);
15441
15657
  }
15442
- var PostfixedExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement))), function($skip, $loc, $0, $1, $2) {
15658
+ var PostfixedExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(AssignmentExpressionSpread, (0, import_lib2.$E)(_), (0, import_lib2.$N)(IfClause), PostfixStatement), function($skip, $loc, $0, $1, $2, $3, $4) {
15659
+ var expression = $1;
15660
+ var ws = $2;
15661
+ var post = $4;
15662
+ return attachPostfixStatementAsExpression(expression, [ws, post]);
15663
+ });
15664
+ var PostfixedExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement)), function($skip, $loc, $0, $1, $2) {
15443
15665
  var expression = $1;
15444
15666
  var post = $2;
15445
- if (post) return attachPostfixStatementAsExpression(expression, post);
15446
- return expression;
15667
+ return attachPostfixStatementAsExpression(expression, post);
15447
15668
  });
15669
+ var PostfixedExpression$2 = Expression;
15670
+ var PostfixedExpression$$ = [PostfixedExpression$0, PostfixedExpression$1, PostfixedExpression$2];
15448
15671
  function PostfixedExpression(ctx, state2) {
15449
- return (0, import_lib2.$EVENT)(ctx, state2, "PostfixedExpression", PostfixedExpression$0);
15672
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedExpression", PostfixedExpression$$);
15450
15673
  }
15451
- var PostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(PostfixedExpression, (0, import_lib2.$C)((0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement), (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, AssignmentExpression)))), function($skip, $loc, $0, $1, $2) {
15674
+ var PostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(CommaExpressionSpread, (0, import_lib2.$E)(_), (0, import_lib2.$N)(IfClause), PostfixStatement), function($skip, $loc, $0, $1, $2, $3, $4) {
15675
+ var expression = $1;
15676
+ var ws = $2;
15677
+ var post = $4;
15678
+ return attachPostfixStatementAsExpression(expression, [ws, post]);
15679
+ });
15680
+ var PostfixedCommaExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, (0, import_lib2.$S)((0, import_lib2.$E)(_), PostfixStatement)), function($skip, $loc, $0, $1, $2) {
15452
15681
  var expression = $1;
15453
15682
  var post = $2;
15454
- if (!post.length) return $1;
15455
- if (post.length === 2 && !Array.isArray(post[1])) {
15456
- return attachPostfixStatementAsExpression(expression, post);
15457
- }
15458
- return $0;
15683
+ return attachPostfixStatementAsExpression(expression, post);
15459
15684
  });
15685
+ var PostfixedCommaExpression$2 = CommaExpression;
15686
+ var PostfixedCommaExpression$$ = [PostfixedCommaExpression$0, PostfixedCommaExpression$1, PostfixedCommaExpression$2];
15460
15687
  function PostfixedCommaExpression(ctx, state2) {
15461
- return (0, import_lib2.$EVENT)(ctx, state2, "PostfixedCommaExpression", PostfixedCommaExpression$0);
15688
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "PostfixedCommaExpression", PostfixedCommaExpression$$);
15462
15689
  }
15463
15690
  var PostfixStatement$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R31, "PostfixStatement /(?=for|if|loop|unless|until|while)/"), _PostfixStatement), function(value) {
15464
15691
  return value[1];
@@ -16910,6 +17137,22 @@ var MaybeNestedPostfixedExpression$$ = [MaybeNestedPostfixedExpression$0, MaybeN
16910
17137
  function MaybeNestedPostfixedExpression(ctx, state2) {
16911
17138
  return (0, import_lib2.$EVENT_C)(ctx, state2, "MaybeNestedPostfixedExpression", MaybeNestedPostfixedExpression$$);
16912
17139
  }
17140
+ var MaybeNestedPostfixedCommaExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(NestedBulletedArray), (0, import_lib2.$N)(NestedImplicitObjectLiteral), PushIndent, (0, import_lib2.$E)((0, import_lib2.$S)(Nested, PostfixedCommaExpression)), PopIndent, (0, import_lib2.$E)(AllowedTrailingCallExpressions)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17141
+ var expression = $4;
17142
+ var trailing = $6;
17143
+ if (!expression) return $skip;
17144
+ if (!trailing) return expression;
17145
+ return [expression, trailing];
17146
+ });
17147
+ var MaybeNestedPostfixedCommaExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidImplicitFragment, (0, import_lib2.$E)(PostfixedCommaExpression), RestoreImplicitFragment), function($skip, $loc, $0, $1, $2, $3) {
17148
+ var expression = $2;
17149
+ if (!expression) return $skip;
17150
+ return expression;
17151
+ });
17152
+ var MaybeNestedPostfixedCommaExpression$$ = [MaybeNestedPostfixedCommaExpression$0, MaybeNestedPostfixedCommaExpression$1];
17153
+ function MaybeNestedPostfixedCommaExpression(ctx, state2) {
17154
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "MaybeNestedPostfixedCommaExpression", MaybeNestedPostfixedCommaExpression$$);
17155
+ }
16913
17156
  var NestedPostfixedExpressionNoTrailing$0 = NestedBulletedArray;
16914
17157
  var NestedPostfixedExpressionNoTrailing$1 = NestedImplicitObjectLiteral;
16915
17158
  var NestedPostfixedExpressionNoTrailing$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(PushIndent, (0, import_lib2.$E)((0, import_lib2.$S)(Nested, PostfixedExpression)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
@@ -17360,7 +17603,7 @@ var ExportDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
17360
17603
  }
17361
17604
  ];
17362
17605
  });
17363
- var ExportDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), Export, __, Default, __, (0, import_lib2.$C)(HoistableDeclaration, ClassDeclaration, InterfaceDeclaration, MaybeNestedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17606
+ var ExportDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(Decorators), Export, __, Default, __, (0, import_lib2.$C)(HoistableDeclaration, ClassDeclaration, InterfaceDeclaration, MaybeNestedPostfixedExpression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17364
17607
  var declaration = $6;
17365
17608
  return { type: "ExportDeclaration", declaration, ts: declaration.ts, children: $0 };
17366
17609
  });
@@ -17483,7 +17726,7 @@ var LexicalDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(LetOrConst,
17483
17726
  thisAssignments: bindings.flatMap((b) => b.thisAssignments)
17484
17727
  };
17485
17728
  });
17486
- var LexicalDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Loc, (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(TypeSuffix), __, (0, import_lib2.$C)(ConstAssignment, LetAssignment), MaybeNestedPostfixedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17729
+ var LexicalDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Loc, (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(TypeSuffix), __, (0, import_lib2.$C)(ConstAssignment, LetAssignment), MaybeNestedPostfixedCommaExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
17487
17730
  var loc = $1;
17488
17731
  var assign = $5;
17489
17732
  return processAssignmentDeclaration(
@@ -17549,7 +17792,7 @@ var LexicalBinding$$ = [LexicalBinding$0, LexicalBinding$1];
17549
17792
  function LexicalBinding(ctx, state2) {
17550
17793
  return (0, import_lib2.$EVENT_C)(ctx, state2, "LexicalBinding", LexicalBinding$$);
17551
17794
  }
17552
- var Initializer$0 = (0, import_lib2.$T)((0, import_lib2.$S)(__, Equals, MaybeNestedExpression), function(value) {
17795
+ var Initializer$0 = (0, import_lib2.$T)((0, import_lib2.$S)(__, Equals, MaybeNestedPostfixedExpression), function(value) {
17553
17796
  var expression = value[2];
17554
17797
  return { "type": "Initializer", "expression": expression, "children": value };
17555
17798
  });
@@ -17977,8 +18220,10 @@ function CoffeeHereCommentStart(ctx, state2) {
17977
18220
  var InlineComment$0 = (0, import_lib2.$TR)((0, import_lib2.$EXPECT)($R74, "InlineComment /\\/\\*(?:(?!\\*\\/)[^\\r\\n])*\\*\\//"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
17978
18221
  return { $loc, token: $0 };
17979
18222
  });
18223
+ var InlineComment$1 = CoffeeMultiLineComment;
18224
+ var InlineComment$$ = [InlineComment$0, InlineComment$1];
17980
18225
  function InlineComment(ctx, state2) {
17981
- return (0, import_lib2.$EVENT)(ctx, state2, "InlineComment", InlineComment$0);
18226
+ return (0, import_lib2.$EVENT_C)(ctx, state2, "InlineComment", InlineComment$$);
17982
18227
  }
17983
18228
  var RestOfLine$0 = (0, import_lib2.$S)((0, import_lib2.$Q)((0, import_lib2.$C)(NonNewlineWhitespace, Comment)), EOL);
17984
18229
  function RestOfLine(ctx, state2) {
@@ -17988,7 +18233,7 @@ var TrailingComment$0 = (0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_l
17988
18233
  function TrailingComment(ctx, state2) {
17989
18234
  return (0, import_lib2.$EVENT)(ctx, state2, "TrailingComment", TrailingComment$0);
17990
18235
  }
17991
- var _$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R75, "_ /(?=[ \\t\\/\\\\])/"), (0, import_lib2.$P)((0, import_lib2.$C)(NonNewlineWhitespace, InlineComment))), function(value) {
18236
+ var _$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($R75, "_ /(?=[ \\t\\/\\\\#])/"), (0, import_lib2.$P)((0, import_lib2.$C)(NonNewlineWhitespace, InlineComment))), function(value) {
17992
18237
  return value[1];
17993
18238
  });
17994
18239
  function _(ctx, state2) {
@@ -22163,8 +22408,9 @@ ${counts}`;
22163
22408
  const code = generate_civet_default(ast2, options);
22164
22409
  checkErrors();
22165
22410
  if (options.inlineMap) {
22411
+ const outputFilename = options.outputFilename ?? (options.js ? filename2 + ".jsx" : filename2 + ".tsx");
22166
22412
  return `${code}
22167
- ${options.sourceMap.comment(filename2, filename2 + ".tsx")}`;
22413
+ ${options.sourceMap.comment(filename2, outputFilename)}`;
22168
22414
  } else {
22169
22415
  return {
22170
22416
  code,