typescript 4.8.0-dev.20220526 → 4.8.0-dev.20220527

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/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220526";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220527";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -12599,9 +12599,6 @@ var ts;
12599
12599
  }
12600
12600
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
12601
12601
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
12602
- if (node.kind === 203) {
12603
- node = node.parent.parent;
12604
- }
12605
12602
  return ts.isVariableDeclaration(node) &&
12606
12603
  !!node.initializer &&
12607
12604
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, true);
@@ -15861,13 +15858,13 @@ var ts;
15861
15858
  return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
15862
15859
  }
15863
15860
  function isFileForcedToBeModuleByFormat(file) {
15864
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
15861
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts"]))) && !file.isDeclarationFile ? true : undefined;
15865
15862
  }
15866
15863
  function getSetExternalModuleIndicator(options) {
15867
15864
  switch (getEmitModuleDetectionKind(options)) {
15868
15865
  case ts.ModuleDetectionKind.Force:
15869
15866
  return function (file) {
15870
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
15867
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
15871
15868
  };
15872
15869
  case ts.ModuleDetectionKind.Legacy:
15873
15870
  return function (file) {
@@ -15923,7 +15920,8 @@ var ts;
15923
15920
  }
15924
15921
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
15925
15922
  function getEmitModuleDetectionKind(options) {
15926
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
15923
+ return options.moduleDetection ||
15924
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
15927
15925
  }
15928
15926
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
15929
15927
  function hasJsonModuleEmitEnabled(options) {
@@ -38491,12 +38489,14 @@ var ts;
38491
38489
  }
38492
38490
  }
38493
38491
  function setCommonJsModuleIndicator(node) {
38494
- if (file.externalModuleIndicator) {
38492
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
38495
38493
  return false;
38496
38494
  }
38497
38495
  if (!file.commonJsModuleIndicator) {
38498
38496
  file.commonJsModuleIndicator = node;
38499
- bindSourceFileAsExternalModule();
38497
+ if (!file.externalModuleIndicator) {
38498
+ bindSourceFileAsExternalModule();
38499
+ }
38500
38500
  }
38501
38501
  return true;
38502
38502
  }
@@ -38849,7 +38849,11 @@ var ts;
38849
38849
  checkStrictModeEvalOrArguments(node, node.name);
38850
38850
  }
38851
38851
  if (!ts.isBindingPattern(node.name)) {
38852
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1)) {
38852
+ var possibleVariableDecl = node.kind === 254 ? node : node.parent.parent;
38853
+ if (ts.isInJSFile(node) &&
38854
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
38855
+ !ts.getJSDocTypeTag(node) &&
38856
+ !(ts.getCombinedModifierFlags(node) & 1)) {
38853
38857
  declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
38854
38858
  }
38855
38859
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -41162,7 +41166,8 @@ var ts;
41162
41166
  && isAliasableOrJsExpression(node.parent.right)
41163
41167
  || node.kind === 297
41164
41168
  || node.kind === 296 && isAliasableOrJsExpression(node.initializer)
41165
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
41169
+ || node.kind === 254 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
41170
+ || node.kind === 203 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
41166
41171
  }
41167
41172
  function isAliasableOrJsExpression(e) {
41168
41173
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -41243,7 +41248,7 @@ var ts;
41243
41248
  if (!ts.isSourceFileJS(file)) {
41244
41249
  return hasExportAssignmentSymbol(moduleSymbol);
41245
41250
  }
41246
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
41251
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
41247
41252
  }
41248
41253
  function getTargetOfImportClause(node, dontResolveAlias) {
41249
41254
  var _a;
@@ -69081,7 +69086,7 @@ var ts;
69081
69086
  return;
69082
69087
  }
69083
69088
  var symbol = getSymbolOfNode(node);
69084
- if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
69089
+ if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 ? node.parent.parent : node)) {
69085
69090
  checkAliasSymbol(node);
69086
69091
  return;
69087
69092
  }
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220526";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220527";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -16218,9 +16218,6 @@ var ts;
16218
16218
  }
16219
16219
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16220
16220
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16221
- if (node.kind === 203 /* BindingElement */) {
16222
- node = node.parent.parent;
16223
- }
16224
16221
  return ts.isVariableDeclaration(node) &&
16225
16222
  !!node.initializer &&
