@typescript-deploys/pr-build 4.7.0-pr-48294-7 → 4.7.0-pr-36747-12

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/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-insiders.20220316";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220321";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -8250,6 +8250,7 @@ var ts;
8250
8250
  Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
8251
8251
  Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
8252
8252
  Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
8253
+ A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled: diag(1272, ts.DiagnosticCategory.Error, "A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_w_1272", "A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled."),
8253
8254
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
8254
8255
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
8255
8256
  Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
@@ -40895,7 +40896,10 @@ var ts;
40895
40896
  * file to. e.g. outDir
40896
40897
  */
40897
40898
  function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
40898
- return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
40899
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName });
40900
+ var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
40901
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
40902
+ return result;
40899
40903
  }
40900
40904
  ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
40901
40905
  /*@internal*/
@@ -47469,7 +47473,7 @@ var ts;
47469
47473
  (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */);
47470
47474
  }
47471
47475
  ts.isInstantiatedModule = isInstantiatedModule;
47472
- function createTypeChecker(host, produceDiagnostics) {
47476
+ function createTypeChecker(host) {
47473
47477
  var getPackagesMap = ts.memoize(function () {
47474
47478
  // A package name maps to true when we detect it has .d.ts files.
47475
47479
  // This is useful as an approximation of whether a package bundles its own types.
@@ -47486,6 +47490,10 @@ var ts;
47486
47490
  });
47487
47491
  return map;
47488
47492
  });
47493
+ var deferredDiagnosticsCallbacks = [];
47494
+ var addLazyDiagnostic = function (arg) {
47495
+ deferredDiagnosticsCallbacks.push(arg);
47496
+ };
47489
47497
  // Cancellation that controls whether or not we can cancel in the middle of type checking.
47490
47498
  // In general cancelling is *not* safe for the type checker. We might be in the middle of
47491
47499
  // computing something, and we will leave our internals in an inconsistent state. Callers
@@ -47848,8 +47856,8 @@ var ts;
47848
47856
  // Do this in a finally block so we can ensure that it gets reset back to nothing after
47849
47857
  // this call is done.
47850
47858
  cancellationToken = ct;
47851
- // Ensure file is type checked
47852
- checkSourceFile(file);
47859
+ // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused
47860
+ checkSourceFileWithEagerDiagnostics(file);
47853
47861
  ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
47854
47862
  diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
47855
47863
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
@@ -49184,110 +49192,114 @@ var ts;
49184
49192
  }
49185
49193
  }
49186
49194
  if (!result) {
49187
- if (nameNotFoundMessage && produceDiagnostics) {
49188
- if (!errorLocation ||
49189
- !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
49190
- !checkAndReportErrorForExtendingInterface(errorLocation) &&
49191
- !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
49192
- !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
49193
- !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
49194
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
49195
- !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
49196
- var suggestion = void 0;
49197
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
49198
- suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
49199
- var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
49200
- if (isGlobalScopeAugmentationDeclaration) {
49201
- suggestion = undefined;
49202
- }
49203
- if (suggestion) {
49204
- var suggestionName = symbolToString(suggestion);
49205
- var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
49206
- var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
49207
- : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
49208
- : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
49209
- var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
49210
- addErrorOrSuggestion(!isUncheckedJS, diagnostic);
49211
- if (suggestion.valueDeclaration) {
49212
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
49195
+ if (nameNotFoundMessage) {
49196
+ addLazyDiagnostic(function () {
49197
+ if (!errorLocation ||
49198
+ !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
49199
+ !checkAndReportErrorForExtendingInterface(errorLocation) &&
49200
+ !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
49201
+ !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
49202
+ !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
49203
+ !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
49204
+ !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
49205
+ var suggestion = void 0;
49206
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
49207
+ suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
49208
+ var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
49209
+ if (isGlobalScopeAugmentationDeclaration) {
49210
+ suggestion = undefined;
49213
49211
  }
49214
- }
49215
- }
49216
- if (!suggestion) {
49217
- if (nameArg) {
49218
- var lib = getSuggestedLibForNonExistentName(nameArg);
49219
- if (lib) {
49220
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
49212
+ if (suggestion) {
49213
+ var suggestionName = symbolToString(suggestion);
49214
+ var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
49215
+ var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
49216
+ : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
49217
+ : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
49218
+ var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
49219
+ addErrorOrSuggestion(!isUncheckedJS, diagnostic);
49220
+ if (suggestion.valueDeclaration) {
49221
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
49222
+ }
49221
49223
  }
49222
- else {
49223
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
49224
+ }
49225
+ if (!suggestion) {
49226
+ if (nameArg) {
49227
+ var lib = getSuggestedLibForNonExistentName(nameArg);
49228
+ if (lib) {
49229
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
49230
+ }
49231
+ else {
49232
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
49233
+ }
49224
49234
  }
49225
49235
  }
49236
+ suggestionCount++;
49226
49237
  }
49227
- suggestionCount++;
49228
- }
49238
+ });
49229
49239
  }
49230
49240
  return undefined;
49231
49241
  }
49242
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
49243
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
49244
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
49245
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
49246
+ var propertyName = propertyWithInvalidInitializer.name;
49247
+ error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
49248
+ return undefined;
49249
+ }
49232
49250
  // Perform extra checks only if error reporting was requested
49233
- if (nameNotFoundMessage && produceDiagnostics) {
49234
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
49235
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
49236
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
49237
- // with ESNext+useDefineForClassFields because the scope semantics are different.
49238
- var propertyName = propertyWithInvalidInitializer.name;
49239
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
49240
- return undefined;
49241
- }
49242
- // Only check for block-scoped variable if we have an error location and are looking for the
49243
- // name with variable meaning
49244
- // For example,
49245
- // declare module foo {
49246
- // interface bar {}
49247
- // }
49248
- // const foo/*1*/: foo/*2*/.bar;
49249
- // The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
49250
- // block-scoped variable and namespace module. However, only when we
49251
- // try to resolve name in /*1*/ which is used in variable position,
49252
- // we want to check for block-scoped
49253
- if (errorLocation &&
49254
- (meaning & 2 /* BlockScopedVariable */ ||
49255
- ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) {
49256
- var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
49257
- if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
49258
- checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
49259
- }
49260
- }
49261
- // If we're in an external module, we can't reference value symbols created from UMD export declarations
49262
- if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49263
- var merged = getMergedSymbol(result);
49264
- if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49265
- errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
49266
- }
49267
- }
49268
- // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right
49269
- if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) {
49270
- var candidate = getMergedSymbol(getLateBoundSymbol(result));
49271
- var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
49272
- // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
49273
- if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
49274
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
49275
- }
49276
- // And it cannot refer to any declarations which come after it
49277
- else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
49278
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
49279
- }
49280
- }
49281
- if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
49282
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
49283
- if (typeOnlyDeclaration) {
49284
- var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
49285
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
49286
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
49287
- var unescapedName = ts.unescapeLeadingUnderscores(name);
49288
- addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
49251
+ if (nameNotFoundMessage) {
49252
+ addLazyDiagnostic(function () {
49253
+ // Only check for block-scoped variable if we have an error location and are looking for the
49254
+ // name with variable meaning
49255
+ // For example,
49256
+ // declare module foo {
49257
+ // interface bar {}
49258
+ // }
49259
+ // const foo/*1*/: foo/*2*/.bar;
49260
+ // The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
49261
+ // block-scoped variable and namespace module. However, only when we
49262
+ // try to resolve name in /*1*/ which is used in variable position,
49263
+ // we want to check for block-scoped
49264
+ if (errorLocation &&
49265
+ (meaning & 2 /* BlockScopedVariable */ ||
49266
+ ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) {
49267
+ var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
49268
+ if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
49269
+ checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
49270
+ }
49271
+ }
49272
+ // If we're in an external module, we can't reference value symbols created from UMD export declarations
49273
+ if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49274
+ var merged = getMergedSymbol(result);
49275
+ if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49276
+ errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name));
49277
+ }
49278
+ }
49279
+ // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right
49280
+ if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) {
49281
+ var candidate = getMergedSymbol(getLateBoundSymbol(result));
49282
+ var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
49283
+ // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
49284
+ if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
49285
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
49286
+ }
49287
+ // And it cannot refer to any declarations which come after it
49288
+ else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
49289
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
49290
+ }
49291
+ }
49292
+ if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
49293
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
49294
+ if (typeOnlyDeclaration) {
49295
+ var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
49296
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
49297
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
49298
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
49299
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
49300
+ }
49289
49301
  }
49290
- }
49302
+ });
49291
49303
  }
49292
49304
  return result;
49293
49305
  }
@@ -50933,9 +50945,7 @@ var ts;
50933
50945
  var result = new Type(checker, flags);
50934
50946
  typeCount++;
50935
50947
  result.id = typeCount;
50936
- if (produceDiagnostics) { // Only record types from one checker
50937
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
50938
- }
50948
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
50939
50949
  return result;
50940
50950
  }
50941
50951
  function createOriginType(flags) {
@@ -54918,7 +54928,7 @@ var ts;
54918
54928
  if (!omitTypeAlias) {
54919
54929
  return errorType;
54920
54930
  }
54921
- return getGlobalTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
54931
+ return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
54922
54932
  }
54923
54933
  var members = ts.createSymbolTable();
54924
54934
  for (var _b = 0, spreadableProperties_1 = spreadableProperties; _b < spreadableProperties_1.length; _b++) {
@@ -56685,7 +56695,7 @@ var ts;
56685
56695
  }
56686
56696
  }
56687
56697
  if (memberTypeList.length) {
56688
- var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined);
56698
+ var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined);
56689
56699
  if (enumType_1.flags & 1048576 /* Union */) {
56690
56700
  enumType_1.flags |= 1024 /* EnumLiteral */;
56691
56701
  enumType_1.symbol = symbol;
@@ -59408,7 +59418,7 @@ var ts;
59408
59418
  type.resolvedTypeArguments = source.resolvedTypeArguments;
59409
59419
  return type;
59410
59420
  }
59411
- function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments, aliasMapper) {
59421
+ function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) {
59412
59422
  if (!aliasSymbol) {
59413
59423
  aliasSymbol = getAliasSymbolForTypeNode(node);
59414
59424
  var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
@@ -59420,7 +59430,6 @@ var ts;
59420
59430
  type.mapper = mapper;
59421
59431
  type.aliasSymbol = aliasSymbol;
59422
59432
  type.aliasTypeArguments = aliasTypeArguments;
59423
- type.aliasMapper = aliasMapper;
59424
59433
  return type;
59425
59434
  }
59426
59435
  function getTypeArguments(type) {
@@ -59485,7 +59494,7 @@ var ts;
59485
59494
  }
59486
59495
  return checkNoTypeArguments(node, symbol) ? type : errorType;
59487
59496
  }
59488
- function getGlobalTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
59497
+ function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
59489
59498
  var type = getDeclaredTypeOfSymbol(symbol);
59490
59499
  if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
59491
59500
  return getStringMappingType(symbol, typeArguments[0]);
@@ -59499,33 +59508,6 @@ var ts;
59499
59508
  }
59500
59509
  return instantiation;
59501
59510
  }
