typescript 4.8.0-dev.20220524 → 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/protocol.d.ts CHANGED
@@ -2699,6 +2699,7 @@ declare namespace ts.server.protocol {
2699
2699
  readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
2700
2700
  readonly includeInlayFunctionParameterTypeHints?: boolean;
2701
2701
  readonly includeInlayVariableTypeHints?: boolean;
2702
+ readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
2702
2703
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
2703
2704
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
2704
2705
  readonly includeInlayEnumMemberValueHints?: boolean;
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.20220524";
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) {
@@ -34266,7 +34264,7 @@ var ts;
34266
34264
  }
34267
34265
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
34268
34266
  return {
34269
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
34267
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
34270
34268
  flags: 1
34271
34269
  };
34272
34270
  }
@@ -35199,15 +35197,19 @@ var ts;
35199
35197
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
35200
35198
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
35201
35199
  }
35202
- function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
35203
- var containingDirectory = ts.getDirectoryPath(containingFile);
35204
- var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
35205
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
35206
- }
35207
35200
  var jsOnlyExtensions = [Extensions.JavaScript];
35208
35201
  var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
35209
35202
  var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
35210
35203
  var tsconfigExtensions = [Extensions.TSConfig];
35204
+ function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
35205
+ var containingDirectory = ts.getDirectoryPath(containingFile);
35206
+ var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
35207
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
35208
+ if (compilerOptions.resolveJsonModule) {
35209
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
35210
+ }
35211
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
35212
+ }
35211
35213
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
35212
35214
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
35213
35215
  }
@@ -38487,12 +38489,14 @@ var ts;
38487
38489
  }
38488
38490
  }
38489
38491
  function setCommonJsModuleIndicator(node) {
38490
- if (file.externalModuleIndicator) {
38492
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
38491
38493
  return false;
38492
38494
  }
38493
38495
  if (!file.commonJsModuleIndicator) {
38494
38496
  file.commonJsModuleIndicator = node;
38495
- bindSourceFileAsExternalModule();
38497
+ if (!file.externalModuleIndicator) {
38498
+ bindSourceFileAsExternalModule();
38499
+ }
38496
38500
  }
38497
38501
  return true;
38498
38502
  }
@@ -38845,7 +38849,11 @@ var ts;
38845
38849
  checkStrictModeEvalOrArguments(node, node.name);
38846
38850
  }
38847
38851
  if (!ts.isBindingPattern(node.name)) {
38848
- 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)) {
38849
38857
  declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
38850
38858
  }
38851
38859
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -41158,7 +41166,8 @@ var ts;
41158
41166
  && isAliasableOrJsExpression(node.parent.right)
41159
41167
  || node.kind === 297
41160
41168
  || node.kind === 296 && isAliasableOrJsExpression(node.initializer)
41161
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
41169
+ || node.kind === 254 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
41170
+ || node.kind === 203 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
41162
41171
  }
41163
41172
  function isAliasableOrJsExpression(e) {
41164
41173
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -41239,7 +41248,7 @@ var ts;
41239
41248
  if (!ts.isSourceFileJS(file)) {
41240
41249
  return hasExportAssignmentSymbol(moduleSymbol);
41241
41250
  }
41242
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
41251
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
41243
41252
  }
41244
41253
  function getTargetOfImportClause(node, dontResolveAlias) {
41245
41254
  var _a;
@@ -60320,7 +60329,7 @@ var ts;
60320
60329
  if (result) {
60321
60330
  return result;
60322
60331
  }
60323
- if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name)) {
60332
+ if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
60324
60333
  return getTypeFromBindingPattern(declaration.name, true, false);
60325
60334
  }
60326
60335
  }
@@ -60737,16 +60746,14 @@ var ts;
60737
60746
  function instantiateContextualType(contextualType, node, contextFlags) {
60738
60747
  if (contextualType && maybeTypeOfKind(contextualType, 465829888)) {
60739
60748
  var inferenceContext = getInferenceContext(node);
60740
- if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
60741
- if (contextFlags && contextFlags & 1) {
60742
- return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
60743
- }
60744
- if (inferenceContext.returnMapper) {
60745
- var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
60746
- return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
60747
- filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
60748
- type;
60749
- }
60749
+ if (inferenceContext && contextFlags & 1 && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
60750
+ return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
60751
+ }
60752
+ if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
60753
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
60754
+ return type.flags & 1048576 && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
60755
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
60756
+ type;
60750
60757
  }
60751
60758
  }
60752
60759
  return contextualType;
@@ -62900,18 +62907,22 @@ var ts;
62900
62907
  return inferJsxTypeArguments(node, signature, checkMode, context);