16226
16223
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20032,8 +20029,9 @@ var ts;
20032
20029
  */
20033
20030
  function isFileForcedToBeModuleByFormat(file) {
20034
20031
  // Excludes declaration files - they still require an explicit `export {}` or the like
20035
- // for back compat purposes.
20036
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20032
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20033
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20034
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20037
20035
  }
20038
20036
  function getSetExternalModuleIndicator(options) {
20039
20037
  // TODO: Should this callback be cached?
@@ -20041,7 +20039,7 @@ var ts;
20041
20039
  case ts.ModuleDetectionKind.Force:
20042
20040
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20043
20041
  return function (file) {
20044
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20042
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20045
20043
  };
20046
20044
  case ts.ModuleDetectionKind.Legacy:
20047
20045
  // Files are modules if they have imports, exports, or import.meta
@@ -20101,7 +20099,8 @@ var ts;
20101
20099
  }
20102
20100
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20103
20101
  function getEmitModuleDetectionKind(options) {
20104
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20102
+ return options.moduleDetection ||
20103
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20105
20104
  }
20106
20105
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20107
20106
  function hasJsonModuleEmitEnabled(options) {
@@ -46946,12 +46945,14 @@ var ts;
46946
46945
  }
46947
46946
  }
46948
46947
  function setCommonJsModuleIndicator(node) {
46949
- if (file.externalModuleIndicator) {
46948
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46950
46949
  return false;
46951
46950
  }
46952
46951
  if (!file.commonJsModuleIndicator) {
46953
46952
  file.commonJsModuleIndicator = node;
46954
- bindSourceFileAsExternalModule();
46953
+ if (!file.externalModuleIndicator) {
46954
+ bindSourceFileAsExternalModule();
46955
+ }
46955
46956
  }
46956
46957
  return true;
46957
46958
  }
@@ -47365,7 +47366,11 @@ var ts;
47365
47366
  checkStrictModeEvalOrArguments(node, node.name);
47366
47367
  }
47367
47368
  if (!ts.isBindingPattern(node.name)) {
47368
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47369
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47370
+ if (ts.isInJSFile(node) &&
47371
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47372
+ !ts.getJSDocTypeTag(node) &&
47373
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47369
47374
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47370
47375
  }
47371
47376
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50192,7 +50197,8 @@ var ts;
50192
50197
  && isAliasableOrJsExpression(node.parent.right)
50193
50198
  || node.kind === 297 /* ShorthandPropertyAssignment */
50194
50199
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50195
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50200
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50201
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50196
50202
  }
50197
50203
  function isAliasableOrJsExpression(e) {
50198
50204
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50285,7 +50291,7 @@ var ts;
50285
50291
  return hasExportAssignmentSymbol(moduleSymbol);
50286
50292
  }
50287
50293
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50288
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50294
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50289
50295
  }
50290
50296
  function getTargetOfImportClause(node, dontResolveAlias) {
50291
50297
  var _a;
@@ -82468,7 +82474,7 @@ var ts;
82468
82474
  }
82469
82475
  // For a commonjs `const x = require`, validate the alias and exit
82470
82476
  var symbol = getSymbolOfNode(node);
82471
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82477
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82472
82478
  checkAliasSymbol(node);
82473
82479
  return;
82474
82480
  }
@@ -136332,7 +136338,7 @@ var ts;
136332
136338
  ts.Debug.assert(parent.name === node);
136333
136339
  return true;
136334
136340
  case 203 /* BindingElement */:
136335
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136341
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136336
136342
  default:
136337
136343
  return false;
136338
136344
  }
@@ -137798,7 +137804,7 @@ var ts;
137798
137804
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
137799
137805
  if (ts.isInJSFile(referenceLocation)
137800
137806
  && referenceLocation.parent.kind === 203 /* BindingElement */
137801
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
137807
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
137802
137808
  referenceSymbol = referenceLocation.parent.symbol;
137803
137809
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
137804
137810
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -175081,8 +175087,7 @@ var ts;
175081
175087
  // it easier for the caller to skip post-processing.
175082
175088
  if (searchedProjects.size === 1) {
175083
175089
  var it = resultsMap.values().next();
175084
- ts.Debug.assert(!it.done);
175085
- return it.value;
175090
+ return it.done ? server.emptyArray : it.value; // There may not be any results at all
175086
175091
  }
175087
175092
  return resultsMap;
175088
175093
  // May enqueue to otherPositionQueue
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220526";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220527";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -16412,9 +16412,6 @@ var ts;
16412
16412
  }