59502
- function getLocalTypeAliasInstantiation(symbol, typeArguments, outerTypeParameterMapper, aliasSymbol, aliasTypeArguments) {
59503
- var type = getDeclaredTypeOfSymbol(symbol);
59504
- if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
59505
- return getStringMappingType(symbol, typeArguments[0]);
59506
- }
59507
- var links = getSymbolLinks(symbol);
59508
- var outerTypeParameters = getOuterTypeParametersOfAlias(symbol);
59509
- var mappedOuterParams = outerTypeParameterMapper && outerTypeParameters && instantiateTypes(outerTypeParameters, outerTypeParameterMapper);
59510
- var typeParameters = links.typeParameters;
59511
- var id = getTypeListId(ts.concatenate(mappedOuterParams, typeArguments)) + getAliasId(aliasSymbol, aliasTypeArguments);
59512
- var instantiation = links.instantiations.get(id);
59513
- if (!instantiation) {
59514
- var outerTypeArgumentMapper = outerTypeParameters && mappedOuterParams && createTypeMapper(outerTypeParameters, mappedOuterParams);
59515
- var argumentMapper = createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)));
59516
- var combinedMapper = outerTypeArgumentMapper ? combineTypeMappers(argumentMapper, outerTypeArgumentMapper) : argumentMapper;
59517
- links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, combinedMapper, aliasSymbol, aliasTypeArguments));
59518
- }
59519
- return instantiation;
59520
- }
59521
- function getOuterTypeParametersOfAlias(symbol) {
59522
- var _a;
59523
- var links = getSymbolLinks(symbol);
59524
- if (!links.outerTypeParameters) {
59525
- links.outerTypeParameters = ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) && getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true);
59526
- }
59527
- return links.outerTypeParameters;
59528
- }
59529
59511
  /**
59530
59512
  * Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
59531
59513
  * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
@@ -59561,7 +59543,7 @@ var ts;
59561
59543
  // a .d.ts file. See #43622 for an example.
59562
59544
  var aliasSymbol = getAliasSymbolForTypeNode(node);
59563
59545
  var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined;
59564
- return getGlobalTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
59546
+ return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
59565
59547
  }
59566
59548
  return checkNoTypeArguments(node, symbol) ? type : errorType;
59567
59549
  }
@@ -60476,7 +60458,14 @@ var ts;
60476
60458
  result.types = types;
60477
60459
  return result;
60478
60460
  }
60479
- function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, aliasMapper, origin) {
60461
+ // We sort and deduplicate the constituent types based on object identity. If the subtypeReduction
60462
+ // flag is specified we also reduce the constituent type set to only include types that aren't subtypes
60463
+ // of other types. Subtype reduction is expensive for large union types and is possible only when union
60464
+ // types are known not to circularly reference themselves (as is the case with union types created by
60465
+ // expression constructs such as array literals and the || and ?: operators). Named types can
60466
+ // circularly reference themselves and therefore cannot be subtype reduced during their declaration.
60467
+ // For example, "type Item = string | (() => Item" is a named type that circularly references itself.
60468
+ function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
60480
60469
  if (unionReduction === void 0) { unionReduction = 1 /* Literal */; }
60481
60470
  if (types.length === 0) {
60482
60471
  return neverType;
@@ -60545,7 +60534,7 @@ var ts;
60545
60534
  }
60546
60535
  var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
60547
60536
  (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
60548
- return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, aliasMapper, origin);
60537
+ return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
60549
60538
  }
60550
60539
  function getUnionOrIntersectionTypePredicate(signatures, kind) {
60551
60540
  var first;
@@ -60583,7 +60572,7 @@ var ts;
60583
60572
  return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
60584
60573
  }
60585
60574
  // This function assumes the constituent type list is sorted and deduplicated.
60586
- function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, aliasMapper, origin) {
60575
+ function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) {
60587
60576
  if (types.length === 0) {
60588
60577
  return neverType;
60589
60578
  }
@@ -60603,7 +60592,6 @@ var ts;
60603
60592
  type.origin = origin;
60604
60593
  type.aliasSymbol = aliasSymbol;
60605
60594
  type.aliasTypeArguments = aliasTypeArguments;
60606
- type.aliasMapper = aliasMapper;
60607
60595
  if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
60608
60596
  type.flags |= 16 /* Boolean */;
60609
60597
  type.intrinsicName = "boolean";
@@ -60616,7 +60604,7 @@ var ts;
60616
60604
  var links = getNodeLinks(node);
60617
60605
  if (!links.resolvedType) {
60618
60606
  var aliasSymbol = getAliasSymbolForTypeNode(node);
60619
- links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), /*aliasMapper*/ undefined);
60607
+ links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
60620
60608
  }
60621
60609
  return links.resolvedType;
60622
60610
  }
@@ -60775,16 +60763,25 @@ var ts;
60775
60763
  types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
60776
60764
  return true;
60777
60765
  }
60778
- function createIntersectionType(types, aliasSymbol, aliasTypeArguments, aliasMapper) {
60766
+ function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
60779
60767
  var result = createType(2097152 /* Intersection */);
60780
60768
  result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
60781
60769
  result.types = types;
60782
60770
  result.aliasSymbol = aliasSymbol;
60783
60771
  result.aliasTypeArguments = aliasTypeArguments;
60784
- result.aliasMapper = aliasMapper;
60785
60772
  return result;
60786
60773
  }
60787
- function getIntersectionType(types, aliasSymbol, aliasTypeArguments, aliasMapper) {
60774
+ // We normalize combinations of intersection and union types based on the distributive property of the '&'
60775
+ // operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
60776
+ // types with union type constituents into equivalent union types with intersection type constituents and
60777
+ // effectively ensure that union types are always at the top level in type representations.
60778
+ //
60779
+ // We do not perform structural deduplication on intersection types. Intersection types are created only by the &
60780
+ // type operator and we can't reduce those because we want to support recursive intersection types. For example,
60781
+ // a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
60782
+ // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
60783
+ // for intersections of types with signatures can be deterministic.
60784
+ function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
60788
60785
  var typeMembershipMap = new ts.Map();
60789
60786
  var includes = addTypesToIntersection(typeMembershipMap, 0, types);
60790
60787
  var typeSet = ts.arrayFrom(typeMembershipMap.values());
@@ -60844,16 +60841,16 @@ var ts;
60844
60841
  // When the intersection creates a reduced set (which might mean that *all* union types have
60845
60842
  // disappeared), we restart the operation to get a new set of combined flags. Once we have
60846
60843
  // reduced we'll never reduce again, so this occurs at most once.
60847
- result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments, aliasMapper);
60844
+ result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
60848
60845
  }
60849
60846
  else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
60850
60847
  var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
60851
60848
  removeFromEach(typeSet, 32768 /* Undefined */);
60852
- result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
60849
+ result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60853
60850
  }
60854
60851
  else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
60855
60852
  removeFromEach(typeSet, 65536 /* Null */);
60856
- result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
60853
+ result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60857
60854
  }
60858
60855
  else {
60859
60856
  // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of
@@ -60866,7 +60863,7 @@ var ts;
60866
60863
  // We attach a denormalized origin type when at least one constituent of the cross-product union is an
60867
60864
  // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
60868
60865
  var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
60869
- result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper, origin);
60866
+ result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
60870
60867
  }
60871
60868
  }
60872
60869
  else {
@@ -60912,7 +60909,7 @@ var ts;
60912
60909
  var links = getNodeLinks(node);
60913
60910
  if (!links.resolvedType) {
60914
60911
  var aliasSymbol = getAliasSymbolForTypeNode(node);
60915
- links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), /*aliasMapper*/ undefined);
60912
+ links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
60916
60913
  }
60917
60914
  return links.resolvedType;
60918
60915
  }
@@ -61031,7 +61028,7 @@ var ts;
61031
61028
  var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ?
61032
61029
  info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; });
61033
61030
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
61034
- /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined, origin);
61031
+ /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
61035
61032
  }
61036
61033
  /**
61037
61034
  * A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
@@ -61064,7 +61061,7 @@ var ts;
61064
61061
  return type;
61065
61062
  }
61066
61063
  var extractTypeAlias = getGlobalExtractSymbol();
61067
- return extractTypeAlias ? getGlobalTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
61064
+ return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
61068
61065
  }
61069
61066
  function getIndexTypeOrString(type) {
61070
61067
  var indexType = getExtractStringType(getIndexType(type));
@@ -61194,14 +61191,13 @@ var ts;
61194
61191
  result.type = type;
61195
61192
  return result;
61196
61193
  }
61197
- function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments, aliasMapper) {
61194
+ function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) {
61198
61195
  var type = createType(8388608 /* IndexedAccess */);
61199
61196
  type.objectType = objectType;
61200
61197
  type.indexType = indexType;
61201
61198
  type.accessFlags = accessFlags;
61202
61199
  type.aliasSymbol = aliasSymbol;
61203
61200
  type.aliasTypeArguments = aliasTypeArguments;
61204
- type.aliasMapper = aliasMapper;
61205
61201
  return type;
61206
61202
  }
61207
61203
  /**
@@ -61559,9 +61555,9 @@ var ts;
61559
61555
  var templateMapper = combineTypeMappers(objectType.mapper, mapper);
61560
61556
  return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
61561
61557
  }
61562
- function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) {
61558
+ function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
61563
61559
  if (accessFlags === void 0) { accessFlags = 0 /* None */; }
61564
- return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) || (accessNode ? errorType : unknownType);
61560
+ return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
61565
61561
  }
61566
61562
  function indexTypeLessThan(indexType, limit) {
61567
61563
  return everyType(indexType, function (t) {
@@ -61575,7 +61571,7 @@ var ts;
61575
61571
  return false;
61576
61572
  });
61577
61573
  }
61578
- function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments, aliasMapper) {
61574
+ function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
61579
61575
  if (accessFlags === void 0) { accessFlags = 0 /* None */; }
61580
61576
  if (objectType === wildcardType || indexType === wildcardType) {
61581
61577
  return wildcardType;
@@ -61606,7 +61602,7 @@ var ts;
61606
61602
  var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
61607
61603
  var type = indexedAccessTypes.get(id);
61608
61604
  if (!type) {
61609
- indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments, aliasMapper));
61605
+ indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments));
61610
61606
  }
61611
61607
  return type;
61612
61608
  }
@@ -61636,8 +61632,8 @@ var ts;
61636
61632
  return undefined;
61637
61633
  }
61638
61634
  return accessFlags & 4 /* Writing */
61639
- ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments, aliasMapper)
61640
- : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper);
61635
+ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
61636
+ : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
61641
61637
  }
61642
61638
  return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */);
61643
61639
  }
@@ -61647,7 +61643,7 @@ var ts;
61647
61643
  var objectType = getTypeFromTypeNode(node.objectType);
61648
61644
  var indexType = getTypeFromTypeNode(node.indexType);
61649
61645
  var potentialAlias = getAliasSymbolForTypeNode(node);
61650
- var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias), /*aliasMapper*/ undefined);
61646
+ var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
61651
61647
  links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ &&
61652
61648
  resolved.objectType === objectType &&
61653
61649
  resolved.indexType === indexType ?
@@ -61814,7 +61810,6 @@ var ts;
61814
61810
  result.combinedMapper = combinedMapper;
61815
61811
  result.aliasSymbol = aliasSymbol || root.aliasSymbol;
61816
61812
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
61817
- result.aliasMapper = result.aliasSymbol ? mapper : undefined;
61818
61813
  return "break";
61819
61814
  };
61820
61815
  // We loop here for an immediately nested conditional type in the false position, effectively treating
@@ -62610,7 +62605,7 @@ var ts;
62610
62605
  var result = target.instantiations.get(id);
62611
62606
  if (!result) {
62612
62607
  var newMapper = createTypeMapper(typeParameters, typeArguments);
62613
- result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments, mapper) :
62608
+ result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
62614
62609
  target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
62615
62610
  instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
62616
62611
  target.instantiations.set(id, result);
@@ -62699,7 +62694,7 @@ var ts;
62699
62694
  return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
62700
62695
  }
62701
62696
  return t;
62702
- }, aliasSymbol, aliasTypeArguments, mapper);
62697
+ }, aliasSymbol, aliasTypeArguments);
62703
62698
  }
62704
62699
  }
62705
62700
  // If the constraint type of the instantiation is the wildcard type, return the wildcard type.
@@ -62768,7 +62763,6 @@ var ts;
62768
62763
  result.mapper = mapper;
62769
62764
  result.aliasSymbol = aliasSymbol || type.aliasSymbol;
62770
62765
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62771
- result.aliasMapper = mapper;
62772
62766
  return result;
62773
62767
  }
62774
62768
  function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
@@ -62788,7 +62782,7 @@ var ts;
62788
62782
  // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
62789
62783
  // result is (A extends U ? X : Y) | (B extends U ? X : Y).
62790
62784
  result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ?
62791
- mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments, mapper) :
62785
+ mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
62792
62786
  getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
62793
62787
  root.instantiations.set(id, result);
62794
62788
  }
@@ -62848,8 +62842,8 @@ var ts;
62848
62842
  var newAliasSymbol = aliasSymbol || type.aliasSymbol;
62849
62843
  var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62850
62844
  return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ?
62851
- getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments, mapper) :
62852
- getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments, mapper);
62845
+ getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
62846
+ getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments);
62853
62847
  }
62854
62848
  if (flags & 4194304 /* Index */) {
62855
62849
  return getIndexType(instantiateType(type.type, mapper));
@@ -62863,7 +62857,7 @@ var ts;
62863
62857
  if (flags & 8388608 /* IndexedAccess */) {
62864
62858
  var newAliasSymbol = aliasSymbol || type.aliasSymbol;
62865
62859
  var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
62866
- return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments, mapper);
62860
+ return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments);
62867
62861
  }