62901
62908
  }
62902
62909
  if (node.kind !== 165) {
62903
- var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 : 0);
62910
+ var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
62911
+ var contextualType = getContextualType(node, skipBindingPatterns ? 8 : 0);
62904
62912
  if (contextualType) {
62905
62913
  var inferenceTargetType = getReturnTypeOfSignature(signature);
62906
62914
  if (couldContainTypeVariables(inferenceTargetType)) {
62907
62915
  var outerContext = getInferenceContext(node);
62908
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
62909
- var instantiatedType = instantiateType(contextualType, outerMapper);
62910
- var contextualSignature = getSingleCallSignature(instantiatedType);
62911
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
62912
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
62913
- instantiatedType;
62914
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128);
62916
+ var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8) !== contextualType;
62917
+ if (!isFromBindingPattern) {
62918
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
62919
+ var instantiatedType = instantiateType(contextualType, outerMapper);
62920
+ var contextualSignature = getSingleCallSignature(instantiatedType);
62921
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
62922
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
62923
+ instantiatedType;
62924
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128);
62925
+ }
62915
62926
  var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
62916
62927
  var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
62917
62928
  inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
@@ -69075,7 +69086,7 @@ var ts;
69075
69086
  return;
69076
69087
  }
69077
69088
  var symbol = getSymbolOfNode(node);
69078
- if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
69089
+ if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 ? node.parent.parent : node)) {
69079
69090
  checkAliasSymbol(node);
69080
69091
  return;
69081
69092
  }
@@ -87835,7 +87846,7 @@ var ts;
87835
87846
  function visitor(node) {
87836
87847
  switch (node.kind) {
87837
87848
  case 265:
87838
- return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
87849
+ return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
87839
87850
  case 271:
87840
87851
  return visitExportAssignment(node);
87841
87852
  case 272:
@@ -102343,6 +102354,7 @@ var ts;
102343
102354
  }
102344
102355
  function reloadFileNamesFromConfigFile() {
102345
102356
  writeLog("Reloading new file names and options");
102357
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
102346
102358
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
102347
102359
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
102348
102360
  hasChangedConfigFileParsingErrors = true;
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.20220524";
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) {
@@ -42043,7 +42042,7 @@ var ts;
42043
42042
  }
42044
42043
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42045
42044
  return {
42046
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42045
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42047
42046
  flags: 1 /* Recursive */
42048
42047
  };
42049
42048
  }
@@ -43148,16 +43147,20 @@ var ts;
43148
43147
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43149
43148
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43150
43149
  }
43150
+ var jsOnlyExtensions = [Extensions.JavaScript];
43151
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43152
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43153
+ var tsconfigExtensions = [Extensions.TSConfig];
43151
43154
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43152
43155
  var containingDirectory = ts.getDirectoryPath(containingFile);
43153
43156
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43154
43157
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43155
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43158
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43159
+ if (compilerOptions.resolveJsonModule) {
43160
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43161
+ }
43162
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43156
43163
  }
43157
- var jsOnlyExtensions = [Extensions.JavaScript];
43158
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43159
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43160
- var tsconfigExtensions = [Extensions.TSConfig];
43161
43164
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43162
43165
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43163
43166
  }
@@ -46942,12 +46945,14 @@ var ts;
46942
46945
  }
46943
46946
  }
46944
46947
  function setCommonJsModuleIndicator(node) {
46945
- if (file.externalModuleIndicator) {
46948
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46946
46949
  return false;
46947
46950
  }
46948
46951
  if (!file.commonJsModuleIndicator) {
46949
46952
  file.commonJsModuleIndicator = node;
46950
- bindSourceFileAsExternalModule();
46953
+ if (!file.externalModuleIndicator) {
46954
+ bindSourceFileAsExternalModule();
46955
+ }
46951
46956
  }
46952
46957
  return true;
46953
46958
  }
@@ -47361,7 +47366,11 @@ var ts;
47361
47366
  checkStrictModeEvalOrArguments(node, node.name);
47362
47367
  }
47363
47368
  if (!ts.isBindingPattern(node.name)) {
47364
- 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 */)) {
47365
47374
  declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
47366
47375
  }
47367
47376
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50188,7 +50197,8 @@ var ts;
50188
50197
  && isAliasableOrJsExpression(node.parent.right)
50189
50198
  || node.kind === 297 /* ShorthandPropertyAssignment */
50190
50199
  || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50191
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50200
+ || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50201
+ || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50192
50202
  }