16413
16413
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16414
16414
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16415
- if (node.kind === 203 /* BindingElement */) {
16416
- node = node.parent.parent;
16417
- }
16418
16415
  return ts.isVariableDeclaration(node) &&
16419
16416
  !!node.initializer &&
16420
16417
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20226,8 +20223,9 @@ var ts;
20226
20223
  */
20227
20224
  function isFileForcedToBeModuleByFormat(file) {
20228
20225
  // Excludes declaration files - they still require an explicit `export {}` or the like
20229
- // for back compat purposes.
20230
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20226
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20227
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20228
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20231
20229
  }
20232
20230
  function getSetExternalModuleIndicator(options) {
20233
20231
  // TODO: Should this callback be cached?
@@ -20235,7 +20233,7 @@ var ts;
20235
20233
  case ts.ModuleDetectionKind.Force:
20236
20234
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20237
20235
  return function (file) {
20238
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20236
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20239
20237
  };
20240
20238
  case ts.ModuleDetectionKind.Legacy:
20241
20239
  // Files are modules if they have imports, exports, or import.meta
@@ -20295,7 +20293,8 @@ var ts;
20295
20293
  }
20296
20294
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20297
20295
  function getEmitModuleDetectionKind(options) {
20298
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20296
+ return options.moduleDetection ||
20297
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20299
20298
  }
20300
20299
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20301
20300
  function hasJsonModuleEmitEnabled(options) {
@@ -47140,12 +47139,14 @@ var ts;
47140
47139
  }
47141
47140
  }
47142
47141
  function setCommonJsModuleIndicator(node) {
47143
- if (file.externalModuleIndicator) {
47142
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47144
47143
  return false;
47145
47144
  }
47146
47145
  if (!file.commonJsModuleIndicator) {
47147
47146
  file.commonJsModuleIndicator = node;
47148
- bindSourceFileAsExternalModule();
47147
+ if (!file.externalModuleIndicator) {
47148
+ bindSourceFileAsExternalModule();
47149
+ }
47149
47150
  }
47150
47151
  return true;
47151
47152
  }
@@ -47559,7 +47560,11 @@ var ts;
47559
47560
  checkStrictModeEvalOrArguments(node, node.name);
47560
47561
  }
47561
47562
  if (!ts.isBindingPattern(node.name)) {
47562
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47563
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47564
+ if (ts.isInJSFile(node) &&
47565
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47566
+ !ts.getJSDocTypeTag(node) &&
47567
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47563
47568
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47564
47569
  }
47565
47570
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50386,7 +50391,8 @@ var ts;
50386
50391
  && isAliasableOrJsExpression(node.parent.right)
50387
50392
  || node.kind === 297 /* ShorthandPropertyAssignment */
50388
50393
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50389
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50394
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50395
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50390
50396
  }
50391
50397
  function isAliasableOrJsExpression(e) {
50392
50398
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50479,7 +50485,7 @@ var ts;
50479
50485
  return hasExportAssignmentSymbol(moduleSymbol);
50480
50486
  }
50481
50487
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50482
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50488
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50483
50489
  }
50484
50490
  function getTargetOfImportClause(node, dontResolveAlias) {
50485
50491
  var _a;
@@ -82662,7 +82668,7 @@ var ts;
82662
82668
  }
82663
82669
  // For a commonjs `const x = require`, validate the alias and exit
82664
82670
  var symbol = getSymbolOfNode(node);
82665
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82671
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82666
82672
  checkAliasSymbol(node);
82667
82673
  return;
82668
82674
  }
@@ -136943,7 +136949,7 @@ var ts;
136943
136949
  ts.Debug.assert(parent.name === node);
136944
136950
  return true;
136945
136951
  case 203 /* BindingElement */:
136946
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136952
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136947
136953
  default:
136948
136954
  return false;
136949
136955
  }