62868
62862
  if (flags & 16777216 /* Conditional */) {
62869
62863
  return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
@@ -64857,10 +64851,7 @@ var ts;
64857
64851
  if (variances === ts.emptyArray) {
64858
64852
  return 1 /* Unknown */;
64859
64853
  }
64860
- var outerTypeParameters = getOuterTypeParametersOfAlias(source.aliasSymbol);
64861
- var sourceArgs = outerTypeParameters && source.aliasMapper ? ts.concatenate(source.aliasTypeArguments, instantiateTypes(outerTypeParameters, source.aliasMapper)) : source.aliasTypeArguments;
64862
- var targetArgs = outerTypeParameters && target.aliasMapper ? ts.concatenate(target.aliasTypeArguments, instantiateTypes(outerTypeParameters, target.aliasMapper)) : target.aliasTypeArguments;
64863
- var varianceResult = relateVariances(sourceArgs, targetArgs, variances, intersectionState);
64854
+ var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
64864
64855
  if (varianceResult !== undefined) {
64865
64856
  return varianceResult;
64866
64857
  }
@@ -66149,11 +66140,8 @@ var ts;
66149
66140
  }
66150
66141
  function getAliasVariances(symbol) {
66151
66142
  var links = getSymbolLinks(symbol);
66152
- // outer type parameter aliases are last so they can be easily ignored by, eg, inference
66153
- var params = ts.concatenate(links.typeParameters, getOuterTypeParametersOfAlias(symbol));
66154
- return getVariancesWorker(params, links, function (_links, param, marker) {
66155
- var mapper = makeUnaryTypeMapper(param, marker);
66156
- var type = getLocalTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, mapper), mapper);
66143
+ return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
66144
+ var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
66157
66145
  type.aliasTypeArgumentsContainsMarker = true;
66158
66146
  return type;
66159
66147
  });
@@ -66810,7 +66798,7 @@ var ts;
66810
66798
  }
66811
66799
  // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
66812
66800
  return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
66813
- getGlobalTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
66801
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
66814
66802
  reducedType;
66815
66803
  }
66816
66804
  function getNonNullableType(type) {
@@ -67153,12 +67141,14 @@ var ts;
67153
67141
  errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
67154
67142
  }
67155
67143
  function reportErrorsFromWidening(declaration, type, wideningKind) {
67156
- if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
67157
- // Report implicit any error within type if possible, otherwise report error on declaration
67158
- if (!reportWideningErrorsInType(type)) {
67159
- reportImplicitAny(declaration, type, wideningKind);
67144
+ addLazyDiagnostic(function () {
67145
+ if (noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
67146
+ // Report implicit any error within type if possible, otherwise report error on declaration
67147
+ if (!reportWideningErrorsInType(type)) {
67148
+ reportImplicitAny(declaration, type, wideningKind);
67149
+ }
67160
67150
  }
67161
- }
67151
+ });
67162
67152
  }
67163
67153
  function applyToParameterTypes(source, target, callback) {
67164
67154
  var sourceCount = getParameterCount(source);
@@ -69036,7 +69026,7 @@ var ts;
69036
69026
  newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered);
69037
69027
  }
69038
69028
  }
69039
- return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, /*aliasMapper*/ undefined, newOrigin);
69029
+ return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin);
69040
69030
  }
69041
69031
  return type.flags & 131072 /* Never */ || f(type) ? type : neverType;
69042
69032
  }
@@ -69072,9 +69062,9 @@ var ts;
69072
69062
  }
69073
69063
  return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
69074
69064
  }
69075
- function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments, aliasMapper) {
69065
+ function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
69076
69066
  return type.flags & 1048576 /* Union */ && aliasSymbol ?
69077
- getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments, aliasMapper) :
69067
+ getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
69078
69068
  mapType(type, mapper);
69079
69069
  }
69080
69070
  function extractTypesOfKind(type, kind) {
@@ -72259,7 +72249,7 @@ var ts;
72259
72249
  var params = getSymbolLinks(managedSym).typeParameters;
72260
72250
  if (ts.length(params) >= 2) {
72261
72251
  var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
72262
- return getGlobalTypeAliasInstantiation(managedSym, args);
72252
+ return getTypeAliasInstantiation(managedSym, args);
72263
72253
  }
72264
72254
  }
72265
72255
  if (ts.length(declaredManagedType.typeParameters) >= 2) {
@@ -75150,7 +75140,7 @@ var ts;
75150
75140
  var isTaggedTemplate = node.kind === 209 /* TaggedTemplateExpression */;
75151
75141
  var isDecorator = node.kind === 164 /* Decorator */;
75152
75142
  var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
75153
- var reportErrors = !candidatesOutArray && produceDiagnostics;
75143
+ var reportErrors = !candidatesOutArray;
75154
75144
  var typeArguments;
75155
75145
  if (!isDecorator) {
75156
75146
  typeArguments = node.typeArguments;
@@ -76430,11 +76420,13 @@ var ts;
76430
76420
  checkSourceElement(type);
76431
76421
  exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
76432
76422
  var targetType = getTypeFromTypeNode(type);
76433
- if (produceDiagnostics && !isErrorType(targetType)) {
76434
- var widenedType = getWidenedType(exprType);
76435
- if (!isTypeComparableTo(targetType, widenedType)) {
76436
- checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
76437
- }
76423
+ if (!isErrorType(targetType)) {
76424
+ addLazyDiagnostic(function () {
76425
+ var widenedType = getWidenedType(exprType);
76426
+ if (!isTypeComparableTo(targetType, widenedType)) {
76427
+ checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
76428
+ }
76429
+ });
76438
76430
  }
76439
76431
  return targetType;
76440
76432
  }
@@ -77194,47 +77186,48 @@ var ts;
77194
77186
  * @param returnType - return type of the function, can be undefined if return type is not explicitly specified
77195
77187
  */
77196
77188
  function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
77197
- if (!produceDiagnostics) {
77198
- return;
77199
- }
77200
- var functionFlags = ts.getFunctionFlags(func);
77201
- var type = returnType && unwrapReturnType(returnType, functionFlags);
77202
- // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
77203
- if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
77204
- return;
77205
- }
77206
- // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
77207
- // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
77208
- if (func.kind === 167 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 234 /* Block */ || !functionHasImplicitReturn(func)) {
77209
- return;
77210
- }
77211
- var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
77212
- var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
77213
- if (type && type.flags & 131072 /* Never */) {
77214
- error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
77215
- }
77216
- else if (type && !hasExplicitReturn) {
77217
- // minimal check: function has syntactic return type annotation and no explicit return statements in the body
77218
- // this function does not conform to the specification.
77219
- error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
77220
- }
77221
- else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
77222
- error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
77223
- }
77224
- else if (compilerOptions.noImplicitReturns) {
77225
- if (!type) {
77226
- // If return type annotation is omitted check if function has any explicit return statements.
77227
- // If it does not have any - its inferred return type is void - don't do any checks.
77228
- // Otherwise get inferred return type from function body and report error only if it is not void / anytype
77229
- if (!hasExplicitReturn) {
77230
- return;
77231
- }
77232
- var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
77233
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
77234
- return;
77189
+ addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
77190
+ return;
77191
+ function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
77192
+ var functionFlags = ts.getFunctionFlags(func);
77193
+ var type = returnType && unwrapReturnType(returnType, functionFlags);
77194
+ // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
77195
+ if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
77196
+ return;
77197
+ }
77198
+ // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
77199
+ // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
77200
+ if (func.kind === 167 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 234 /* Block */ || !functionHasImplicitReturn(func)) {
77201
+ return;
77202
+ }
77203
+ var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
77204
+ var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
77205
+ if (type && type.flags & 131072 /* Never */) {
77206
+ error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
77207
+ }
77208
+ else if (type && !hasExplicitReturn) {
77209
+ // minimal check: function has syntactic return type annotation and no explicit return statements in the body
77210
+ // this function does not conform to the specification.
77211
+ error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
77212
+ }
77213
+ else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
77214
+ error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
77215
+ }
77216
+ else if (compilerOptions.noImplicitReturns) {
77217
+ if (!type) {
77218
+ // If return type annotation is omitted check if function has any explicit return statements.
77219
+ // If it does not have any - its inferred return type is void - don't do any checks.
77220
+ // Otherwise get inferred return type from function body and report error only if it is not void / anytype
77221
+ if (!hasExplicitReturn) {
77222
+ return;
77223
+ }
77224
+ var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
77225
+ if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
77226
+ return;
77227
+ }
77235
77228
  }
77229
+ error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
77236
77230
  }
77237
- error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
77238
77231
  }
77239
77232
  }
77240
77233
  function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
@@ -77494,49 +77487,50 @@ var ts;
77494
77487
  checkExpression(node.expression);
77495
77488
  return undefinedWideningType;
77496
77489
  }
77497
- function checkAwaitExpression(node) {
77490
+ function checkAwaitExpressionGrammar(node) {
77498
77491
  // Grammar checking
77499
- if (produceDiagnostics) {
77500
- var container = ts.getContainingFunctionOrClassStaticBlock(node);
77501
- if (container && ts.isClassStaticBlockDeclaration(container)) {
77502
- error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
77503
- }
77504
- else if (!(node.flags & 32768 /* AwaitContext */)) {
77505
- if (ts.isInTopLevelContext(node)) {
77506
- var sourceFile = ts.getSourceFileOfNode(node);
77507
- if (!hasParseDiagnostics(sourceFile)) {
77508
- var span = void 0;
77509
- if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
77510
- if (!span)
77511
- span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77512
- var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
77513
- diagnostics.add(diagnostic);
77514
- }
77515
- if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
77492
+ var container = ts.getContainingFunctionOrClassStaticBlock(node);
77493
+ if (container && ts.isClassStaticBlockDeclaration(container)) {
77494
+ error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
77495
+ }
77496
+ else if (!(node.flags & 32768 /* AwaitContext */)) {
77497
+ if (ts.isInTopLevelContext(node)) {
77498
+ var sourceFile = ts.getSourceFileOfNode(node);
77499
+ if (!hasParseDiagnostics(sourceFile)) {
77500
+ var span = void 0;
77501
+ if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
77502
+ if (!span)
77516
77503
  span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77517
- var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
77518
- diagnostics.add(diagnostic);
77519
- }
77504
+ var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
77505
+ diagnostics.add(diagnostic);
77520
77506
  }
77521
- }
77522
- else {
77523
- // use of 'await' in non-async function
77524
- var sourceFile = ts.getSourceFileOfNode(node);
77525
- if (!hasParseDiagnostics(sourceFile)) {
77526
- var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77527
- var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
77528
- if (container && container.kind !== 170 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
77529
- var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
77530
- ts.addRelatedInfo(diagnostic, relatedInfo);
77531
- }
77507
+ if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
77508
+ span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77509
+ var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
77532
77510
  diagnostics.add(diagnostic);
77533
77511
  }
77534
77512
  }
77535
77513
  }
77536
- if (isInParameterInitializerBeforeContainingFunction(node)) {
77537
- error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
77514
+ else {
77515
+ // use of 'await' in non-async function
77516
+ var sourceFile = ts.getSourceFileOfNode(node);
77517
+ if (!hasParseDiagnostics(sourceFile)) {
77518
+ var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77519
+ var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
77520
+ if (container && container.kind !== 170 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
77521
+ var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
77522
+ ts.addRelatedInfo(diagnostic, relatedInfo);
77523
+ }
77524
+ diagnostics.add(diagnostic);
77525
+ }
77538
77526
  }
77539
77527
  }
77528
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
77529
+ error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
77530
+ }
77531
+ }
77532
+ function checkAwaitExpression(node) {
77533
+ addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); });
77540
77534
  var operandType = checkExpression(node.expression);
77541
77535
  var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
77542
77536
  if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
@@ -78360,7 +78354,10 @@ var ts;
78360
78354
  }
78361
78355
  }