50193
50203
  function isAliasableOrJsExpression(e) {
50194
50204
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50281,7 +50291,7 @@ var ts;
50281
50291
  return hasExportAssignmentSymbol(moduleSymbol);
50282
50292
  }
50283
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
50284
- 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);
50285
50295
  }
50286
50296
  function getTargetOfImportClause(node, dontResolveAlias) {
50287
50297
  var _a;
@@ -72296,7 +72306,7 @@ var ts;
72296
72306
  if (result) {
72297
72307
  return result;
72298
72308
  }
72299
- if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
72309
+ if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) {
72300
72310
  return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
72301
72311
  }
72302
72312
  }
@@ -72765,22 +72775,20 @@ var ts;
72765
72775
  var inferenceContext = getInferenceContext(node);
72766
72776
  // If no inferences have been made, nothing is gained from instantiating as type parameters
72767
72777
  // would just be replaced with their defaults similar to the apparent type.
72768
- if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
72778
+ if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
72769
72779
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
72770
72780
  // types as well as arguments to the left in a function call.
72771
- if (contextFlags && contextFlags & 1 /* Signature */) {
72772
- return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
72773
- }
72781
+ return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
72782
+ }
72783
+ if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.returnMapper) {
72774
72784
  // For other purposes (e.g. determining whether to produce literal types) we only
72775
72785
  // incorporate inferences made from the return type in a function call. We remove
72776
72786
  // the 'boolean' type from the contextual type such that contextually typed boolean
72777
72787
  // literals actually end up widening to 'boolean' (see #48363).
72778
- if (inferenceContext.returnMapper) {
72779
- var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72780
- return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
72781
- filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
72782
- type;
72783
- }
72788
+ var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
72789
+ return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
72790
+ filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
72791
+ type;
72784
72792
  }
72785
72793
  }
72786
72794
  return contextualType;
@@ -75314,29 +75322,43 @@ var ts;
75314
75322
  // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
75315
75323
  // return type of 'wrap'.
75316
75324
  if (node.kind !== 165 /* Decorator */) {
75317
- var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75325
+ var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); });
75326
+ var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */);
75318
75327
  if (contextualType) {
75319
75328
  var inferenceTargetType = getReturnTypeOfSignature(signature);
75320
75329
  if (couldContainTypeVariables(inferenceTargetType)) {
75321
- // We clone the inference context to avoid disturbing a resolution in progress for an
75322
- // outer call expression. Effectively we just want a snapshot of whatever has been
75323
- // inferred for any outer call expression so far.
75324
75330
  var outerContext = getInferenceContext(node);
75325
- var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75326
- var instantiatedType = instantiateType(contextualType, outerMapper);
75327
- // If the contextual type is a generic function type with a single call signature, we
75328
- // instantiate the type with its own type parameters and type arguments. This ensures that
75329
- // the type parameters are not erased to type any during type inference such that they can
75330
- // be inferred as actual types from the contextual type. For example:
75331
- // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75332
- // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75333
- // Above, the type of the 'value' parameter is inferred to be 'A'.
75334
- var contextualSignature = getSingleCallSignature(instantiatedType);
75335
- var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75336
- getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75337
- instantiatedType;
75338
- // Inferences made from return types have lower priority than all other inferences.
75339
- inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75331
+ var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType;
75332
+ // A return type inference from a binding pattern can be used in instantiating the contextual
75333
+ // type of an argument later in inference, but cannot stand on its own as the final return type.
75334
+ // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`,
75335
+ // but doesn't need to go into `context.inferences`. This allows a an array binding pattern to
75336
+ // produce a tuple for `T` in
75337
+ // declare function f<T>(cb: () => T): T;
75338
+ // const [e1, e2, e3] = f(() => [1, "hi", true]);
75339
+ // but does not produce any inference for `T` in
75340
+ // declare function f<T>(): T;
75341
+ // const [e1, e2, e3] = f();
75342
+ if (!isFromBindingPattern) {
75343
+ // We clone the inference context to avoid disturbing a resolution in progress for an
75344
+ // outer call expression. Effectively we just want a snapshot of whatever has been
75345
+ // inferred for any outer call expression so far.
75346
+ var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
75347
+ var instantiatedType = instantiateType(contextualType, outerMapper);
75348
+ // If the contextual type is a generic function type with a single call signature, we
75349
+ // instantiate the type with its own type parameters and type arguments. This ensures that
75350
+ // the type parameters are not erased to type any during type inference such that they can
75351
+ // be inferred as actual types from the contextual type. For example:
75352
+ // declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
75353
+ // const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
75354
+ // Above, the type of the 'value' parameter is inferred to be 'A'.
75355
+ var contextualSignature = getSingleCallSignature(instantiatedType);
75356
+ var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
75357
+ getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
75358
+ instantiatedType;
75359
+ // Inferences made from return types have lower priority than all other inferences.
75360
+ inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
75361
+ }
75340
75362
  // Create a type mapper for instantiating generic contextual types using the inferences made
75341
75363
  // from the return type. We need a separate inference pass here because (a) instantiation of
75342
75364
  // the source type uses the outer context's return mapper (which excludes inferences made from
@@ -82452,7 +82474,7 @@ var ts;
82452
82474
  }
82453
82475
  // For a commonjs `const x = require`, validate the alias and exit
82454
82476
  var symbol = getSymbolOfNode(node);
82455
- if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82477
+ if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) {
82456
82478
  checkAliasSymbol(node);
82457
82479
  return;
82458
82480
  }