@@ -138409,7 +138415,7 @@ var ts;
138409
138415
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138410
138416
  if (ts.isInJSFile(referenceLocation)
138411
138417
  && referenceLocation.parent.kind === 203 /* BindingElement */
138412
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138418
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138413
138419
  referenceSymbol = referenceLocation.parent.symbol;
138414
138420
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138415
138421
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -175275,8 +175281,7 @@ var ts;
175275
175281
  // it easier for the caller to skip post-processing.
175276
175282
  if (searchedProjects.size === 1) {
175277
175283
  var it = resultsMap.values().next();
175278
- ts.Debug.assert(!it.done);
175279
- return it.value;
175284
+ return it.done ? server.emptyArray : it.value; // There may not be any results at all
175280
175285
  }
175281
175286
  return resultsMap;
175282
175287
  // May enqueue to otherPositionQueue
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220526";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220527";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -16412,9 +16412,6 @@ var ts;
16412
16412
  }
16413
16413
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16414
16414
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16415
- if (node.kind === 203 /* BindingElement */) {
16416
- node = node.parent.parent;
16417
- }
16418
16415
  return ts.isVariableDeclaration(node) &&
16419
16416
  !!node.initializer &&
16420
16417
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20226,8 +20223,9 @@ var ts;
20226
20223
  */
20227
20224
  function isFileForcedToBeModuleByFormat(file) {
20228
20225
  // Excludes declaration files - they still require an explicit `export {}` or the like
20229
- // for back compat purposes.
20230
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20226
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20227
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20228
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20231
20229
  }
20232
20230
  function getSetExternalModuleIndicator(options) {
20233
20231
  // TODO: Should this callback be cached?
@@ -20235,7 +20233,7 @@ var ts;
20235
20233
  case ts.ModuleDetectionKind.Force:
20236
20234
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20237
20235
  return function (file) {
20238
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20236
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20239
20237
  };
20240
20238
  case ts.ModuleDetectionKind.Legacy:
20241
20239
  // Files are modules if they have imports, exports, or import.meta
@@ -20295,7 +20293,8 @@ var ts;
20295
20293
  }
20296
20294
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20297
20295
  function getEmitModuleDetectionKind(options) {
20298
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20296
+ return options.moduleDetection ||
20297
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20299
20298
  }
20300
20299
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20301
20300
  function hasJsonModuleEmitEnabled(options) {
@@ -47140,12 +47139,14 @@ var ts;
47140
47139
  }
47141
47140
  }
47142
47141
  function setCommonJsModuleIndicator(node) {
47143
- if (file.externalModuleIndicator) {
47142
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47144
47143
  return false;
47145
47144
  }
47146
47145
  if (!file.commonJsModuleIndicator) {
47147
47146
  file.commonJsModuleIndicator = node;
47148
- bindSourceFileAsExternalModule();
47147
+ if (!file.externalModuleIndicator) {
47148
+ bindSourceFileAsExternalModule();
47149
+ }
47149
47150
  }
47150
47151
  return true;
47151
47152
  }
@@ -47559,7 +47560,11 @@ var ts;
47559
47560
  checkStrictModeEvalOrArguments(node, node.name);
47560
47561
  }
47561
47562
  if (!ts.isBindingPattern(node.name)) {
47562
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47563
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47564
+ if (ts.isInJSFile(node) &&
47565
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47566
+ !ts.getJSDocTypeTag(node) &&
47567
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47563
47568
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47564
47569
  }
47565
47570
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50386,7 +50391,8 @@ var ts;
50386
50391
  && isAliasableOrJsExpression(node.parent.right)
50387
50392
  || node.kind === 297 /* ShorthandPropertyAssignment */
50388
50393
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50389
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50394
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50395
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50390
50396
  }
50391
50397
  function isAliasableOrJsExpression(e) {
50392
50398
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50479,7 +50485,7 @@ var ts;
50479
50485
  return hasExportAssignmentSymbol(moduleSymbol);
50480
50486
  }
50481
50487
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50482
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50488
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50483
50489
  }
50484
50490
  function getTargetOfImportClause(node, dontResolveAlias) {
50485
50491
  var _a;
@@ -82662,7 +82668,7 @@ var ts;
82662
82668
  }
82663
82669
  // For a commonjs `const x = require`, validate the alias and exit
82664
82670
  var symbol = getSymbolOfNode(node);
82665
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82671
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82666
82672
  checkAliasSymbol(node);
82667
82673
  return;
82668
82674
  }
@@ -136943,7 +136949,7 @@ var ts;
136943
136949
  ts.Debug.assert(parent.name === node);