78362
78356
  function checkAssignmentOperator(valueType) {
78363
- if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
78357
+ if (ts.isAssignmentOperator(operator)) {
78358
+ addLazyDiagnostic(checkAssignmentOperatorWorker);
78359
+ }
78360
+ function checkAssignmentOperatorWorker() {
78364
78361
  // TypeScript 1.0 spec (April 2014): 4.17
78365
78362
  // An assignment of the form
78366
78363
  // VarExpr = ValueExpr
@@ -78459,15 +78456,7 @@ var ts;
78459
78456
  return [effectiveLeft, effectiveRight];
78460
78457
  }
78461
78458
  function checkYieldExpression(node) {
78462
- // Grammar checking
78463
- if (produceDiagnostics) {
78464
- if (!(node.flags & 8192 /* YieldContext */)) {
78465
- grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
78466
- }
78467
- if (isInParameterInitializerBeforeContainingFunction(node)) {
78468
- error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
78469
- }
78470
- }
78459
+ addLazyDiagnostic(checkYieldExpressionGrammar);
78471
78460
  var func = ts.getContainingFunction(node);
78472
78461
  if (!func)
78473
78462
  return anyType;
@@ -78513,14 +78502,24 @@ var ts;
78513
78502
  var type = getContextualIterationType(2 /* Next */, func);
78514
78503
  if (!type) {
78515
78504
  type = anyType;
78516
- if (produceDiagnostics && noImplicitAny && !ts.expressionResultIsUnused(node)) {
78517
- var contextualType = getContextualType(node);
78518
- if (!contextualType || isTypeAny(contextualType)) {
78519
- error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
78505
+ addLazyDiagnostic(function () {
78506
+ if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
78507
+ var contextualType = getContextualType(node);
78508
+ if (!contextualType || isTypeAny(contextualType)) {
78509
+ error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
78510
+ }
78520
78511
  }
78521
- }
78512
+ });
78522
78513
  }
78523
78514
  return type;
78515
+ function checkYieldExpressionGrammar() {
78516
+ if (!(node.flags & 8192 /* YieldContext */)) {
78517
+ grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
78518
+ }
78519
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
78520
+ error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
78521
+ }
78522
+ }
78524
78523
  }
78525
78524
  function checkConditionalExpression(node, checkMode) {
78526
78525
  checkTruthinessExpression(node.condition);
@@ -79103,9 +79102,7 @@ var ts;
79103
79102
  if (constraintType && defaultType) {
79104
79103
  checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
79105
79104
  }
79106
- if (produceDiagnostics) {
79107
- checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
79108
- }
79105
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79109
79106
  }
79110
79107
  function checkParameter(node) {
79111
79108
  // Grammar checking
@@ -79259,7 +79256,8 @@ var ts;
79259
79256
  if (node.type) {
79260
79257
  checkSourceElement(node.type);
79261
79258
  }
79262
- if (produceDiagnostics) {
79259
+ addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
79260
+ function checkSignatureDeclarationDiagnostics() {
79263
79261
  checkCollisionWithArgumentsInGeneratedCode(node);
79264
79262
  var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
79265
79263
  if (noImplicitAny && !returnTypeNode) {
@@ -79549,9 +79547,8 @@ var ts;
79549
79547
  if (ts.nodeIsMissing(node.body)) {
79550
79548
  return;
79551
79549
  }
79552
- if (!produceDiagnostics) {
79553
- return;
79554
- }
79550
+ addLazyDiagnostic(checkConstructorDeclarationDiagnostics);
79551
+ return;
79555
79552
  function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
79556
79553
  if (ts.isPrivateIdentifierClassElementDeclaration(n)) {
79557
79554
  return true;
@@ -79560,54 +79557,56 @@ var ts;
79560
79557
  !ts.isStatic(n) &&
79561
79558
  !!n.initializer;
79562
79559
  }
79563
- // TS 1.0 spec (April 2014): 8.3.2
79564
- // Constructors of classes with no extends clause may not contain super calls, whereas
79565
- // constructors of derived classes must contain at least one super call somewhere in their function body.
79566
- var containingClassDecl = node.parent;
79567
- if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
79568
- captureLexicalThis(node.parent, containingClassDecl);
79569
- var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
79570
- var superCall = findFirstSuperCall(node.body);
79571
- if (superCall) {
79572
- if (classExtendsNull) {
79573
- error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
79574
- }
79575
- // A super call must be root-level in a constructor if both of the following are true:
79576
- // - The containing class is a derived class.
79577
- // - The constructor declares parameter properties
79578
- // or the containing class declares instance member variables with initializers.
79579
- var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
79580
- (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
79581
- ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
79582
- if (superCallShouldBeRootLevel) {
79583
- // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
79584
- // See GH #8277
79585
- if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
79586
- error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
79587
- }
79588
- // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
79589
- else {
79590
- var superCallStatement = void 0;
79591
- for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
79592
- var statement = _a[_i];
79593
- if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
79594
- superCallStatement = statement;
79595
- break;
79596
- }
79597
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
79598
- break;
79599
- }
79600
- }
79560
+ function checkConstructorDeclarationDiagnostics() {
79561
+ // TS 1.0 spec (April 2014): 8.3.2
79562
+ // Constructors of classes with no extends clause may not contain super calls, whereas
79563
+ // constructors of derived classes must contain at least one super call somewhere in their function body.
79564
+ var containingClassDecl = node.parent;
79565
+ if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
79566
+ captureLexicalThis(node.parent, containingClassDecl);
79567
+ var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
79568
+ var superCall = findFirstSuperCall(node.body);
79569
+ if (superCall) {
79570
+ if (classExtendsNull) {
79571
+ error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
79572
+ }
79573
+ // A super call must be root-level in a constructor if both of the following are true:
79574
+ // - The containing class is a derived class.
79575
+ // - The constructor declares parameter properties
79576
+ // or the containing class declares instance member variables with initializers.
79577
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
79578
+ (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
79579
+ ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
79580
+ if (superCallShouldBeRootLevel) {
79601
79581
  // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
79602
79582
  // See GH #8277
79603
- if (superCallStatement === undefined) {
79604
- error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
79583
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
79584
+ error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
79585
+ }
79586
+ // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
79587
+ else {
79588
+ var superCallStatement = void 0;
79589
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
79590
+ var statement = _a[_i];
79591
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
79592
+ superCallStatement = statement;
79593
+ break;
79594
+ }
79595
+ if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
79596
+ break;
79597
+ }
79598
+ }
79599
+ // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
79600
+ // See GH #8277
79601
+ if (superCallStatement === undefined) {
79602
+ error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
79603
+ }
79605
79604
  }
79606
79605
  }
79607
79606
  }
79608
- }
79609
- else if (!classExtendsNull) {
79610
- error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
79607
+ else if (!classExtendsNull) {
79608
+ error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
79609
+ }
79611
79610
  }
79612
79611
  }
79613
79612
  }
@@ -79625,7 +79624,10 @@ var ts;
79625
79624
  return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
79626
79625
  }
79627
79626
  function checkAccessorDeclaration(node) {
79628
- if (produceDiagnostics) {
79627
+ addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
79628
+ checkSourceElement(node.body);
79629
+ setNodeLinksForPrivateIdentifierScope(node);
79630
+ function checkAccessorDeclarationDiagnostics() {
79629
79631
  // Grammar checking accessors
79630
79632
  if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
79631
79633
  checkGrammarComputedPropertyName(node.name);
@@ -79675,8 +79677,6 @@ var ts;
79675
79677
  checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
79676
79678
  }
79677
79679
  }
79678
- checkSourceElement(node.body);
79679
- setNodeLinksForPrivateIdentifierScope(node);
79680
79680
  }
79681
79681
  function checkMissingDeclaration(node) {
79682
79682
  checkDecorators(node);
@@ -79719,11 +79719,13 @@ var ts;
79719
79719
  ts.forEach(node.typeArguments, checkSourceElement);
79720
79720
  var type = getTypeFromTypeReference(node);
79721
79721
  if (!isErrorType(type)) {
79722
- if (node.typeArguments && produceDiagnostics) {
79723
- var typeParameters = getTypeParametersForTypeReference(node);
79724
- if (typeParameters) {
79725
- checkTypeArgumentConstraints(node, typeParameters);
79726
- }
79722
+ if (node.typeArguments) {
79723
+ addLazyDiagnostic(function () {
79724
+ var typeParameters = getTypeParametersForTypeReference(node);
79725
+ if (typeParameters) {
79726
+ checkTypeArgumentConstraints(node, typeParameters);
79727
+ }
79728
+ });
79727
79729
  }
79728
79730
  var symbol = getNodeLinks(node).resolvedSymbol;
79729
79731
  if (symbol) {
@@ -79751,7 +79753,8 @@ var ts;
79751
79753
  }
79752
79754
  function checkTypeLiteral(node) {
79753
79755
  ts.forEach(node.members, checkSourceElement);
79754
- if (produceDiagnostics) {
79756
+ addLazyDiagnostic(checkTypeLiteralDiagnostics);
79757
+ function checkTypeLiteralDiagnostics() {
79755
79758
  var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
79756
79759
  checkIndexConstraints(type, type.symbol);
79757
79760
  checkTypeForDuplicateIndexSignatures(node);
@@ -79942,9 +79945,9 @@ var ts;
79942
79945
  return flags & flagsToCheck;
79943
79946
  }
79944
79947
  function checkFunctionOrConstructorSymbol(symbol) {
79945
- if (!produceDiagnostics) {
79946
- return;
79947
- }
79948
+ addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
79949
+ }
79950
+ function checkFunctionOrConstructorSymbolWorker(symbol) {
79948
79951
  function getCanonicalOverload(overloads, implementation) {
79949
79952
  // Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
79950
79953
  // Error on all deviations from this canonical set of flags
@@ -80165,9 +80168,9 @@ var ts;
80165
80168
  }
80166
80169
  }
80167
80170
  function checkExportsOnMergedDeclarations(node) {
80168
- if (!produceDiagnostics) {
80169
- return;
80170
- }
80171
+ addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); });
80172
+ }
80173
+ function checkExportsOnMergedDeclarationsWorker(node) {
80171
80174
  // if localSymbol is defined on node then node itself is exported - check is required
80172
80175
  var symbol = node.localSymbol;
80173
80176
  if (!symbol) {
@@ -80403,7 +80406,7 @@ var ts;
80403
80406
  if (awaitedSymbol) {
80404
80407
  // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
80405
80408
  // an `Awaited<T | U>` would suffice.
80406
- return getGlobalTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
80409
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
80407
80410
  }
80408
80411
  }
80409
80412
  }
@@ -80654,20 +80657,31 @@ var ts;
80654
80657
  * marked as referenced to prevent import elision.
80655
80658
  */
80656
80659
  function markTypeNodeAsReferenced(node) {
80657
- markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
80660
+ markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
80658
80661
  }
80659
- function markEntityNameOrEntityExpressionAsReference(typeName) {
80662
+ function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
80660
80663
  if (!typeName)
80661
80664
  return;
80662
80665
  var rootName = ts.getFirstIdentifier(typeName);
80663
80666
  var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
80664
80667
  var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
80665
- if (rootSymbol
80666
- && rootSymbol.flags & 2097152 /* Alias */
80667
- && symbolIsValue(rootSymbol)
80668
- && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
80669
- && !getTypeOnlyAliasDeclaration(rootSymbol)) {
80670
- markAliasSymbolAsReferenced(rootSymbol);
80668
+ if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) {
80669
+ if (symbolIsValue(rootSymbol)
80670
+ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
80671
+ && !getTypeOnlyAliasDeclaration(rootSymbol)) {
80672
+ markAliasSymbolAsReferenced(rootSymbol);
80673
+ }
80674
+ else if (forDecoratorMetadata
80675
+ && compilerOptions.isolatedModules
80676
+ && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015
80677
+ && !symbolIsValue(rootSymbol)
80678
+ && !ts.some(rootSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration)) {
80679
+ var diag = error(typeName, ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled);
80680
+ var aliasDeclaration = ts.find(rootSymbol.declarations || ts.emptyArray, isAliasSymbolDeclaration);
80681
+ if (aliasDeclaration) {
80682
+ ts.addRelatedInfo(diag, ts.createDiagnosticForNode(aliasDeclaration, ts.Diagnostics._0_was_imported_here, ts.idText(rootName)));
80683
+ }
80684
+ }
80671
80685
  }
80672
80686
  }
80673
80687
  /**
@@ -80680,7 +80694,7 @@ var ts;
80680
80694
  function markDecoratorMedataDataTypeNodeAsReferenced(node) {
80681
80695
  var entityName = getEntityNameForDecoratorMetadata(node);
80682
80696
  if (entityName && ts.isEntityName(entityName)) {
80683
- markEntityNameOrEntityExpressionAsReference(entityName);
80697
+ markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
80684
80698
  }
80685
80699
  }
80686
80700
  function getEntityNameForDecoratorMetadata(node) {
@@ -80800,7 +80814,8 @@ var ts;
80800
80814
  ts.forEach(node.decorators, checkDecorator);
80801
80815
  }
80802
80816
  function checkFunctionDeclaration(node) {
80803
- if (produceDiagnostics) {
80817
+ addLazyDiagnostic(checkFunctionDeclarationDiagnostics);
80818
+ function checkFunctionDeclarationDiagnostics() {
80804
80819
  checkFunctionOrMethodDeclaration(node);
80805
80820
  checkGrammarForGenerator(node);
80806
80821
  checkCollisionsForDeclarationName(node, node.name);
@@ -80834,10 +80849,13 @@ var ts;
80834
80849
  checkSourceElement(node.typeExpression);
80835
80850
  }
80836
80851
  function checkJSDocFunctionType(node) {
80837
- if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
80838
- reportImplicitAny(node, anyType);
80839
- }
80852
+ addLazyDiagnostic(checkJSDocFunctionTypeImplicitAny);
80840
80853
  checkSignatureDeclaration(node);
80854
+ function checkJSDocFunctionTypeImplicitAny() {
80855
+ if (!node.type && !ts.isJSDocConstructSignature(node)) {
80856
+ reportImplicitAny(node, anyType);
80857
+ }
80858
+ }
80841
80859
  }
80842
80860
  function checkJSDocImplementsTag(node) {
80843
80861
  var classLike = ts.getEffectiveJSDocHost(node);
@@ -80918,19 +80936,7 @@ var ts;
80918
80936
  var body = node.kind === 167 /* MethodSignature */ ? undefined : node.body;
80919
80937
  checkSourceElement(body);
80920
80938
  checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
80921
- if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
80922
- // Report an implicit any error if there is no body, no explicit return type, and node is not a private method
80923
- // in an ambient context
80924
- if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
80925
- reportImplicitAny(node, anyType);
80926
- }
80927
- if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
80928
- // A generator with a body and no type annotation can still cause errors. It can error if the
80929
- // yielded values have no common supertype, or it can give an implicit any error if it has no
80930
- // yielded values. The only way to trigger these errors is to try checking its return type.
80931
- getReturnTypeOfSignature(getSignatureFromDeclaration(node));
80932
- }
80933
- }
80939
+ addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics);
80934
80940
  // A js function declaration can have a @type tag instead of a return type node, but that type must have a call signature