@@ -107261,7 +107283,7 @@ var ts;
107261
107283
  // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
107262
107284
  // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
107263
107285
  // is available, just because the output is reasonable for a node-like runtime.
107264
- return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
107286
+ return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined;
107265
107287
  case 271 /* ExportAssignment */:
107266
107288
  return visitExportAssignment(node);
107267
107289
  case 272 /* ExportDeclaration */:
@@ -123635,6 +123657,7 @@ var ts;
123635
123657
  }
123636
123658
  function reloadFileNamesFromConfigFile() {
123637
123659
  writeLog("Reloading new file names and options");
123660
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123638
123661
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123639
123662
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123640
123663
  hasChangedConfigFileParsingErrors = true;
@@ -134698,6 +134721,7 @@ var ts;
134698
134721
  return kind === 131 /* AsyncKeyword */
134699
134722
  || kind === 132 /* AwaitKeyword */
134700
134723
  || kind === 127 /* AsKeyword */
134724
+ || kind === 152 /* TypeKeyword */
134701
134725
  || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind);
134702
134726
  }
134703
134727
  function keywordForNode(node) {
@@ -136314,7 +136338,7 @@ var ts;
136314
136338
  ts.Debug.assert(parent.name === node);
136315
136339
  return true;
136316
136340
  case 203 /* BindingElement */:
136317
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136341
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136318
136342
  default:
136319
136343
  return false;
136320
136344
  }
@@ -137780,7 +137804,7 @@ var ts;
137780
137804
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
137781
137805
  if (ts.isInJSFile(referenceLocation)
137782
137806
  && referenceLocation.parent.kind === 203 /* BindingElement */
137783
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
137807
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
137784
137808
  referenceSymbol = referenceLocation.parent.symbol;
137785
137809
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
137786
137810
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -143952,6 +143976,10 @@ var ts;
143952
143976
  }
143953
143977
  var typeDisplayString = printTypeInSingleLine(declarationType);
143954
143978
  if (typeDisplayString) {
143979
+ var isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && ts.equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
143980
+ if (isVariableNameMatchesType) {
143981
+ return;
143982
+ }
143955
143983
  addTypeHints(typeDisplayString, decl.name.end);
143956
143984
  }
143957
143985
  }
@@ -175059,8 +175087,7 @@ var ts;
175059
175087
  // it easier for the caller to skip post-processing.
175060
175088
  if (searchedProjects.size === 1) {
175061
175089
  var it = resultsMap.values().next();
175062
- ts.Debug.assert(!it.done);
175063
- return it.value;
175090
+ return it.done ? server.emptyArray : it.value; // There may not be any results at all
175064
175091
  }
175065
175092
  return resultsMap;
175066
175093
  // May enqueue to otherPositionQueue
@@ -4120,6 +4120,7 @@ declare namespace ts {
4120
4120
  readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
4121
4121
  readonly includeInlayFunctionParameterTypeHints?: boolean;
4122
4122
  readonly includeInlayVariableTypeHints?: boolean;
4123
+ readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
4123
4124
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
4124
4125
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
4125
4126
  readonly includeInlayEnumMemberValueHints?: boolean;
@@ -9711,6 +9712,7 @@ declare namespace ts.server.protocol {
9711
9712
  readonly includeInlayParameterNameHintsWhenArgumentMatchesName?: boolean;
9712
9713
  readonly includeInlayFunctionParameterTypeHints?: boolean;
9713
9714
  readonly includeInlayVariableTypeHints?: boolean;
9715
+ readonly includeInlayVariableTypeHintsWhenTypeMatchesName?: boolean;
9714
9716
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
9715
9717
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
9716
9718
  readonly includeInlayEnumMemberValueHints?: boolean;