136944
136950
  return true;
136945
136951
  case 203 /* BindingElement */:
136946
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136952
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136947
136953
  default:
136948
136954
  return false;
136949
136955
  }
@@ -138409,7 +138415,7 @@ var ts;
138409
138415
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138410
138416
  if (ts.isInJSFile(referenceLocation)
138411
138417
  && referenceLocation.parent.kind === 203 /* BindingElement */
138412
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138418
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138413
138419
  referenceSymbol = referenceLocation.parent.symbol;
138414
138420
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138415
138421
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220526";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220527";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -16412,9 +16412,6 @@ var ts;
16412
16412
  }
16413
16413
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16414
16414
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16415
- if (node.kind === 203 /* BindingElement */) {
16416
- node = node.parent.parent;
16417
- }
16418
16415
  return ts.isVariableDeclaration(node) &&
16419
16416
  !!node.initializer &&
16420
16417
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20226,8 +20223,9 @@ var ts;
20226
20223
  */
20227
20224
  function isFileForcedToBeModuleByFormat(file) {
20228
20225
  // Excludes declaration files - they still require an explicit `export {}` or the like
20229
- // for back compat purposes.
20230
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20226
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20227
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20228
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20231
20229
  }
20232
20230
  function getSetExternalModuleIndicator(options) {
20233
20231
  // TODO: Should this callback be cached?
@@ -20235,7 +20233,7 @@ var ts;
20235
20233
  case ts.ModuleDetectionKind.Force:
20236
20234
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20237
20235
  return function (file) {
20238
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20236
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20239
20237
  };
20240
20238
  case ts.ModuleDetectionKind.Legacy:
20241
20239
  // Files are modules if they have imports, exports, or import.meta
@@ -20295,7 +20293,8 @@ var ts;
20295
20293
  }
20296
20294
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20297
20295
  function getEmitModuleDetectionKind(options) {
20298
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20296
+ return options.moduleDetection ||
20297
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20299
20298
  }
20300
20299
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20301
20300
  function hasJsonModuleEmitEnabled(options) {
@@ -47140,12 +47139,14 @@ var ts;
47140
47139
  }
47141
47140
  }
47142
47141
  function setCommonJsModuleIndicator(node) {
47143
- if (file.externalModuleIndicator) {
47142
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47144
47143
  return false;
47145
47144
  }
47146
47145
  if (!file.commonJsModuleIndicator) {
47147
47146
  file.commonJsModuleIndicator = node;
47148
- bindSourceFileAsExternalModule();
47147
+ if (!file.externalModuleIndicator) {
47148
+ bindSourceFileAsExternalModule();
47149
+ }
47149
47150
  }
47150
47151
  return true;
47151
47152
  }
@@ -47559,7 +47560,11 @@ var ts;
47559
47560
  checkStrictModeEvalOrArguments(node, node.name);
47560
47561
  }
47561
47562
  if (!ts.isBindingPattern(node.name)) {
47562
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47563
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47564
+ if (ts.isInJSFile(node) &&
47565
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47566
+ !ts.getJSDocTypeTag(node) &&
47567
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47563
47568
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47564
47569
  }
47565
47570
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50386,7 +50391,8 @@ var ts;
50386
50391
  && isAliasableOrJsExpression(node.parent.right)
50387
50392
  || node.kind === 297 /* ShorthandPropertyAssignment */
50388
50393
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50389
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50394
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50395
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50390
50396
  }
50391
50397
  function isAliasableOrJsExpression(e) {
50392
50398
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50479,7 +50485,7 @@ var ts;
50479
50485
  return hasExportAssignmentSymbol(moduleSymbol);
50480
50486
  }
50481
50487
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50482
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50488
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50483
50489
  }
50484
50490
  function getTargetOfImportClause(node, dontResolveAlias) {
50485
50491
  var _a;
@@ -82662,7 +82668,7 @@ var ts;
82662
82668
  }
82663
82669
  // For a commonjs `const x = require`, validate the alias and exit
82664
82670
  var symbol = getSymbolOfNode(node);
82665
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82671
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82666
82672
  checkAliasSymbol(node);
82667
82673
  return;
82668
82674
  }
@@ -136943,7 +136949,7 @@ var ts;
136943
136949
  ts.Debug.assert(parent.name === node);