80935
80941
  if (ts.isInJSFile(node)) {
80936
80942
  var typeTag = ts.getJSDocTypeTag(node);
@@ -80938,10 +80944,26 @@ var ts;
80938
80944
  error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
80939
80945
  }
80940
80946
  }
80947
+ function checkFunctionOrMethodDeclarationDiagnostics() {
80948
+ if (!ts.getEffectiveReturnTypeNode(node)) {
80949
+ // Report an implicit any error if there is no body, no explicit return type, and node is not a private method
80950
+ // in an ambient context
80951
+ if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
80952
+ reportImplicitAny(node, anyType);
80953
+ }
80954
+ if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
80955
+ // A generator with a body and no type annotation can still cause errors. It can error if the
80956
+ // yielded values have no common supertype, or it can give an implicit any error if it has no
80957
+ // yielded values. The only way to trigger these errors is to try checking its return type.
80958
+ getReturnTypeOfSignature(getSignatureFromDeclaration(node));
80959
+ }
80960
+ }
80961
+ }
80941
80962
  }
80942
80963
  function registerForUnusedIdentifiersCheck(node) {
80943
- // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
80944
- if (produceDiagnostics) {
80964
+ addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
80965
+ function registerForUnusedIdentifiersCheckDiagnostics() {
80966
+ // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
80945
80967
  var sourceFile = ts.getSourceFileOfNode(node);
80946
80968
  var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
80947
80969
  if (!potentiallyUnusedIdentifiers) {
@@ -82715,26 +82737,31 @@ var ts;
82715
82737
  hasDuplicateDefaultClause = true;
82716
82738
  }
82717
82739
  }
82718
- if (produceDiagnostics && clause.kind === 288 /* CaseClause */) {
82719
- // TypeScript 1.0 spec (April 2014): 5.9
82720
- // In a 'switch' statement, each 'case' expression must be of a type that is comparable
82721
- // to or from the type of the 'switch' expression.
82722
- var caseType = checkExpression(clause.expression);
82723
- var caseIsLiteral = isLiteralType(caseType);
82724
- var comparedExpressionType = expressionType;
82725
- if (!caseIsLiteral || !expressionIsLiteral) {
82726
- caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
82727
- comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
82728
- }
82729
- if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
82730
- // expressionType is not comparable to caseType, try the reversed check and report errors if it fails
82731
- checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
82732
- }
82740
+ if (clause.kind === 288 /* CaseClause */) {
82741
+ addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause));
82733
82742
  }
82734
82743
  ts.forEach(clause.statements, checkSourceElement);
82735
82744
  if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
82736
82745
  error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
82737
82746
  }
82747
+ function createLazyCaseClauseDiagnostics(clause) {
82748
+ return function () {
82749
+ // TypeScript 1.0 spec (April 2014): 5.9
82750
+ // In a 'switch' statement, each 'case' expression must be of a type that is comparable
82751
+ // to or from the type of the 'switch' expression.
82752
+ var caseType = checkExpression(clause.expression);
82753
+ var caseIsLiteral = isLiteralType(caseType);
82754
+ var comparedExpressionType = expressionType;
82755
+ if (!caseIsLiteral || !expressionIsLiteral) {
82756
+ caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
82757
+ comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
82758
+ }
82759
+ if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
82760
+ // expressionType is not comparable to caseType, try the reversed check and report errors if it fails
82761
+ checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
82762
+ }
82763
+ };
82764
+ }
82738
82765
  });
82739
82766
  if (node.caseBlock.locals) {
82740
82767
  registerForUnusedIdentifiersCheck(node.caseBlock);
@@ -82955,26 +82982,29 @@ var ts;
82955
82982
  * Check each type parameter and check that type parameters have no duplicate type parameter declarations
82956
82983
  */
82957
82984
  function checkTypeParameters(typeParameterDeclarations) {
82985
+ var seenDefault = false;
82958
82986
  if (typeParameterDeclarations) {
82959
- var seenDefault = false;
82960
82987
  for (var i = 0; i < typeParameterDeclarations.length; i++) {
82961
82988
  var node = typeParameterDeclarations[i];
82962
82989
  checkTypeParameter(node);
82963
- if (produceDiagnostics) {
82964
- if (node.default) {
82965
- seenDefault = true;
82966
- checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
82967
- }
82968
- else if (seenDefault) {
82969
- error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
82970
- }
82971
- for (var j = 0; j < i; j++) {
82972
- if (typeParameterDeclarations[j].symbol === node.symbol) {
82973
- error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
82974
- }
82990
+ addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
82991
+ }
82992
+ }
82993
+ function createCheckTypeParameterDiagnostic(node, i) {
82994
+ return function () {
82995
+ if (node.default) {
82996
+ seenDefault = true;
82997
+ checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
82998
+ }
82999
+ else if (seenDefault) {
83000
+ error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
83001
+ }
83002
+ for (var j = 0; j < i; j++) {
83003
+ if (typeParameterDeclarations[j].symbol === node.symbol) {
83004
+ error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
82975
83005
  }
82976
83006
  }
82977
- }
83007
+ };
82978
83008
  }
82979
83009
  }
82980
83010
  /** Check that type parameter defaults only reference previously declared type parameters */
@@ -83106,85 +83136,90 @@ var ts;
83106
83136
  if (extendsNode && extendsNode !== baseTypeNode) {
83107
83137
  checkExpression(extendsNode.expression);
83108
83138
  }
83109
- var baseTypes = getBaseTypes(type);
83110
- if (baseTypes.length && produceDiagnostics) {
83111
- var baseType_1 = baseTypes[0];
83112
- var baseConstructorType = getBaseConstructorTypeOfClass(type);
83113
- var staticBaseType = getApparentType(baseConstructorType);
83114
- checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
83115
- checkSourceElement(baseTypeNode.expression);
83116
- if (ts.some(baseTypeNode.typeArguments)) {
83117
- ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
83118
- for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
83119
- var constructor = _a[_i];
83120
- if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
83121
- break;
83139
+ var baseTypes_2 = getBaseTypes(type);
83140
+ if (baseTypes_2.length) {
83141
+ addLazyDiagnostic(function () {
83142
+ var baseType = baseTypes_2[0];
83143
+ var baseConstructorType = getBaseConstructorTypeOfClass(type);
83144
+ var staticBaseType = getApparentType(baseConstructorType);
83145
+ checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
83146
+ checkSourceElement(baseTypeNode.expression);
83147
+ if (ts.some(baseTypeNode.typeArguments)) {
83148
+ ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
83149
+ for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
83150
+ var constructor = _a[_i];
83151
+ if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
83152
+ break;
83153
+ }
83122
83154
  }
83123
83155
  }
83124
- }
83125
- var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
83126
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83127
- issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
83128
- }
83129
- else {
83130
- // Report static side error only when instance type is assignable
83131
- checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
83132
- }
83133
- if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
83134
- if (!isMixinConstructorType(staticType)) {
83135
- error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
83156
+ var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
83157
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83158
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
83136
83159
  }
83137
83160
  else {
83138
- var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
83139
- if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
83140
- error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract);
83161
+ // Report static side error only when instance type is assignable
83162
+ checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
83163
+ }
83164
+ if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
83165
+ if (!isMixinConstructorType(staticType)) {
83166
+ error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
83167
+ }
83168
+ else {
83169
+ var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
83170
+ if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
83171
+ error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract);
83172
+ }
83141
83173
  }
83142
83174
  }
83143
- }
83144
- if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
83145
- // When the static base type is a "class-like" constructor function (but not actually a class), we verify
83146
- // that all instantiated base constructor signatures return the same type.
83147
- var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
83148
- if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
83149
- error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
83175
+ if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
83176
+ // When the static base type is a "class-like" constructor function (but not actually a class), we verify
83177
+ // that all instantiated base constructor signatures return the same type.
83178
+ var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
83179
+ if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType); })) {
83180
+ error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
83181
+ }
83150
83182
  }
83151
- }
83152
- checkKindsOfPropertyMemberOverrides(type, baseType_1);
83183
+ checkKindsOfPropertyMemberOverrides(type, baseType);
83184
+ });
83153
83185
  }
83154
83186
  }
83155
83187
  checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
83156
83188
  var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
83157
83189
  if (implementedTypeNodes) {
83158
- for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
83159
- var typeRefNode = implementedTypeNodes_1[_b];
83190
+ for (var _i = 0, implementedTypeNodes_1 = implementedTypeNodes; _i < implementedTypeNodes_1.length; _i++) {
83191
+ var typeRefNode = implementedTypeNodes_1[_i];
83160
83192
  if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
83161
83193
  error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
83162
83194
  }
83163
83195
  checkTypeReferenceNode(typeRefNode);
83164
- if (produceDiagnostics) {
83165
- var t = getReducedType(getTypeFromTypeNode(typeRefNode));
83166
- if (!isErrorType(t)) {
83167
- if (isValidBaseType(t)) {
83168
- var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
83169
- ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
83170
- ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
83171
- var baseWithThis = getTypeWithThisArgument(t, type.thisType);
83172
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83173
- issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
83174
- }
83175
- }
83176
- else {
83177
- error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
83178
- }
83179
- }
83180
- }
83196
+ addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
83181
83197
  }
83182
83198
  }
83183
- if (produceDiagnostics) {
83199
+ addLazyDiagnostic(function () {
83184
83200
  checkIndexConstraints(type, symbol);
83185
83201
  checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
83186
83202
  checkTypeForDuplicateIndexSignatures(node);
83187
83203
  checkPropertyInitialization(node);
83204
+ });
83205
+ function createImplementsDiagnostics(typeRefNode) {
83206
+ return function () {
83207
+ var t = getReducedType(getTypeFromTypeNode(typeRefNode));
83208
+ if (!isErrorType(t)) {
83209
+ if (isValidBaseType(t)) {
83210
+ var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
83211
+ ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
83212
+ ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
83213
+ var baseWithThis = getTypeWithThisArgument(t, type.thisType);
83214
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83215
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
83216
+ }
83217
+ }
83218
+ else {
83219
+ error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
83220
+ }
83221
+ }
83222
+ };
83188
83223
  }
83189
83224
  }
83190
83225
  function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
@@ -83508,8 +83543,8 @@ var ts;
83508
83543
  ts.forEach(properties, function (p) {
83509
83544
  seen.set(p.escapedName, p);
83510
83545
  });
83511
- for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
83512
- var base = baseTypes_2[_i];
83546
+ for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
83547
+ var base = baseTypes_3[_i];
83513
83548
  var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
83514
83549
  for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
83515
83550
  var prop = properties_4[_a];
@@ -83531,8 +83566,8 @@ var ts;
83531
83566
  seen.set(p.escapedName, { prop: p, containingType: type });
83532
83567
  });
83533
83568
  var ok = true;
83534
- for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
83535
- var base = baseTypes_3[_i];
83569
+ for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
83570
+ var base = baseTypes_4[_i];
83536
83571
  var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
83537
83572
  for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
83538
83573
  var prop = properties_6[_a];
@@ -83616,7 +83651,7 @@ var ts;
83616
83651
  if (!checkGrammarDecoratorsAndModifiers(node))
83617
83652
  checkGrammarInterfaceDeclaration(node);
83618
83653
  checkTypeParameters(node.typeParameters);
83619
- if (produceDiagnostics) {
83654
+ addLazyDiagnostic(function () {
83620
83655
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
83621
83656
  checkExportsOnMergedDeclarations(node);
83622
83657
  var symbol = getSymbolOfNode(node);
@@ -83636,7 +83671,7 @@ var ts;
83636
83671
  }
83637
83672
  }
83638
83673
  checkObjectTypeForDuplicateDeclarations(node);
83639
- }
83674
+ });
83640
83675
  ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
83641
83676
  if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
83642
83677
  error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
@@ -83644,10 +83679,10 @@ var ts;
83644
83679
  checkTypeReferenceNode(heritageElement);
83645
83680
  });
83646
83681
  ts.forEach(node.members, checkSourceElement);
83647
- if (produceDiagnostics) {
83682
+ addLazyDiagnostic(function () {
83648
83683
  checkTypeForDuplicateIndexSignatures(node);
83649
83684
  registerForUnusedIdentifiersCheck(node);
83650
- }
83685
+ });
83651
83686
  }
83652
83687
  function checkTypeAliasDeclaration(node) {
83653
83688
  // Grammar checking
@@ -83836,9 +83871,9 @@ var ts;
83836
83871
  ts.isStringLiteralLike(node.argumentExpression);
83837
83872
  }
83838
83873
  function checkEnumDeclaration(node) {
83839
- if (!produceDiagnostics) {
83840
- return;
83841
- }
83874
+ addLazyDiagnostic(function () { return checkEnumDeclarationWorker(node); });
83875
+ }
83876
+ function checkEnumDeclarationWorker(node) {
83842
83877
  // Grammar checking
83843
83878
  checkGrammarDecoratorsAndModifiers(node);
83844
83879
  checkCollisionsForDeclarationName(node, node.name);
@@ -83918,7 +83953,14 @@ var ts;
83918
83953
  }
83919
83954
  }
83920
83955
  function checkModuleDeclaration(node) {
83921
- if (produceDiagnostics) {
83956
+ if (node.body) {
83957
+ checkSourceElement(node.body);
83958
+ if (!ts.isGlobalScopeAugmentation(node)) {
83959
+ registerForUnusedIdentifiersCheck(node);
83960
+ }
83961
+ }
83962
+ addLazyDiagnostic(checkModuleDeclarationDiagnostics);
83963
+ function checkModuleDeclarationDiagnostics() {
83922
83964
  // Grammar checking
83923
83965
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
83924
83966
  var inAmbientContext = node.flags & 8388608 /* Ambient */;
@@ -84001,12 +84043,6 @@ var ts;
84001
84043
  }
84002
84044
  }
84003
84045
  }
84004
- if (node.body) {
84005
- checkSourceElement(node.body);
84006
- if (!ts.isGlobalScopeAugmentation(node)) {
84007
- registerForUnusedIdentifiersCheck(node);
84008
- }
84009
- }
84010
84046
  }
84011
84047
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
84012
84048
  var _a;
@@ -84332,7 +84368,7 @@ var ts;
84332
84368
  // If we hit an export in an illegal context, just bail out to avoid cascading errors.
84333
84369
  return;
84334
84370
  }
84335
- if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
84371
+ if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
84336
84372
  grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
84337
84373
  }
84338
84374
  if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
@@ -84943,13 +84979,16 @@ var ts;
84943
84979
  if (ts.isExternalOrCommonJsModule(node)) {
84944
84980
  registerForUnusedIdentifiersCheck(node);
84945
84981
  }
84946
- if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
84947
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
84948
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
84949
- diagnostics.add(diag);
84950
- }
84951
- });
84952
- }
84982
+ addLazyDiagnostic(function () {
84983
+ // This relies on the results of other lazy diagnostics, so must be computed after them
84984
+ if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
84985
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
84986
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
84987
+ diagnostics.add(diag);
84988
+ }
84989
+ });
84990
+ }
84991
+ });
84953
84992
  if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
84954
84993
  !node.isDeclarationFile &&
84955
84994
  ts.isExternalModule(node)) {
@@ -84989,15 +85028,35 @@ var ts;
84989
85028
  cancellationToken = undefined;
84990
85029
  }
84991
85030
  }
85031
+ function ensurePendingDiagnosticWorkComplete() {
85032
+ // Invoke any existing lazy diagnostics to add them, clear the backlog of diagnostics
85033
+ for (var _i = 0, deferredDiagnosticsCallbacks_1 = deferredDiagnosticsCallbacks; _i < deferredDiagnosticsCallbacks_1.length; _i++) {
85034
+ var cb = deferredDiagnosticsCallbacks_1[_i];
85035
+ cb();
85036
+ }
85037
+ deferredDiagnosticsCallbacks = [];
85038
+ }
85039
+ function checkSourceFileWithEagerDiagnostics(sourceFile) {
85040
+ ensurePendingDiagnosticWorkComplete();
85041
+ // then setup diagnostics for immediate invocation (as we are about to collect them, and
85042
+ // this avoids the overhead of longer-lived callbacks we don't need to allocate)
85043
+ // This also serves to make the shift to possibly lazy diagnostics transparent to serial command-line scenarios
85044
+ // (as in those cases, all the diagnostics will still be computed as the appropriate place in the tree,
85045
+ // thus much more likely retaining the same union ordering as before we had lazy diagnostics)
85046
+ var oldAddLazyDiagnostics = addLazyDiagnostic;
85047
+ addLazyDiagnostic = function (cb) { return cb(); };
85048
+ checkSourceFile(sourceFile);
85049
+ addLazyDiagnostic = oldAddLazyDiagnostics;
85050
+ }
84992
85051
  function getDiagnosticsWorker(sourceFile) {
84993
- throwIfNonDiagnosticsProducing();
84994
85052
  if (sourceFile) {
85053
+ ensurePendingDiagnosticWorkComplete();
84995
85054
  // Some global diagnostics are deferred until they are needed and
84996
85055
  // may not be reported in the first call to getGlobalDiagnostics.
84997
85056
  // We should catch these changes and report them.
84998
85057
  var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
84999
85058
  var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
85000
- checkSourceFile(sourceFile);
85059
+ checkSourceFileWithEagerDiagnostics(sourceFile);
85001
85060
  var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
85002
85061
  var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
85003
85062
  if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
@@ -85015,18 +85074,13 @@ var ts;
85015
85074
  }
85016
85075
  // Global diagnostics are always added when a file is not provided to
85017
85076
  // getDiagnostics
85018
- ts.forEach(host.getSourceFiles(), checkSourceFile);
85077
+ ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
85019
85078
  return diagnostics.getDiagnostics();
85020
85079
  }
85021
85080
  function getGlobalDiagnostics() {
85022
- throwIfNonDiagnosticsProducing();
85081
+ ensurePendingDiagnosticWorkComplete();
85023
85082
  return diagnostics.getGlobalDiagnostics();
85024
85083
  }
85025
- function throwIfNonDiagnosticsProducing() {
85026
- if (!produceDiagnostics) {
85027
- throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
85028
- }
85029
- }
85030
85084
  // Language service support
85031
85085
  function getSymbolsInScope(location, meaning) {
85032
85086
  if (location.flags & 16777216 /* InWithStatement */) {
@@ -87509,10 +87563,9 @@ var ts;
87509
87563
  }
87510
87564
  var parent = ts.walkUpParenthesizedTypes(node.parent);
87511
87565
  if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
87512
- parent = parent.parent;
87513
- if (ts.isJSDocTypeTag(parent)) {
87514
- // walk up past JSDoc comment node
87515
- parent = parent.parent.parent;
87566
+ var host_2 = ts.getJSDocHost(parent);
87567
+ if (host_2) {
87568
+ parent = ts.getSingleVariableOfVariableStatement(host_2) || host_2;
87516
87569
  }
87517
87570
  }
87518
87571
  switch (parent.kind) {
@@ -115476,8 +115529,7 @@ var ts;
115476
115529
  var files;
115477
115530
  var symlinks;
115478
115531
  var commonSourceDirectory;
115479
- var diagnosticsProducingTypeChecker;
115480
- var noDiagnosticsTypeChecker;
115532
+ var typeChecker;
115481
115533
  var classifiableNames;
115482
115534
  var ambientModuleNameToUnmodifiedFileName = new ts.Map();
115483
115535
  var fileReasons = ts.createMultiMap();
@@ -115723,21 +115775,19 @@ var ts;
115723
115775
  getProgramDiagnostics: getProgramDiagnostics,
115724
115776
  getTypeChecker: getTypeChecker,
115725
115777
  getClassifiableNames: getClassifiableNames,
115726
- getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
115727
115778
  getCommonSourceDirectory: getCommonSourceDirectory,
115728
115779
  emit: emit,
115729
115780
  getCurrentDirectory: function () { return currentDirectory; },
115730
- getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
115731
- getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
115732
- getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
115733
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
115734
- getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
115735
- getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
115781
+ getNodeCount: function () { return getTypeChecker().getNodeCount(); },
115782
+ getIdentifierCount: function () { return getTypeChecker().getIdentifierCount(); },
115783
+ getSymbolCount: function () { return getTypeChecker().getSymbolCount(); },
115784
+ getTypeCount: function () { return getTypeChecker().getTypeCount(); },
115785
+ getInstantiationCount: function () { return getTypeChecker().getInstantiationCount(); },
115786
+ getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
115736
115787
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
115737
115788
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
115738
115789
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
115739
115790
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
115740
- dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
115741
115791
  getSourceFileFromReference: getSourceFileFromReference,
115742
115792
  getLibFileFromReference: getLibFileFromReference,
115743
115793
  sourceFileToPackageName: sourceFileToPackageName,
@@ -116326,14 +116376,8 @@ var ts;
116326
116376
  return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); });
116327
116377
  }
116328
116378
  }
116329
- function getDiagnosticsProducingTypeChecker() {
116330
- return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true));
116331
- }
116332
- function dropDiagnosticsProducingTypeChecker() {
116333
- diagnosticsProducingTypeChecker = undefined;
116334
- }
116335
116379
  function getTypeChecker() {
116336
- return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false));
116380
+ return typeChecker || (typeChecker = ts.createTypeChecker(program));
116337
116381
  }
116338
116382
  function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
116339
116383
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true);
@@ -116358,7 +116402,7 @@ var ts;
116358
116402
  // This is because in the -out scenario all files need to be emitted, and therefore all
116359
116403
  // files need to be type checked. And the way to specify that all files need to be type
116360
116404
  // checked is to not pass the file to getEmitResolver.
116361
- var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
116405
+ var emitResolver = getTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
116362
116406
  ts.performance.mark("beforeEmit");
116363
116407
  var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles,
116364
116408
  /*onlyBuildInfo*/ false, forceDtsEmit);
@@ -116438,15 +116482,7 @@ var ts;
116438
116482
  if (e instanceof ts.OperationCanceledException) {
116439
116483
  // We were canceled while performing the operation. Because our type checker
116440
116484
  // might be a bad state, we need to throw it away.
116441
- //
116442
- // Note: we are overly aggressive here. We do not actually *have* to throw away
116443
- // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
116444
- // the lifetimes of these two TypeCheckers the same. Also, we generally only
116445
- // cancel when the user has made a change anyways. And, in that case, we (the
116446
- // program instance) will get thrown away anyways. So trying to keep one of
116447
- // these type checkers alive doesn't serve much purpose.
116448
- noDiagnosticsTypeChecker = undefined;
116449
- diagnosticsProducingTypeChecker = undefined;
116485
+ typeChecker = undefined;
116450
116486
  }
116451
116487
  throw e;
116452
116488
  }
@@ -116462,7 +116498,7 @@ var ts;
116462
116498
  if (ts.skipTypeChecking(sourceFile, options, program)) {
116463
116499
  return ts.emptyArray;
116464
116500
  }
116465
- var typeChecker = getDiagnosticsProducingTypeChecker();
116501
+ var typeChecker = getTypeChecker();
116466
116502
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
116467
116503
  var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
116468
116504
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
@@ -116514,7 +116550,7 @@ var ts;
116514
116550
  }
116515
116551
  function getSuggestionDiagnostics(sourceFile, cancellationToken) {
116516
116552
  return runWithCancellationToken(function () {
116517
- return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
116553
+ return getTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
116518
116554
  });
116519
116555
  }
116520
116556
  /**
@@ -116732,7 +116768,7 @@ var ts;
116732
116768
  }
116733
116769
  function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
116734
116770
  return runWithCancellationToken(function () {
116735
- var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
116771
+ var resolver = getTypeChecker().getEmitResolver(sourceFile, cancellationToken);
116736
116772
  // Don't actually write any files since we're just getting diagnostics.
116737
116773
  return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
116738
116774
  });
@@ -116770,7 +116806,7 @@ var ts;
116770
116806
  return diagnostics;
116771
116807
  }
116772
116808
  function getGlobalDiagnostics() {
116773
- return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
116809
+ return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
116774
116810
  }
116775
116811
  function getConfigFileParsingDiagnostics() {
116776
116812
  return configFileParsingDiagnostics || ts.emptyArray;
@@ -130330,14 +130366,15 @@ var ts;
130330
130366
  SortText["SuggestedClassMembers"] = "14";
130331
130367
  SortText["GlobalsOrKeywords"] = "15";
130332
130368
  SortText["AutoImportSuggestions"] = "16";
130333
- SortText["JavascriptIdentifiers"] = "17";
130334
- SortText["DeprecatedLocalDeclarationPriority"] = "18";
130335
- SortText["DeprecatedLocationPriority"] = "19";
130336
- SortText["DeprecatedOptionalMember"] = "20";
130337
- SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "21";
130338
- SortText["DeprecatedSuggestedClassMembers"] = "22";
130339
- SortText["DeprecatedGlobalsOrKeywords"] = "23";
130340
- SortText["DeprecatedAutoImportSuggestions"] = "24";
130369
+ SortText["ClassMemberSnippets"] = "17";
130370
+ SortText["JavascriptIdentifiers"] = "18";
130371
+ SortText["DeprecatedLocalDeclarationPriority"] = "19";
130372
+ SortText["DeprecatedLocationPriority"] = "20";
130373
+ SortText["DeprecatedOptionalMember"] = "21";
130374
+ SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "22";
130375
+ SortText["DeprecatedSuggestedClassMembers"] = "23";
130376
+ SortText["DeprecatedGlobalsOrKeywords"] = "24";
130377
+ SortText["DeprecatedAutoImportSuggestions"] = "25";
130341
130378
  })(SortText = Completions.SortText || (Completions.SortText = {}));
130342
130379
  var SortTextId;
130343
130380
  (function (SortTextId) {
@@ -130349,10 +130386,10 @@ var ts;
130349
130386
  SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
130350
130387
  SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
130351
130388
  // Don't use these directly.
130352
- SortTextId[SortTextId["_JavaScriptIdentifiers"] = 17] = "_JavaScriptIdentifiers";
130353
- SortTextId[SortTextId["_DeprecatedStart"] = 18] = "_DeprecatedStart";
130389
+ SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
130390
+ SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
130354
130391
  SortTextId[SortTextId["_First"] = 10] = "_First";
130355
- SortTextId[SortTextId["DeprecatedOffset"] = 8] = "DeprecatedOffset";
130392
+ SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
130356
130393
  })(SortTextId || (SortTextId = {}));
130357
130394
  /**
130358
130395
  * Special values for `CompletionInfo['source']` used to disambiguate
@@ -130833,6 +130870,7 @@ var ts;
130833
130870
  isClassLikeMemberCompletion(symbol, location)) {
130834
130871
  var importAdder = void 0;
130835
130872
  (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
130873
+ sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
130836
130874
  if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
130837
130875
  hasAction = true;
130838
130876
  source = CompletionSource.ClassMemberSnippet;
@@ -131196,7 +131234,7 @@ var ts;
131196
131234
  }
131197
131235
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
131198
131236
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
131199
- var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131237
+ var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
131200
131238
  var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
131201
131239
  if (!entry) {
131202
131240
  continue;
@@ -148213,7 +148251,7 @@ var ts;
148213
148251
  errorCodes: errorCodes,
148214
148252
  getCodeActions: function getCodeActionsToAddMissingAsync(context) {
148215
148253
  var sourceFile = context.sourceFile, errorCode = context.errorCode, cancellationToken = context.cancellationToken, program = context.program, span = context.span;
148216
- var diagnostic = ts.find(program.getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
148254
+ var diagnostic = ts.find(program.getTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
148217
148255
  var directSpan = diagnostic && diagnostic.relatedInformation && ts.find(diagnostic.relatedInformation, function (r) { return r.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; });
148218
148256
  var decl = getFixableErrorSpanDeclaration(sourceFile, directSpan);
148219
148257
  if (!decl) {
@@ -148367,7 +148405,7 @@ var ts;
148367
148405
  return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await);
148368
148406
  }
148369
148407
  function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) {
148370
- var checker = program.getDiagnosticsProducingTypeChecker();
148408
+ var checker = program.getTypeChecker();
148371
148409
  var diagnostics = checker.getDiagnostics(sourceFile, cancellationToken);
148372
148410
  return ts.some(diagnostics, function (_a) {
148373
148411
  var start = _a.start, length = _a.length, relatedInformation = _a.relatedInformation, code = _a.code;
@@ -149034,20 +149072,6 @@ var ts;
149034
149072
  }
149035
149073
  function createClassElementsFromSymbol(symbol) {
149036
149074
  var memberElements = [];
149037
- // all instance members are stored in the "member" array of symbol
149038
- if (symbol.members) {
149039
- symbol.members.forEach(function (member, key) {
149040
- if (key === "constructor" && member.valueDeclaration) {
149041
- // fn.prototype.constructor = fn
149042
- changes.delete(sourceFile, member.valueDeclaration.parent);
149043
- return;
149044
- }
149045
- var memberElement = createClassElement(member, /*modifiers*/ undefined);
149046
- if (memberElement) {
149047
- memberElements.push.apply(memberElements, memberElement);
149048
- }
149049
- });
149050
- }
149051
149075
  // all static members are stored in the "exports" array of symbol
149052
149076
  if (symbol.exports) {
149053
149077
  symbol.exports.forEach(function (member) {
@@ -149060,18 +149084,31 @@ var ts;
149060
149084
  firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ &&
149061
149085
  ts.isObjectLiteralExpression(firstDeclaration.parent.right)) {
149062
149086
  var prototypes = firstDeclaration.parent.right;
149063
- var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined);
149064
- if (memberElement) {
149065
- memberElements.push.apply(memberElements, memberElement);
149066
- }
149087
+ createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements);
149067
149088
  }
149068
149089
  }
149069
149090
  else {
149070
- var memberElement = createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)]);
149071
- if (memberElement) {
149072
- memberElements.push.apply(memberElements, memberElement);
149091
+ createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements);
149092
+ }
149093
+ });
149094
+ }
149095
+ // all instance members are stored in the "member" array of symbol (done last so instance members pulled from prototype assignments have priority)
149096
+ if (symbol.members) {
149097
+ symbol.members.forEach(function (member, key) {
149098
+ var _a, _b, _c, _d;
149099
+ if (key === "constructor" && member.valueDeclaration) {
149100
+ var prototypeAssignment = (_d = (_c = (_b = (_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.get("prototype")) === null || _b === void 0 ? void 0 : _b.declarations) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.parent;
149101
+ if (prototypeAssignment && ts.isBinaryExpression(prototypeAssignment) && ts.isObjectLiteralExpression(prototypeAssignment.right) && ts.some(prototypeAssignment.right.properties, isConstructorAssignment)) {
149102
+ // fn.prototype = { constructor: fn }
149103
+ // Already deleted in `createClassElement` in first pass
149104
+ }
149105
+ else {
149106
+ // fn.prototype.constructor = fn
149107
+ changes.delete(sourceFile, member.valueDeclaration.parent);
149073
149108
  }
149109
+ return;
149074
149110
  }
149111
+ createClassElement(member, /*modifiers*/ undefined, memberElements);
149075
149112
  });
149076
149113
  }
149077
149114
  return memberElements;
@@ -149099,18 +149136,26 @@ var ts;
149099
149136
  });
149100
149137
  }
149101
149138
  }
149102
- function createClassElement(symbol, modifiers) {
149139
+ function createClassElement(symbol, modifiers, members) {
149103
149140
  // Right now the only thing we can convert are function expressions, which are marked as methods
149104
149141
  // or { x: y } type prototype assignments, which are marked as ObjectLiteral
149105
- var members = [];
149106
149142
  if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) {
149107
- return members;
149143
+ return;
149108
149144
  }
149109
149145
  var memberDeclaration = symbol.valueDeclaration;
149110
149146
  var assignmentBinaryExpression = memberDeclaration.parent;
149111
149147
  var assignmentExpr = assignmentBinaryExpression.right;
149112
149148
  if (!shouldConvertDeclaration(memberDeclaration, assignmentExpr)) {
149113
- return members;
149149
+ return;
149150
+ }
149151
+ if (ts.some(members, function (m) {
149152
+ var name = ts.getNameOfDeclaration(m);
149153
+ if (name && ts.isIdentifier(name) && ts.idText(name) === ts.symbolName(symbol)) {
149154
+ return true; // class member already made for this name
149155
+ }
149156
+ return false;
149157
+ })) {
149158
+ return;
149114
149159
  }
149115
149160
  // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end
149116
149161
  var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 237 /* ExpressionStatement */
@@ -149119,43 +149164,44 @@ var ts;
149119
149164
  if (!assignmentExpr) {
149120
149165
  members.push(ts.factory.createPropertyDeclaration([], modifiers, symbol.name, /*questionToken*/ undefined,
149121
149166
  /*type*/ undefined, /*initializer*/ undefined));
149122
- return members;
149167
+ return;
149123
149168
  }
149124
149169
  // f.x = expr
149125
149170
  if (ts.isAccessExpression(memberDeclaration) && (ts.isFunctionExpression(assignmentExpr) || ts.isArrowFunction(assignmentExpr))) {
149126
149171
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
149127
149172
  var name = tryGetPropertyName(memberDeclaration, compilerOptions, quotePreference);
149128
149173
  if (name) {
149129
- return createFunctionLikeExpressionMember(members, assignmentExpr, name);
149174
+ createFunctionLikeExpressionMember(members, assignmentExpr, name);
149130
149175
  }
149131
- return members;
149176
+ return;
149132
149177
  }
149133
149178
  // f.prototype = { ... }
149134
149179
  else if (ts.isObjectLiteralExpression(assignmentExpr)) {
149135
- return ts.flatMap(assignmentExpr.properties, function (property) {
149180
+ ts.forEach(assignmentExpr.properties, function (property) {
149136
149181
  if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) {
149137
149182
  // MethodDeclaration and AccessorDeclaration can appear in a class directly
149138
- return members.concat(property);
149183
+ members.push(property);
149139
149184
  }
149140
149185
  if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer)) {
149141
- return createFunctionLikeExpressionMember(members, property.initializer, property.name);
149186
+ createFunctionLikeExpressionMember(members, property.initializer, property.name);
149142
149187
  }
149143
149188
  // Drop constructor assignments
149144
149189
  if (isConstructorAssignment(property))
149145
- return members;
149146
- return [];
149190
+ return;
149191
+ return;
149147
149192
  });
149193
+ return;
149148
149194
  }
149149
149195
  else {
149150
149196
  // Don't try to declare members in JavaScript files
149151
149197
  if (ts.isSourceFileJS(sourceFile))
149152
- return members;
149198
+ return;
149153
149199
  if (!ts.isPropertyAccessExpression(memberDeclaration))
149154
- return members;
149200
+ return;
149155
149201
  var prop = ts.factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr);
149156
149202
  ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile);
149157
149203
  members.push(prop);
149158
- return members;
149204
+ return;
149159
149205
  }
149160
149206
  function createFunctionLikeExpressionMember(members, expression, name) {
149161
149207
  if (ts.isFunctionExpression(expression))
@@ -149168,7 +149214,8 @@ var ts;
149168
149214
  var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
149169
149215
  /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body);
149170
149216
  ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
149171
- return members.concat(method);
149217
+ members.push(method);
149218
+ return;
149172
149219
  }
149173
149220
  function createArrowFunctionExpressionMember(members, arrowFunction, name) {
149174
149221
  var arrowFunctionBody = arrowFunction.body;
@@ -149185,7 +149232,7 @@ var ts;
149185
149232
  var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
149186
149233
  /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock);
149187
149234
  ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
149188
- return members.concat(method);
149235
+ members.push(method);
149189
149236
  }
149190
149237
  }
149191
149238
  }
@@ -153615,6 +153662,74 @@ var ts;
153615
153662
  })(ts || (ts = {}));
153616
153663
  /* @internal */
153617
153664
  var ts;
153665
+ (function (ts) {
153666
+ var codefix;
153667
+ (function (codefix) {
153668
+ var fixId = "fixUnreferenceableDecoratorMetadata";
153669
+ var errorCodes = [ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled.code];
153670
+ codefix.registerCodeFix({
153671
+ errorCodes: errorCodes,
153672
+ getCodeActions: function (context) {
153673
+ var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
153674
+ if (!importDeclaration)
153675
+ return;
153676
+ var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 269 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); });
153677
+ var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); });
153678
+ var actions;
153679
+ if (namespaceChanges.length) {
153680
+ actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, namespaceChanges, ts.Diagnostics.Convert_named_imports_to_namespace_import));
153681
+ }
153682
+ if (typeOnlyChanges.length) {
153683
+ actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, typeOnlyChanges, ts.Diagnostics.Convert_to_type_only_import));
153684
+ }
153685
+ return actions;
153686
+ },
153687
+ fixIds: [fixId],
153688
+ });
153689
+ function getImportDeclaration(sourceFile, program, start) {
153690
+ var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier);
153691
+ if (!identifier || identifier.parent.kind !== 177 /* TypeReference */)
153692
+ return;
153693
+ var checker = program.getTypeChecker();
153694
+ var symbol = checker.getSymbolAtLocation(identifier);
153695
+ return ts.find((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, ts.or(ts.isImportClause, ts.isImportSpecifier, ts.isImportEqualsDeclaration));
153696
+ }
153697
+ // Converts the import declaration of the offending import to a type-only import,
153698
+ // only if it can be done without affecting other imported names. If the conversion
153699
+ // cannot be done cleanly, we could offer to *extract* the offending import to a
153700
+ // new type-only import declaration, but honestly I doubt anyone will ever use this
153701
+ // codefix at all, so it's probably not worth the lines of code.
153702
+ function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) {
153703
+ if (importDeclaration.kind === 264 /* ImportEqualsDeclaration */) {
153704
+ changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importDeclaration.name);
153705
+ return;
153706
+ }
153707
+ var importClause = importDeclaration.kind === 266 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent;
153708
+ if (importClause.name && importClause.namedBindings) {
153709
+ // Cannot convert an import with a default import and named bindings to type-only
153710
+ // (it's a grammar error).
153711
+ return;
153712
+ }
153713
+ var checker = program.getTypeChecker();
153714
+ var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) {
153715
+ if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */)
153716
+ return true;
153717
+ });
153718
+ if (importsValue) {
153719
+ // Assume that if someone wrote a non-type-only import that includes some values,
153720
+ // they intend to use those values in value positions, even if they haven't yet.
153721
+ // Don't convert it to type-only.
153722
+ return;
153723
+ }
153724
+ changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importClause);
153725
+ }
153726
+ function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
153727
+ ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
153728
+ }
153729
+ })(codefix = ts.codefix || (ts.codefix = {}));
153730
+ })(ts || (ts = {}));
153731
+ /* @internal */
153732
+ var ts;
153618
153733
  (function (ts) {
153619
153734
  var codefix;
153620
153735
  (function (codefix) {
@@ -156182,6 +156297,7 @@ var ts;
156182
156297
  return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
156183
156298
  }
156184
156299
  function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
156300
+ ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
156185
156301
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
156186
156302
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
156187
156303
  }
@@ -156211,6 +156327,7 @@ var ts;
156211
156327
  return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
156212
156328
  }
156213
156329
  function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
156330
+ ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
156214
156331
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
156215
156332
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
156216
156333
  }
@@ -157134,20 +157251,22 @@ var ts;
157134
157251
  if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
157135
157252
  return { convertTo: 0 /* Named */, import: importClause.namedBindings };
157136
157253
  }
157137
- var compilerOptions = context.program.getCompilerOptions();
157138
- var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
157139
- && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
157254
+ var shouldUseDefault = getShouldUseDefault(context.program, importClause);
157140
157255
  return shouldUseDefault
157141
157256
  ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
157142
157257
  : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
157143
157258
  }
157259
+ function getShouldUseDefault(program, importClause) {
157260
+ return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
157261
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
157262
+ }
157144
157263
  function doChange(sourceFile, program, changes, info) {
157145
157264
  var checker = program.getTypeChecker();
157146
157265
  if (info.convertTo === 0 /* Named */) {
157147
157266
  doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
157148
157267
  }
157149
157268
  else {
157150
- doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
157269
+ doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */);
157151
157270
  }
157152
157271
  }
157153
157272
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -157197,7 +157316,9 @@ var ts;
157197
157316
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
157198
157317
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
157199
157318
  }
157200
- function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
157319
+ function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConvert, shouldUseDefault) {
157320
+ if (shouldUseDefault === void 0) { shouldUseDefault = getShouldUseDefault(program, toConvert.parent); }
157321
+ var checker = program.getTypeChecker();
157201
157322
  var importDecl = toConvert.parent.parent;
157202
157323
  var moduleSpecifier = importDecl.moduleSpecifier;
157203
157324
  var toConvertSymbols = new ts.Set();
@@ -157258,6 +157379,7 @@ var ts;
157258
157379
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
157259
157380
  }
157260
157381
  }
157382
+ refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
157261
157383
  function isExportEqualsModule(moduleSpecifier, checker) {
157262
157384
  var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
157263
157385
  if (!externalModule)
@@ -158658,7 +158780,9 @@ var ts;
158658
158780
  var checker = context.program.getTypeChecker();
158659
158781
  // Make a unique name for the extracted variable
158660
158782
  var file = scope.getSourceFile();
158661
- var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file);
158783
+ var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind)
158784
+ ? node.name.text
158785
+ : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file);
158662
158786
  var isJS = ts.isInJSFile(scope);
158663
158787
  var variableType = isJS || !checker.isContextSensitive(node)
158664
158788
  ? undefined
@@ -162425,10 +162549,12 @@ var ts;
162425
162549
  this.fileNameToEntry = new ts.Map();
162426
162550
  // Initialize the list with the root file names
162427
162551
  var rootFileNames = host.getScriptFileNames();
162552
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
162428
162553
  for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
162429
162554
  var fileName = rootFileNames_1[_i];
162430
162555
  this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
162431
162556
  }
162557
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
162432
162558
  }
162433
162559
  HostCache.prototype.createEntry = function (fileName, path) {
162434
162560
  var entry;
@@ -167916,6 +168042,7 @@ var ts;
167916
168042
  */
167917
168043
  Project.prototype.updateGraph = function () {
167918
168044
  var _a;
168045
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] });
167919
168046
  ts.perfLogger.logStartUpdateGraph();
167920
168047
  this.resolutionCache.startRecordingFilesWithChangedResolutions();
167921
168048
  var hasNewProgram = this.updateGraphWorker();
@@ -167959,6 +168086,7 @@ var ts;
167959
168086
  this.getPackageJsonAutoImportProvider();
167960
168087
  }
167961
168088
  ts.perfLogger.logStopUpdateGraph();
168089
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
167962
168090
  return !hasNewProgram;
167963
168091
  };
167964
168092
  /*@internal*/
@@ -167991,7 +168119,9 @@ var ts;
167991
168119
  this.resolutionCache.startCachingPerDirectoryResolution();
167992
168120
  this.program = this.languageService.getProgram(); // TODO: GH#18217
167993
168121
  this.dirty = false;
168122
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
167994
168123
  this.resolutionCache.finishCachingPerDirectoryResolution();
168124
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
167995
168125
  ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
167996
168126
  // bump up the version if
167997
168127
  // - oldProgram is not set - this is a first time updateGraph is called
@@ -168539,13 +168669,16 @@ var ts;
168539
168669
  }
168540
168670
  var dependencySelection = this.includePackageJsonAutoImports();
168541
168671
  if (dependencySelection) {
168672
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider");
168542
168673
  var start = ts.timestamp();
168543
168674
  this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry);
168544
168675
  if (this.autoImportProviderHost) {
168545
168676
  server.updateProjectIfDirty(this.autoImportProviderHost);
168546
168677
  this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", ts.timestamp() - start);
168678
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
168547
168679
  return this.autoImportProviderHost.getCurrentProgram();
168548
168680
  }
168681
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
168549
168682
  }
168550
168683
  };
168551
168684
  /*@internal*/
@@ -168565,10 +168698,14 @@ var ts;
168565
168698
  }());
168566
168699
  server.Project = Project;
168567
168700
  function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) {
168701
+ var sourceFiles = program.getSourceFiles();
168702
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length });
168568
168703
  var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); });
168569
- return ts.sortAndDeduplicate(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
168704
+ var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) {
168570
168705
  return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile);
168571
168706
  }));
168707
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
168708
+ return result;
168572
168709
  }
168573
168710
  function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) {
168574
168711
  return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () {
@@ -170642,6 +170779,7 @@ var ts;
170642
170779
  };
170643
170780
  /* @internal */
170644
170781
  ProjectService.prototype.createConfiguredProject = function (configFileName) {
170782
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName });
170645
170783
  this.logger.info("Creating configuration project " + configFileName);
170646
170784
  var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName));
170647
170785
  var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
@@ -170690,6 +170828,7 @@ var ts;
170690
170828
  /* @internal */
170691
170829
  ProjectService.prototype.loadConfiguredProject = function (project, reason) {
170692
170830
  var _this = this;
170831
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath });
170693
170832
  this.sendProjectLoadingStartEvent(project, reason);
170694
170833
  // Read updated contents from disk
170695
170834
  var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath()));
@@ -170725,6 +170864,7 @@ var ts;
170725
170864
  project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides);
170726
170865
  var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles());
170727
170866
  this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions);
170867
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
170728
170868
  };
170729
170869
  /*@internal*/
170730
170870
  ProjectService.prototype.ensureParsedConfigUptoDate = function (configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) {
@@ -173773,7 +173913,6 @@ var ts;
173773
173913
  this.host.write(msgText);
173774
173914
  };
173775
173915
  Session.prototype.event = function (body, eventName) {
173776
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
173777
173916
  this.send(toEvent(eventName, body));
173778
173917
  };
173779
173918
  // For backwards-compatibility only.
@@ -173822,16 +173961,22 @@ var ts;
173822
173961
  this.send(res);
173823
173962
  };
173824
173963
  Session.prototype.semanticCheck = function (file, project) {
173964
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
173825
173965
  var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file)
173826
173966
  ? server.emptyArray
173827
173967
  : project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; });
173828
173968
  this.sendDiagnosticsEvent(file, project, diags, "semanticDiag");
173969
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
173829
173970
  };
173830
173971
  Session.prototype.syntacticCheck = function (file, project) {
173972
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
173831
173973
  this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag");
173974
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
173832
173975
  };
173833
173976
  Session.prototype.suggestionCheck = function (file, project) {
173977
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
173834
173978
  this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag");
173979
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
173835
173980
  };
173836
173981
  Session.prototype.sendDiagnosticsEvent = function (file, project, diagnostics, kind) {
173837
173982
  try {