136944
136950
  return true;
136945
136951
  case 203 /* BindingElement */:
136946
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136952
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136947
136953
  default:
136948
136954
  return false;
136949
136955
  }
@@ -138409,7 +138415,7 @@ var ts;
138409
138415
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138410
138416
  if (ts.isInJSFile(referenceLocation)
138411
138417
  && referenceLocation.parent.kind === 203 /* BindingElement */
138412
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138418
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138413
138419
  referenceSymbol = referenceLocation.parent.symbol;
138414
138420
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138415
138421
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220526";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220527";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -16207,9 +16207,6 @@ var ts;
16207
16207
  }
16208
16208
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16209
16209
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16210
- if (node.kind === 203 /* BindingElement */) {
16211
- node = node.parent.parent;
16212
- }
16213
16210
  return ts.isVariableDeclaration(node) &&
16214
16211
  !!node.initializer &&
16215
16212
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20021,8 +20018,9 @@ var ts;
20021
20018
  */
20022
20019
  function isFileForcedToBeModuleByFormat(file) {
20023
20020
  // Excludes declaration files - they still require an explicit `export {}` or the like
20024
- // for back compat purposes.
20025
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20021
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20022
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20023
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
20026
20024
  }
20027
20025
  function getSetExternalModuleIndicator(options) {
20028
20026
  // TODO: Should this callback be cached?
@@ -20030,7 +20028,7 @@ var ts;
20030
20028
  case ts.ModuleDetectionKind.Force:
20031
20029
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20032
20030
  return function (file) {
20033
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20031
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20034
20032
  };
20035
20033
  case ts.ModuleDetectionKind.Legacy:
20036
20034
  // Files are modules if they have imports, exports, or import.meta
@@ -20090,7 +20088,8 @@ var ts;
20090
20088
  }
20091
20089
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20092
20090
  function getEmitModuleDetectionKind(options) {
20093
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20091
+ return options.moduleDetection ||
20092
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20094
20093
  }
20095
20094
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20096
20095
  function hasJsonModuleEmitEnabled(options) {
@@ -46935,12 +46934,14 @@ var ts;
46935
46934
  }
46936
46935
  }
46937
46936
  function setCommonJsModuleIndicator(node) {
46938
- if (file.externalModuleIndicator) {
46937
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46939
46938
  return false;
46940
46939
  }
46941
46940
  if (!file.commonJsModuleIndicator) {
46942
46941
  file.commonJsModuleIndicator = node;
46943
- bindSourceFileAsExternalModule();
46942
+ if (!file.externalModuleIndicator) {
46943
+ bindSourceFileAsExternalModule();
46944
+ }
46944
46945
  }
46945
46946
  return true;
46946
46947
  }
@@ -47354,7 +47355,11 @@ var ts;
47354
47355
  checkStrictModeEvalOrArguments(node, node.name);
47355
47356
  }
47356
47357
  if (!ts.isBindingPattern(node.name)) {
47357
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47358
+ var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent;
47359
+ if (ts.isInJSFile(node) &&
47360
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47361
+ !ts.getJSDocTypeTag(node) &&
47362
+ !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) {
47358
47363
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47359
47364
  }
47360
47365
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50181,7 +50186,8 @@ var ts;
50181
50186
  && isAliasableOrJsExpression(node.parent.right)
50182
50187
  || node.kind === 297 /* ShorthandPropertyAssignment */
50183
50188
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50184
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50189
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50190
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50185
50191
  }
50186
50192
  function isAliasableOrJsExpression(e) {
50187
50193
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50274,7 +50280,7 @@ var ts;
50274
50280
  return hasExportAssignmentSymbol(moduleSymbol);
50275
50281
  }
50276
50282
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50277
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50283
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50278
50284
  }
50279
50285
  function getTargetOfImportClause(node, dontResolveAlias) {
50280
50286
  var _a;
@@ -82457,7 +82463,7 @@ var ts;
82457
82463
  }
82458
82464
  // For a commonjs `const x = require`, validate the alias and exit
82459
82465
  var symbol = getSymbolOfNode(node);
82460
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82466
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82461
82467
  checkAliasSymbol(node);
82462
82468
  return;
82463
82469
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.8.0-dev.20220526",
5
+ "version": "4.8.0-dev.20220527",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [