typescript 4.7.0-dev.20220323 → 4.7.0-dev.20220325

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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220323";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220325";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -8396,6 +8396,7 @@ var ts;
8396
8396
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8397
8397
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8398
8398
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8399
+ This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8399
8400
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
8400
8401
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
8401
8402
  Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -44419,11 +44420,14 @@ var ts;
44419
44420
  var saveExceptionTarget = currentExceptionTarget;
44420
44421
  var saveActiveLabelList = activeLabelList;
44421
44422
  var saveHasExplicitReturn = hasExplicitReturn;
44422
- var isIIFE = containerFlags & 16 /* IsFunctionExpression */ && !ts.hasSyntacticModifier(node, 256 /* Async */) &&
44423
- !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
44423
+ var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ &&
44424
+ !ts.hasSyntacticModifier(node, 256 /* Async */) &&
44425
+ !node.asteriskToken &&
44426
+ !!ts.getImmediatelyInvokedFunctionExpression(node)) ||
44427
+ node.kind === 170 /* ClassStaticBlockDeclaration */;
44424
44428
  // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
44425
44429
  // similarly to break statements that exit to a label just past the statement body.
44426
- if (!isIIFE) {
44430
+ if (!isImmediatelyInvoked) {
44427
44431
  currentFlow = initFlowNode({ flags: 2 /* Start */ });
44428
44432
  if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) {
44429
44433
  currentFlow.node = node;
@@ -44431,7 +44435,7 @@ var ts;
44431
44435
  }
44432
44436
  // We create a return control flow graph for IIFEs and constructors. For constructors
44433
44437
  // we use the return control flow graph in strict property initialization checks.
44434
- currentReturnTarget = isIIFE || node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined;
44438
+ currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined;
44435
44439
  currentExceptionTarget = undefined;
44436
44440
  currentBreakTarget = undefined;
44437
44441
  currentContinueTarget = undefined;
@@ -44457,7 +44461,7 @@ var ts;
44457
44461
  node.returnFlowNode = currentFlow;
44458
44462
  }
44459
44463
  }
44460
- if (!isIIFE) {
44464
+ if (!isImmediatelyInvoked) {
44461
44465
  currentFlow = saveCurrentFlow;
44462
44466
  }
44463
44467
  currentBreakTarget = saveBreakTarget;
@@ -47503,7 +47507,7 @@ var ts;
47503
47507
  (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */);
47504
47508
  }
47505
47509
  ts.isInstantiatedModule = isInstantiatedModule;
47506
- function createTypeChecker(host, produceDiagnostics) {
47510
+ function createTypeChecker(host) {
47507
47511
  var getPackagesMap = ts.memoize(function () {
47508
47512
  // A package name maps to true when we detect it has .d.ts files.
47509
47513
  // This is useful as an approximation of whether a package bundles its own types.
@@ -47520,6 +47524,10 @@ var ts;
47520
47524
  });
47521
47525
  return map;
47522
47526
  });
47527
+ var deferredDiagnosticsCallbacks = [];
47528
+ var addLazyDiagnostic = function (arg) {
47529
+ deferredDiagnosticsCallbacks.push(arg);
47530
+ };
47523
47531
  // Cancellation that controls whether or not we can cancel in the middle of type checking.
47524
47532
  // In general cancelling is *not* safe for the type checker. We might be in the middle of
47525
47533
  // computing something, and we will leave our internals in an inconsistent state. Callers
@@ -47883,8 +47891,8 @@ var ts;
47883
47891
  // Do this in a finally block so we can ensure that it gets reset back to nothing after
47884
47892
  // this call is done.
47885
47893
  cancellationToken = ct;
47886
- // Ensure file is type checked
47887
- checkSourceFile(file);
47894
+ // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused
47895
+ checkSourceFileWithEagerDiagnostics(file);
47888
47896
  ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
47889
47897
  diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
47890
47898
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
@@ -49220,110 +49228,114 @@ var ts;
49220
49228
  }
49221
49229
  }
49222
49230
  if (!result) {
49223
- if (nameNotFoundMessage && produceDiagnostics) {
49224
- if (!errorLocation ||
49225
- !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
49226
- !checkAndReportErrorForExtendingInterface(errorLocation) &&
49227
- !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
49228
- !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
49229
- !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
49230
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
49231
- !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
49232
- var suggestion = void 0;
49233
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
49234
- suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
49235
- var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
49236
- if (isGlobalScopeAugmentationDeclaration) {
49237
- suggestion = undefined;
49238
- }
49239
- if (suggestion) {
49240
- var suggestionName = symbolToString(suggestion);
49241
- var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
49242
- var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
49243
- : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
49244
- : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
49245
- var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
49246
- addErrorOrSuggestion(!isUncheckedJS, diagnostic);
49247
- if (suggestion.valueDeclaration) {
49248
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
49231
+ if (nameNotFoundMessage) {
49232
+ addLazyDiagnostic(function () {
49233
+ if (!errorLocation ||
49234
+ !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
49235
+ !checkAndReportErrorForExtendingInterface(errorLocation) &&
49236
+ !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
49237
+ !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
49238
+ !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
49239
+ !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
49240
+ !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
49241
+ var suggestion = void 0;
49242
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
49243
+ suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
49244
+ var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
49245
+ if (isGlobalScopeAugmentationDeclaration) {
49246
+ suggestion = undefined;
49249
49247
  }
49250
- }
49251
- }
49252
- if (!suggestion) {
49253
- if (nameArg) {
49254
- var lib = getSuggestedLibForNonExistentName(nameArg);
49255
- if (lib) {
49256
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
49248
+ if (suggestion) {
49249
+ var suggestionName = symbolToString(suggestion);
49250
+ var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
49251
+ var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
49252
+ : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
49253
+ : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
49254
+ var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
49255
+ addErrorOrSuggestion(!isUncheckedJS, diagnostic);
49256
+ if (suggestion.valueDeclaration) {
49257
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
49258
+ }
49257
49259
  }
49258
- else {
49259
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
49260
+ }
49261
+ if (!suggestion) {
49262
+ if (nameArg) {
49263
+ var lib = getSuggestedLibForNonExistentName(nameArg);
49264
+ if (lib) {
49265
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
49266
+ }
49267
+ else {
49268
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
49269
+ }
49260
49270
  }
49261
49271
  }
49272
+ suggestionCount++;
49262
49273
  }
49263
- suggestionCount++;
49264
- }
49274
+ });
49265
49275
  }
49266
49276
  return undefined;
49267
49277
  }
49278
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
49279
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
49280
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
49281
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
49282
+ var propertyName = propertyWithInvalidInitializer.name;
49283
+ error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
49284
+ return undefined;
49285
+ }
49268
49286
  // Perform extra checks only if error reporting was requested
49269
- if (nameNotFoundMessage && produceDiagnostics) {
49270
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
49271
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
49272
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
49273
- // with ESNext+useDefineForClassFields because the scope semantics are different.
49274
- var propertyName = propertyWithInvalidInitializer.name;
49275
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
49276
- return undefined;
49277
- }
49278
- // Only check for block-scoped variable if we have an error location and are looking for the
49279
- // name with variable meaning
49280
- // For example,
49281
- // declare module foo {
49282
- // interface bar {}
49283
- // }
49284
- // const foo/*1*/: foo/*2*/.bar;
49285
- // The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
49286
- // block-scoped variable and namespace module. However, only when we
49287
- // try to resolve name in /*1*/ which is used in variable position,
49288
- // we want to check for block-scoped
49289
- if (errorLocation &&
49290
- (meaning & 2 /* BlockScopedVariable */ ||
49291
- ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) {
49292
- var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
49293
- if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
49294
- checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
49295
- }
49296
- }
49297
- // If we're in an external module, we can't reference value symbols created from UMD export declarations
49298
- if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49299
- var merged = getMergedSymbol(result);
49300
- if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49301
- 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));
49302
- }
49303
- }
49304
- // 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
49305
- if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) {
49306
- var candidate = getMergedSymbol(getLateBoundSymbol(result));
49307
- var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
49308
- // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
49309
- if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
49310
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
49311
- }
49312
- // And it cannot refer to any declarations which come after it
49313
- else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
49314
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
49315
- }
49316
- }
49317
- if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
49318
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
49319
- if (typeOnlyDeclaration) {
49320
- var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */
49321
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
49322
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
49323
- var unescapedName = ts.unescapeLeadingUnderscores(name);
49324
- addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
49287
+ if (nameNotFoundMessage) {
49288
+ addLazyDiagnostic(function () {
49289
+ // Only check for block-scoped variable if we have an error location and are looking for the
49290
+ // name with variable meaning
49291
+ // For example,
49292
+ // declare module foo {
49293
+ // interface bar {}
49294
+ // }
49295
+ // const foo/*1*/: foo/*2*/.bar;
49296
+ // The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
49297
+ // block-scoped variable and namespace module. However, only when we
49298
+ // try to resolve name in /*1*/ which is used in variable position,
49299
+ // we want to check for block-scoped
49300
+ if (errorLocation &&
49301
+ (meaning & 2 /* BlockScopedVariable */ ||
49302
+ ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) {
49303
+ var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
49304
+ if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
49305
+ checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
49306
+ }
49307
+ }
49308
+ // If we're in an external module, we can't reference value symbols created from UMD export declarations
49309
+ if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
49310
+ var merged = getMergedSymbol(result);
49311
+ if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
49312
+ 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));
49313
+ }
49314
+ }
49315
+ // 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
49316
+ if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) {
49317
+ var candidate = getMergedSymbol(getLateBoundSymbol(result));
49318
+ var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
49319
+ // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
49320
+ if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
49321
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
49322
+ }
49323
+ // And it cannot refer to any declarations which come after it
49324
+ else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
49325
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
49326
+ }
49327
+ }
49328
+ if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
49329
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
49330
+ if (typeOnlyDeclaration) {
49331
+ var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */
49332
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
49333
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
49334
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
49335
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
49336
+ }
49325
49337
  }
49326
- }
49338
+ });
49327
49339
  }
49328
49340
  return result;
49329
49341
  }
@@ -50969,9 +50981,7 @@ var ts;
50969
50981
  var result = new Type(checker, flags);
50970
50982
  typeCount++;
50971
50983
  result.id = typeCount;
50972
- if (produceDiagnostics) { // Only record types from one checker
50973
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
50974
- }
50984
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
50975
50985
  return result;
50976
50986
  }
50977
50987
  function createOriginType(flags) {
@@ -64305,6 +64315,7 @@ var ts;
64305
64315
  return 0 /* False */;
64306
64316
  }
64307
64317
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
64318
+ var _a, _b;
64308
64319
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
64309
64320
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
64310
64321
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -64345,6 +64356,9 @@ var ts;
64345
64356
  return;
64346
64357
  }
64347
64358
  reportRelationError(headMessage, source, target);
64359
+ if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
64360
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
64361
+ }
64348
64362
  }
64349
64363
  function traceUnionsOrIntersectionsTooLarge(source, target) {
64350
64364
  if (!ts.tracing) {
@@ -65117,7 +65131,7 @@ var ts;
65117
65131
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
65118
65132
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
65119
65133
  var constraint = getConstraintOfType(source);
65120
- if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
65134
+ if (!strictNullChecks && (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */))) {
65121
65135
  // A type variable with no constraint is not related to the non-primitive object type.
65122
65136
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
65123
65137
  resetErrorInfo(saveErrorInfo);
@@ -65125,12 +65139,12 @@ var ts;
65125
65139
  }
65126
65140
  }
65127
65141
  // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
65128
- else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
65142
+ else if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState))) {
65129
65143
  resetErrorInfo(saveErrorInfo);
65130
65144
  return result;
65131
65145
  }
65132
65146
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
65133
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
65147
+ else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState))) {
65134
65148
  resetErrorInfo(saveErrorInfo);
65135
65149
  return result;
65136
65150
  }
@@ -67189,12 +67203,14 @@ var ts;
67189
67203
  errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
67190
67204
  }
67191
67205
  function reportErrorsFromWidening(declaration, type, wideningKind) {
67192
- if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
67193
- // Report implicit any error within type if possible, otherwise report error on declaration
67194
- if (!reportWideningErrorsInType(type)) {
67195
- reportImplicitAny(declaration, type, wideningKind);
67206
+ addLazyDiagnostic(function () {
67207
+ if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
67208
+ // Report implicit any error within type if possible, otherwise report error on declaration
67209
+ if (!reportWideningErrorsInType(type)) {
67210
+ reportImplicitAny(declaration, type, wideningKind);
67211
+ }
67196
67212
  }
67197
- }
67213
+ });
67198
67214
  }
67199
67215
  function applyToParameterTypes(source, target, callback) {
67200
67216
  var sourceCount = getParameterCount(source);
@@ -73957,6 +73973,7 @@ var ts;
73957
73973
  && !isOptionalPropertyDeclaration(valueDeclaration)
73958
73974
  && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
73959
73975
  && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
73976
+ && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */)
73960
73977
  && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
73961
73978
  diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
73962
73979
  }
@@ -75186,7 +75203,7 @@ var ts;
75186
75203
  var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */;
75187
75204
  var isDecorator = node.kind === 165 /* Decorator */;
75188
75205
  var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
75189
- var reportErrors = !candidatesOutArray && produceDiagnostics;
75206
+ var reportErrors = !candidatesOutArray;
75190
75207
  var typeArguments;
75191
75208
  if (!isDecorator) {
75192
75209
  typeArguments = node.typeArguments;
@@ -76466,11 +76483,13 @@ var ts;
76466
76483
  checkSourceElement(type);
76467
76484
  exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
76468
76485
  var targetType = getTypeFromTypeNode(type);
76469
- if (produceDiagnostics && !isErrorType(targetType)) {
76470
- var widenedType = getWidenedType(exprType);
76471
- if (!isTypeComparableTo(targetType, widenedType)) {
76472
- 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);
76473
- }
76486
+ if (!isErrorType(targetType)) {
76487
+ addLazyDiagnostic(function () {
76488
+ var widenedType = getWidenedType(exprType);
76489
+ if (!isTypeComparableTo(targetType, widenedType)) {
76490
+ 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);
76491
+ }
76492
+ });
76474
76493
  }
76475
76494
  return targetType;
76476
76495
  }
@@ -77230,47 +77249,48 @@ var ts;
77230
77249
  * @param returnType - return type of the function, can be undefined if return type is not explicitly specified
77231
77250
  */
77232
77251
  function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
77233
- if (!produceDiagnostics) {
77234
- return;
77235
- }
77236
- var functionFlags = ts.getFunctionFlags(func);
77237
- var type = returnType && unwrapReturnType(returnType, functionFlags);
77238
- // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
77239
- if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
77240
- return;
77241
- }
77242
- // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
77243
- // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
77244
- if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) {
77245
- return;
77246
- }
77247
- var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
77248
- var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
77249
- if (type && type.flags & 131072 /* Never */) {
77250
- error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
77251
- }
77252
- else if (type && !hasExplicitReturn) {
77253
- // minimal check: function has syntactic return type annotation and no explicit return statements in the body
77254
- // this function does not conform to the specification.
77255
- error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
77256
- }
77257
- else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
77258
- error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
77259
- }
77260
- else if (compilerOptions.noImplicitReturns) {
77261
- if (!type) {
77262
- // If return type annotation is omitted check if function has any explicit return statements.
77263
- // If it does not have any - its inferred return type is void - don't do any checks.
77264
- // Otherwise get inferred return type from function body and report error only if it is not void / anytype
77265
- if (!hasExplicitReturn) {
77266
- return;
77267
- }
77268
- var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
77269
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
77270
- return;
77252
+ addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
77253
+ return;
77254
+ function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
77255
+ var functionFlags = ts.getFunctionFlags(func);
77256
+ var type = returnType && unwrapReturnType(returnType, functionFlags);
77257
+ // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
77258
+ if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
77259
+ return;
77260
+ }
77261
+ // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
77262
+ // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
77263
+ if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) {
77264
+ return;
77265
+ }
77266
+ var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
77267
+ var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
77268
+ if (type && type.flags & 131072 /* Never */) {
77269
+ error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
77270
+ }
77271
+ else if (type && !hasExplicitReturn) {
77272
+ // minimal check: function has syntactic return type annotation and no explicit return statements in the body
77273
+ // this function does not conform to the specification.
77274
+ error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
77275
+ }
77276
+ else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
77277
+ error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
77278
+ }
77279
+ else if (compilerOptions.noImplicitReturns) {
77280
+ if (!type) {
77281
+ // If return type annotation is omitted check if function has any explicit return statements.
77282
+ // If it does not have any - its inferred return type is void - don't do any checks.
77283
+ // Otherwise get inferred return type from function body and report error only if it is not void / anytype
77284
+ if (!hasExplicitReturn) {
77285
+ return;
77286
+ }
77287
+ var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
77288
+ if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
77289
+ return;
77290
+ }
77271
77291
  }
77292
+ error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
77272
77293
  }
77273
- error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
77274
77294
  }
77275
77295
  }
77276
77296
  function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
@@ -77530,49 +77550,50 @@ var ts;
77530
77550
  checkExpression(node.expression);
77531
77551
  return undefinedWideningType;
77532
77552
  }
77533
- function checkAwaitExpression(node) {
77553
+ function checkAwaitExpressionGrammar(node) {
77534
77554
  // Grammar checking
77535
- if (produceDiagnostics) {
77536
- var container = ts.getContainingFunctionOrClassStaticBlock(node);
77537
- if (container && ts.isClassStaticBlockDeclaration(container)) {
77538
- error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
77539
- }
77540
- else if (!(node.flags & 32768 /* AwaitContext */)) {
77541
- if (ts.isInTopLevelContext(node)) {
77542
- var sourceFile = ts.getSourceFileOfNode(node);
77543
- if (!hasParseDiagnostics(sourceFile)) {
77544
- var span = void 0;
77545
- if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
77546
- if (!span)
77547
- span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77548
- 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);
77549
- diagnostics.add(diagnostic);
77550
- }
77551
- 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 */) {
77555
+ var container = ts.getContainingFunctionOrClassStaticBlock(node);
77556
+ if (container && ts.isClassStaticBlockDeclaration(container)) {
77557
+ error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
77558
+ }
77559
+ else if (!(node.flags & 32768 /* AwaitContext */)) {
77560
+ if (ts.isInTopLevelContext(node)) {
77561
+ var sourceFile = ts.getSourceFileOfNode(node);
77562
+ if (!hasParseDiagnostics(sourceFile)) {
77563
+ var span = void 0;
77564
+ if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
77565
+ if (!span)
77552
77566
  span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77553
- 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);
77554
- diagnostics.add(diagnostic);
77555
- }
77567
+ 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);
77568
+ diagnostics.add(diagnostic);
77556
77569
  }
77557
- }
77558
- else {
77559
- // use of 'await' in non-async function
77560
- var sourceFile = ts.getSourceFileOfNode(node);
77561
- if (!hasParseDiagnostics(sourceFile)) {
77562
- var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77563
- 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);
77564
- if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
77565
- var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
77566
- ts.addRelatedInfo(diagnostic, relatedInfo);
77567
- }
77570
+ 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 */) {
77571
+ span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77572
+ 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);
77568
77573
  diagnostics.add(diagnostic);
77569
77574
  }
77570
77575
  }
77571
77576
  }
77572
- if (isInParameterInitializerBeforeContainingFunction(node)) {
77573
- error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
77577
+ else {
77578
+ // use of 'await' in non-async function
77579
+ var sourceFile = ts.getSourceFileOfNode(node);
77580
+ if (!hasParseDiagnostics(sourceFile)) {
77581
+ var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
77582
+ 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);
77583
+ if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
77584
+ var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
77585
+ ts.addRelatedInfo(diagnostic, relatedInfo);
77586
+ }
77587
+ diagnostics.add(diagnostic);
77588
+ }
77574
77589
  }
77575
77590
  }
77591
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
77592
+ error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
77593
+ }
77594
+ }
77595
+ function checkAwaitExpression(node) {
77596
+ addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); });
77576
77597
  var operandType = checkExpression(node.expression);
77577
77598
  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);
77578
77599
  if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
@@ -78396,7 +78417,10 @@ var ts;
78396
78417
  }
78397
78418
  }
78398
78419
  function checkAssignmentOperator(valueType) {
78399
- if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
78420
+ if (ts.isAssignmentOperator(operator)) {
78421
+ addLazyDiagnostic(checkAssignmentOperatorWorker);
78422
+ }
78423
+ function checkAssignmentOperatorWorker() {
78400
78424
  // TypeScript 1.0 spec (April 2014): 4.17
78401
78425
  // An assignment of the form
78402
78426
  // VarExpr = ValueExpr
@@ -78495,15 +78519,7 @@ var ts;
78495
78519
  return [effectiveLeft, effectiveRight];
78496
78520
  }
78497
78521
  function checkYieldExpression(node) {
78498
- // Grammar checking
78499
- if (produceDiagnostics) {
78500
- if (!(node.flags & 8192 /* YieldContext */)) {
78501
- grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
78502
- }
78503
- if (isInParameterInitializerBeforeContainingFunction(node)) {
78504
- error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
78505
- }
78506
- }
78522
+ addLazyDiagnostic(checkYieldExpressionGrammar);
78507
78523
  var func = ts.getContainingFunction(node);
78508
78524
  if (!func)
78509
78525
  return anyType;
@@ -78549,14 +78565,24 @@ var ts;
78549
78565
  var type = getContextualIterationType(2 /* Next */, func);
78550
78566
  if (!type) {
78551
78567
  type = anyType;
78552
- if (produceDiagnostics && noImplicitAny && !ts.expressionResultIsUnused(node)) {
78553
- var contextualType = getContextualType(node);
78554
- if (!contextualType || isTypeAny(contextualType)) {
78555
- error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
78568
+ addLazyDiagnostic(function () {
78569
+ if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
78570
+ var contextualType = getContextualType(node);
78571
+ if (!contextualType || isTypeAny(contextualType)) {
78572
+ error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
78573
+ }
78556
78574
  }
78557
- }
78575
+ });
78558
78576
  }
78559
78577
  return type;
78578
+ function checkYieldExpressionGrammar() {
78579
+ if (!(node.flags & 8192 /* YieldContext */)) {
78580
+ grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
78581
+ }
78582
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
78583
+ error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
78584
+ }
78585
+ }
78560
78586
  }
78561
78587
  function checkConditionalExpression(node, checkMode) {
78562
78588
  checkTruthinessExpression(node.condition);
@@ -79152,9 +79178,7 @@ var ts;
79152
79178
  varianceTypeParameter = saveVarianceTypeParameter;
79153
79179
  }
79154
79180
  }
79155
- if (produceDiagnostics) {
79156
- checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
79157
- }
79181
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
79158
79182
  }
79159
79183
  function checkParameter(node) {
79160
79184
  // Grammar checking
@@ -79308,7 +79332,8 @@ var ts;
79308
79332
  if (node.type) {
79309
79333
  checkSourceElement(node.type);
79310
79334
  }
79311
- if (produceDiagnostics) {
79335
+ addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
79336
+ function checkSignatureDeclarationDiagnostics() {
79312
79337
  checkCollisionWithArgumentsInGeneratedCode(node);
79313
79338
  var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
79314
79339
  if (noImplicitAny && !returnTypeNode) {
@@ -79598,9 +79623,8 @@ var ts;
79598
79623
  if (ts.nodeIsMissing(node.body)) {
79599
79624
  return;
79600
79625
  }
79601
- if (!produceDiagnostics) {
79602
- return;
79603
- }
79626
+ addLazyDiagnostic(checkConstructorDeclarationDiagnostics);
79627
+ return;
79604
79628
  function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
79605
79629
  if (ts.isPrivateIdentifierClassElementDeclaration(n)) {
79606
79630
  return true;
@@ -79609,54 +79633,56 @@ var ts;
79609
79633
  !ts.isStatic(n) &&
79610
79634
  !!n.initializer;
79611
79635
  }
79612
- // TS 1.0 spec (April 2014): 8.3.2
79613
- // Constructors of classes with no extends clause may not contain super calls, whereas
79614
- // constructors of derived classes must contain at least one super call somewhere in their function body.
79615
- var containingClassDecl = node.parent;
79616
- if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
79617
- captureLexicalThis(node.parent, containingClassDecl);
79618
- var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
79619
- var superCall = findFirstSuperCall(node.body);
79620
- if (superCall) {
79621
- if (classExtendsNull) {
79622
- error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
79623
- }
79624
- // A super call must be root-level in a constructor if both of the following are true:
79625
- // - The containing class is a derived class.
79626
- // - The constructor declares parameter properties
79627
- // or the containing class declares instance member variables with initializers.
79628
- var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
79629
- (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
79630
- ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
79631
- if (superCallShouldBeRootLevel) {
79632
- // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
79633
- // See GH #8277
79634
- if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
79635
- 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);
79636
- }
79637
- // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
79638
- else {
79639
- var superCallStatement = void 0;
79640
- for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
79641
- var statement = _a[_i];
79642
- if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
79643
- superCallStatement = statement;
79644
- break;
79645
- }
79646
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
79647
- break;
79648
- }
79649
- }
79636
+ function checkConstructorDeclarationDiagnostics() {
79637
+ // TS 1.0 spec (April 2014): 8.3.2
79638
+ // Constructors of classes with no extends clause may not contain super calls, whereas
79639
+ // constructors of derived classes must contain at least one super call somewhere in their function body.
79640
+ var containingClassDecl = node.parent;
79641
+ if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
79642
+ captureLexicalThis(node.parent, containingClassDecl);
79643
+ var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
79644
+ var superCall = findFirstSuperCall(node.body);
79645
+ if (superCall) {
79646
+ if (classExtendsNull) {
79647
+ error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
79648
+ }
79649
+ // A super call must be root-level in a constructor if both of the following are true:
79650
+ // - The containing class is a derived class.
79651
+ // - The constructor declares parameter properties
79652
+ // or the containing class declares instance member variables with initializers.
79653
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
79654
+ (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
79655
+ ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
79656
+ if (superCallShouldBeRootLevel) {
79650
79657
  // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
79651
79658
  // See GH #8277
79652
- if (superCallStatement === undefined) {
79653
- 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);
79659
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
79660
+ 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);
79661
+ }
79662
+ // Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
79663
+ else {
79664
+ var superCallStatement = void 0;
79665
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
79666
+ var statement = _a[_i];
79667
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
79668
+ superCallStatement = statement;
79669
+ break;
79670
+ }
79671
+ if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
79672
+ break;
79673
+ }
79674
+ }
79675
+ // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
79676
+ // See GH #8277
79677
+ if (superCallStatement === undefined) {
79678
+ 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);
79679
+ }
79654
79680
  }
79655
79681
  }
79656
79682
  }
79657
- }
79658
- else if (!classExtendsNull) {
79659
- error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
79683
+ else if (!classExtendsNull) {
79684
+ error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
79685
+ }
79660
79686
  }
79661
79687
  }
79662
79688
  }
@@ -79674,7 +79700,10 @@ var ts;
79674
79700
  return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
79675
79701
  }
79676
79702
  function checkAccessorDeclaration(node) {
79677
- if (produceDiagnostics) {
79703
+ addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
79704
+ checkSourceElement(node.body);
79705
+ setNodeLinksForPrivateIdentifierScope(node);
79706
+ function checkAccessorDeclarationDiagnostics() {
79678
79707
  // Grammar checking accessors
79679
79708
  if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
79680
79709
  checkGrammarComputedPropertyName(node.name);
@@ -79724,8 +79753,6 @@ var ts;
79724
79753
  checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
79725
79754
  }
79726
79755
  }
79727
- checkSourceElement(node.body);
79728
- setNodeLinksForPrivateIdentifierScope(node);
79729
79756
  }
79730
79757
  function checkMissingDeclaration(node) {
79731
79758
  checkDecorators(node);
@@ -79768,11 +79795,13 @@ var ts;
79768
79795
  ts.forEach(node.typeArguments, checkSourceElement);
79769
79796
  var type = getTypeFromTypeReference(node);
79770
79797
  if (!isErrorType(type)) {
79771
- if (node.typeArguments && produceDiagnostics) {
79772
- var typeParameters = getTypeParametersForTypeReference(node);
79773
- if (typeParameters) {
79774
- checkTypeArgumentConstraints(node, typeParameters);
79775
- }
79798
+ if (node.typeArguments) {
79799
+ addLazyDiagnostic(function () {
79800
+ var typeParameters = getTypeParametersForTypeReference(node);
79801
+ if (typeParameters) {
79802
+ checkTypeArgumentConstraints(node, typeParameters);
79803
+ }
79804
+ });
79776
79805
  }
79777
79806
  var symbol = getNodeLinks(node).resolvedSymbol;
79778
79807
  if (symbol) {
@@ -79800,7 +79829,8 @@ var ts;
79800
79829
  }
79801
79830
  function checkTypeLiteral(node) {
79802
79831
  ts.forEach(node.members, checkSourceElement);
79803
- if (produceDiagnostics) {
79832
+ addLazyDiagnostic(checkTypeLiteralDiagnostics);
79833
+ function checkTypeLiteralDiagnostics() {
79804
79834
  var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
79805
79835
  checkIndexConstraints(type, type.symbol);
79806
79836
  checkTypeForDuplicateIndexSignatures(node);
@@ -79991,9 +80021,9 @@ var ts;
79991
80021
  return flags & flagsToCheck;
79992
80022
  }
79993
80023
  function checkFunctionOrConstructorSymbol(symbol) {
79994
- if (!produceDiagnostics) {
79995
- return;
79996
- }
80024
+ addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
80025
+ }
80026
+ function checkFunctionOrConstructorSymbolWorker(symbol) {
79997
80027
  function getCanonicalOverload(overloads, implementation) {
79998
80028
  // Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
79999
80029
  // Error on all deviations from this canonical set of flags
@@ -80214,9 +80244,9 @@ var ts;
80214
80244
  }
80215
80245
  }
80216
80246
  function checkExportsOnMergedDeclarations(node) {
80217
- if (!produceDiagnostics) {
80218
- return;
80219
- }
80247
+ addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); });
80248
+ }
80249
+ function checkExportsOnMergedDeclarationsWorker(node) {
80220
80250
  // if localSymbol is defined on node then node itself is exported - check is required
80221
80251
  var symbol = node.localSymbol;
80222
80252
  if (!symbol) {
@@ -80860,7 +80890,8 @@ var ts;
80860
80890
  ts.forEach(node.decorators, checkDecorator);
80861
80891
  }
80862
80892
  function checkFunctionDeclaration(node) {
80863
- if (produceDiagnostics) {
80893
+ addLazyDiagnostic(checkFunctionDeclarationDiagnostics);
80894
+ function checkFunctionDeclarationDiagnostics() {
80864
80895
  checkFunctionOrMethodDeclaration(node);
80865
80896
  checkGrammarForGenerator(node);
80866
80897
  checkCollisionsForDeclarationName(node, node.name);
@@ -80894,10 +80925,13 @@ var ts;
80894
80925
  checkSourceElement(node.typeExpression);
80895
80926
  }
80896
80927
  function checkJSDocFunctionType(node) {
80897
- if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
80898
- reportImplicitAny(node, anyType);
80899
- }
80928
+ addLazyDiagnostic(checkJSDocFunctionTypeImplicitAny);
80900
80929
  checkSignatureDeclaration(node);
80930
+ function checkJSDocFunctionTypeImplicitAny() {
80931
+ if (!node.type && !ts.isJSDocConstructSignature(node)) {
80932
+ reportImplicitAny(node, anyType);
80933
+ }
80934
+ }
80901
80935
  }
80902
80936
  function checkJSDocImplementsTag(node) {
80903
80937
  var classLike = ts.getEffectiveJSDocHost(node);
@@ -80978,19 +81012,7 @@ var ts;
80978
81012
  var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body;
80979
81013
  checkSourceElement(body);
80980
81014
  checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
80981
- if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
80982
- // Report an implicit any error if there is no body, no explicit return type, and node is not a private method
80983
- // in an ambient context
80984
- if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
80985
- reportImplicitAny(node, anyType);
80986
- }
80987
- if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
80988
- // A generator with a body and no type annotation can still cause errors. It can error if the
80989
- // yielded values have no common supertype, or it can give an implicit any error if it has no
80990
- // yielded values. The only way to trigger these errors is to try checking its return type.
80991
- getReturnTypeOfSignature(getSignatureFromDeclaration(node));
80992
- }
80993
- }
81015
+ addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics);
80994
81016
  // A js function declaration can have a @type tag instead of a return type node, but that type must have a call signature
80995
81017
  if (ts.isInJSFile(node)) {
80996
81018
  var typeTag = ts.getJSDocTypeTag(node);
@@ -80998,10 +81020,26 @@ var ts;
80998
81020
  error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
80999
81021
  }
81000
81022
  }
81023
+ function checkFunctionOrMethodDeclarationDiagnostics() {
81024
+ if (!ts.getEffectiveReturnTypeNode(node)) {
81025
+ // Report an implicit any error if there is no body, no explicit return type, and node is not a private method
81026
+ // in an ambient context
81027
+ if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
81028
+ reportImplicitAny(node, anyType);
81029
+ }
81030
+ if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
81031
+ // A generator with a body and no type annotation can still cause errors. It can error if the
81032
+ // yielded values have no common supertype, or it can give an implicit any error if it has no
81033
+ // yielded values. The only way to trigger these errors is to try checking its return type.
81034
+ getReturnTypeOfSignature(getSignatureFromDeclaration(node));
81035
+ }
81036
+ }
81037
+ }
81001
81038
  }
81002
81039
  function registerForUnusedIdentifiersCheck(node) {
81003
- // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
81004
- if (produceDiagnostics) {
81040
+ addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
81041
+ function registerForUnusedIdentifiersCheckDiagnostics() {
81042
+ // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
81005
81043
  var sourceFile = ts.getSourceFileOfNode(node);
81006
81044
  var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
81007
81045
  if (!potentiallyUnusedIdentifiers) {
@@ -82775,26 +82813,31 @@ var ts;
82775
82813
  hasDuplicateDefaultClause = true;
82776
82814
  }
82777
82815
  }
82778
- if (produceDiagnostics && clause.kind === 289 /* CaseClause */) {
82779
- // TypeScript 1.0 spec (April 2014): 5.9
82780
- // In a 'switch' statement, each 'case' expression must be of a type that is comparable
82781
- // to or from the type of the 'switch' expression.
82782
- var caseType = checkExpression(clause.expression);
82783
- var caseIsLiteral = isLiteralType(caseType);
82784
- var comparedExpressionType = expressionType;
82785
- if (!caseIsLiteral || !expressionIsLiteral) {
82786
- caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
82787
- comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
82788
- }
82789
- if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
82790
- // expressionType is not comparable to caseType, try the reversed check and report errors if it fails
82791
- checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
82792
- }
82816
+ if (clause.kind === 289 /* CaseClause */) {
82817
+ addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause));
82793
82818
  }
82794
82819
  ts.forEach(clause.statements, checkSourceElement);
82795
82820
  if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
82796
82821
  error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
82797
82822
  }
82823
+ function createLazyCaseClauseDiagnostics(clause) {
82824
+ return function () {
82825
+ // TypeScript 1.0 spec (April 2014): 5.9
82826
+ // In a 'switch' statement, each 'case' expression must be of a type that is comparable
82827
+ // to or from the type of the 'switch' expression.
82828
+ var caseType = checkExpression(clause.expression);
82829
+ var caseIsLiteral = isLiteralType(caseType);
82830
+ var comparedExpressionType = expressionType;
82831
+ if (!caseIsLiteral || !expressionIsLiteral) {
82832
+ caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
82833
+ comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
82834
+ }
82835
+ if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
82836
+ // expressionType is not comparable to caseType, try the reversed check and report errors if it fails
82837
+ checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
82838
+ }
82839
+ };
82840
+ }
82798
82841
  });
82799
82842
  if (node.caseBlock.locals) {
82800
82843
  registerForUnusedIdentifiersCheck(node.caseBlock);
@@ -83015,26 +83058,29 @@ var ts;
83015
83058
  * Check each type parameter and check that type parameters have no duplicate type parameter declarations
83016
83059
  */
83017
83060
  function checkTypeParameters(typeParameterDeclarations) {
83061
+ var seenDefault = false;
83018
83062
  if (typeParameterDeclarations) {
83019
- var seenDefault = false;
83020
83063
  for (var i = 0; i < typeParameterDeclarations.length; i++) {
83021
83064
  var node = typeParameterDeclarations[i];
83022
83065
  checkTypeParameter(node);
83023
- if (produceDiagnostics) {
83024
- if (node.default) {
83025
- seenDefault = true;
83026
- checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
83027
- }
83028
- else if (seenDefault) {
83029
- error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
83030
- }
83031
- for (var j = 0; j < i; j++) {
83032
- if (typeParameterDeclarations[j].symbol === node.symbol) {
83033
- error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
83034
- }
83066
+ addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
83067
+ }
83068
+ }
83069
+ function createCheckTypeParameterDiagnostic(node, i) {
83070
+ return function () {
83071
+ if (node.default) {
83072
+ seenDefault = true;
83073
+ checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
83074
+ }
83075
+ else if (seenDefault) {
83076
+ error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
83077
+ }
83078
+ for (var j = 0; j < i; j++) {
83079
+ if (typeParameterDeclarations[j].symbol === node.symbol) {
83080
+ error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
83035
83081
  }
83036
83082
  }
83037
- }
83083
+ };
83038
83084
  }
83039
83085
  }
83040
83086
  /** Check that type parameter defaults only reference previously declared type parameters */
@@ -83166,85 +83212,90 @@ var ts;
83166
83212
  if (extendsNode && extendsNode !== baseTypeNode) {
83167
83213
  checkExpression(extendsNode.expression);
83168
83214
  }
83169
- var baseTypes = getBaseTypes(type);
83170
- if (baseTypes.length && produceDiagnostics) {
83171
- var baseType_1 = baseTypes[0];
83172
- var baseConstructorType = getBaseConstructorTypeOfClass(type);
83173
- var staticBaseType = getApparentType(baseConstructorType);
83174
- checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
83175
- checkSourceElement(baseTypeNode.expression);
83176
- if (ts.some(baseTypeNode.typeArguments)) {
83177
- ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
83178
- for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
83179
- var constructor = _a[_i];
83180
- if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
83181
- break;
83215
+ var baseTypes_2 = getBaseTypes(type);
83216
+ if (baseTypes_2.length) {
83217
+ addLazyDiagnostic(function () {
83218
+ var baseType = baseTypes_2[0];
83219
+ var baseConstructorType = getBaseConstructorTypeOfClass(type);
83220
+ var staticBaseType = getApparentType(baseConstructorType);
83221
+ checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
83222
+ checkSourceElement(baseTypeNode.expression);
83223
+ if (ts.some(baseTypeNode.typeArguments)) {
83224
+ ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
83225
+ for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
83226
+ var constructor = _a[_i];
83227
+ if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
83228
+ break;
83229
+ }
83182
83230
  }
83183
83231
  }
83184
- }
83185
- var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
83186
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83187
- issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
83188
- }
83189
- else {
83190
- // Report static side error only when instance type is assignable
83191
- checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
83192
- }
83193
- if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
83194
- if (!isMixinConstructorType(staticType)) {
83195
- error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
83232
+ var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
83233
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83234
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
83196
83235
  }
83197
83236
  else {
83198
- var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
83199
- if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
83200
- 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);
83237
+ // Report static side error only when instance type is assignable
83238
+ checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
83239
+ }
83240
+ if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
83241
+ if (!isMixinConstructorType(staticType)) {
83242
+ error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
83243
+ }
83244
+ else {
83245
+ var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
83246
+ if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
83247
+ 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);
83248
+ }
83201
83249
  }
83202
83250
  }
83203
- }
83204
- if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
83205
- // When the static base type is a "class-like" constructor function (but not actually a class), we verify
83206
- // that all instantiated base constructor signatures return the same type.
83207
- var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
83208
- if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
83209
- error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
83251
+ if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
83252
+ // When the static base type is a "class-like" constructor function (but not actually a class), we verify
83253
+ // that all instantiated base constructor signatures return the same type.
83254
+ var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
83255
+ if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType); })) {
83256
+ error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
83257
+ }
83210
83258
  }
83211
- }
83212
- checkKindsOfPropertyMemberOverrides(type, baseType_1);
83259
+ checkKindsOfPropertyMemberOverrides(type, baseType);
83260
+ });
83213
83261
  }
83214
83262
  }
83215
83263
  checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
83216
83264
  var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
83217
83265
  if (implementedTypeNodes) {
83218
- for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
83219
- var typeRefNode = implementedTypeNodes_1[_b];
83266
+ for (var _i = 0, implementedTypeNodes_1 = implementedTypeNodes; _i < implementedTypeNodes_1.length; _i++) {
83267
+ var typeRefNode = implementedTypeNodes_1[_i];
83220
83268
  if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
83221
83269
  error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
83222
83270
  }
83223
83271
  checkTypeReferenceNode(typeRefNode);
83224
- if (produceDiagnostics) {
83225
- var t = getReducedType(getTypeFromTypeNode(typeRefNode));
83226
- if (!isErrorType(t)) {
83227
- if (isValidBaseType(t)) {
83228
- var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
83229
- ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
83230
- ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
83231
- var baseWithThis = getTypeWithThisArgument(t, type.thisType);
83232
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83233
- issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
83234
- }
83235
- }
83236
- else {
83237
- error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
83238
- }
83239
- }
83240
- }
83272
+ addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
83241
83273
  }
83242
83274
  }
83243
- if (produceDiagnostics) {
83275
+ addLazyDiagnostic(function () {
83244
83276
  checkIndexConstraints(type, symbol);
83245
83277
  checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
83246
83278
  checkTypeForDuplicateIndexSignatures(node);
83247
83279
  checkPropertyInitialization(node);
83280
+ });
83281
+ function createImplementsDiagnostics(typeRefNode) {
83282
+ return function () {
83283
+ var t = getReducedType(getTypeFromTypeNode(typeRefNode));
83284
+ if (!isErrorType(t)) {
83285
+ if (isValidBaseType(t)) {
83286
+ var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
83287
+ ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
83288
+ ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
83289
+ var baseWithThis = getTypeWithThisArgument(t, type.thisType);
83290
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
83291
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
83292
+ }
83293
+ }
83294
+ else {
83295
+ error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
83296
+ }
83297
+ }
83298
+ };
83248
83299
  }
83249
83300
  }
83250
83301
  function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
@@ -83568,8 +83619,8 @@ var ts;
83568
83619
  ts.forEach(properties, function (p) {
83569
83620
  seen.set(p.escapedName, p);
83570
83621
  });
83571
- for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
83572
- var base = baseTypes_2[_i];
83622
+ for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
83623
+ var base = baseTypes_3[_i];
83573
83624
  var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
83574
83625
  for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
83575
83626
  var prop = properties_4[_a];
@@ -83591,8 +83642,8 @@ var ts;
83591
83642
  seen.set(p.escapedName, { prop: p, containingType: type });
83592
83643
  });
83593
83644
  var ok = true;
83594
- for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
83595
- var base = baseTypes_3[_i];
83645
+ for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
83646
+ var base = baseTypes_4[_i];
83596
83647
  var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
83597
83648
  for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
83598
83649
  var prop = properties_6[_a];
@@ -83676,7 +83727,7 @@ var ts;
83676
83727
  if (!checkGrammarDecoratorsAndModifiers(node))
83677
83728
  checkGrammarInterfaceDeclaration(node);
83678
83729
  checkTypeParameters(node.typeParameters);
83679
- if (produceDiagnostics) {
83730
+ addLazyDiagnostic(function () {
83680
83731
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
83681
83732
  checkExportsOnMergedDeclarations(node);
83682
83733
  var symbol = getSymbolOfNode(node);
@@ -83696,7 +83747,7 @@ var ts;
83696
83747
  }
83697
83748
  }
83698
83749
  checkObjectTypeForDuplicateDeclarations(node);
83699
- }
83750
+ });
83700
83751
  ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
83701
83752
  if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
83702
83753
  error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
@@ -83704,10 +83755,10 @@ var ts;
83704
83755
  checkTypeReferenceNode(heritageElement);
83705
83756
  });
83706
83757
  ts.forEach(node.members, checkSourceElement);
83707
- if (produceDiagnostics) {
83758
+ addLazyDiagnostic(function () {
83708
83759
  checkTypeForDuplicateIndexSignatures(node);
83709
83760
  registerForUnusedIdentifiersCheck(node);
83710
- }
83761
+ });
83711
83762
  }
83712
83763
  function checkTypeAliasDeclaration(node) {
83713
83764
  // Grammar checking
@@ -83896,9 +83947,9 @@ var ts;
83896
83947
  ts.isStringLiteralLike(node.argumentExpression);
83897
83948
  }
83898
83949
  function checkEnumDeclaration(node) {
83899
- if (!produceDiagnostics) {
83900
- return;
83901
- }
83950
+ addLazyDiagnostic(function () { return checkEnumDeclarationWorker(node); });
83951
+ }
83952
+ function checkEnumDeclarationWorker(node) {
83902
83953
  // Grammar checking
83903
83954
  checkGrammarDecoratorsAndModifiers(node);
83904
83955
  checkCollisionsForDeclarationName(node, node.name);
@@ -83978,7 +84029,14 @@ var ts;
83978
84029
  }
83979
84030
  }
83980
84031
  function checkModuleDeclaration(node) {
83981
- if (produceDiagnostics) {
84032
+ if (node.body) {
84033
+ checkSourceElement(node.body);
84034
+ if (!ts.isGlobalScopeAugmentation(node)) {
84035
+ registerForUnusedIdentifiersCheck(node);
84036
+ }
84037
+ }
84038
+ addLazyDiagnostic(checkModuleDeclarationDiagnostics);
84039
+ function checkModuleDeclarationDiagnostics() {
83982
84040
  // Grammar checking
83983
84041
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
83984
84042
  var inAmbientContext = node.flags & 8388608 /* Ambient */;
@@ -84061,12 +84119,6 @@ var ts;
84061
84119
  }
84062
84120
  }
84063
84121
  }
84064
- if (node.body) {
84065
- checkSourceElement(node.body);
84066
- if (!ts.isGlobalScopeAugmentation(node)) {
84067
- registerForUnusedIdentifiersCheck(node);
84068
- }
84069
- }
84070
84122
  }
84071
84123
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
84072
84124
  var _a;
@@ -85003,13 +85055,16 @@ var ts;
85003
85055
  if (ts.isExternalOrCommonJsModule(node)) {
85004
85056
  registerForUnusedIdentifiersCheck(node);
85005
85057
  }
85006
- if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
85007
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
85008
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
85009
- diagnostics.add(diag);
85010
- }
85011
- });
85012
- }
85058
+ addLazyDiagnostic(function () {
85059
+ // This relies on the results of other lazy diagnostics, so must be computed after them
85060
+ if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
85061
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
85062
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
85063
+ diagnostics.add(diag);
85064
+ }
85065
+ });
85066
+ }
85067
+ });
85013
85068
  if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
85014
85069
  !node.isDeclarationFile &&
85015
85070
  ts.isExternalModule(node)) {
@@ -85049,15 +85104,35 @@ var ts;
85049
85104
  cancellationToken = undefined;
85050
85105
  }
85051
85106
  }
85107
+ function ensurePendingDiagnosticWorkComplete() {
85108
+ // Invoke any existing lazy diagnostics to add them, clear the backlog of diagnostics
85109
+ for (var _i = 0, deferredDiagnosticsCallbacks_1 = deferredDiagnosticsCallbacks; _i < deferredDiagnosticsCallbacks_1.length; _i++) {
85110
+ var cb = deferredDiagnosticsCallbacks_1[_i];
85111
+ cb();
85112
+ }
85113
+ deferredDiagnosticsCallbacks = [];
85114
+ }
85115
+ function checkSourceFileWithEagerDiagnostics(sourceFile) {
85116
+ ensurePendingDiagnosticWorkComplete();
85117
+ // then setup diagnostics for immediate invocation (as we are about to collect them, and
85118
+ // this avoids the overhead of longer-lived callbacks we don't need to allocate)
85119
+ // This also serves to make the shift to possibly lazy diagnostics transparent to serial command-line scenarios
85120
+ // (as in those cases, all the diagnostics will still be computed as the appropriate place in the tree,
85121
+ // thus much more likely retaining the same union ordering as before we had lazy diagnostics)
85122
+ var oldAddLazyDiagnostics = addLazyDiagnostic;
85123
+ addLazyDiagnostic = function (cb) { return cb(); };
85124
+ checkSourceFile(sourceFile);
85125
+ addLazyDiagnostic = oldAddLazyDiagnostics;
85126
+ }
85052
85127
  function getDiagnosticsWorker(sourceFile) {
85053
- throwIfNonDiagnosticsProducing();
85054
85128
  if (sourceFile) {
85129
+ ensurePendingDiagnosticWorkComplete();
85055
85130
  // Some global diagnostics are deferred until they are needed and
85056
85131
  // may not be reported in the first call to getGlobalDiagnostics.
85057
85132
  // We should catch these changes and report them.
85058
85133
  var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
85059
85134
  var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
85060
- checkSourceFile(sourceFile);
85135
+ checkSourceFileWithEagerDiagnostics(sourceFile);
85061
85136
  var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
85062
85137
  var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
85063
85138
  if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
@@ -85075,18 +85150,13 @@ var ts;
85075
85150
  }
85076
85151
  // Global diagnostics are always added when a file is not provided to
85077
85152
  // getDiagnostics
85078
- ts.forEach(host.getSourceFiles(), checkSourceFile);
85153
+ ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
85079
85154
  return diagnostics.getDiagnostics();
85080
85155
  }
85081
85156
  function getGlobalDiagnostics() {
85082
- throwIfNonDiagnosticsProducing();
85157
+ ensurePendingDiagnosticWorkComplete();
85083
85158
  return diagnostics.getGlobalDiagnostics();
85084
85159
  }
85085
- function throwIfNonDiagnosticsProducing() {
85086
- if (!produceDiagnostics) {
85087
- throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
85088
- }
85089
- }
85090
85160
  // Language service support
85091
85161
  function getSymbolsInScope(location, meaning) {
85092
85162
  if (location.flags & 16777216 /* InWithStatement */) {
@@ -115560,8 +115630,7 @@ var ts;
115560
115630
  var files;
115561
115631
  var symlinks;
115562
115632
  var commonSourceDirectory;
115563
- var diagnosticsProducingTypeChecker;
115564
- var noDiagnosticsTypeChecker;
115633
+ var typeChecker;
115565
115634
  var classifiableNames;
115566
115635
  var ambientModuleNameToUnmodifiedFileName = new ts.Map();
115567
115636
  var fileReasons = ts.createMultiMap();
@@ -115807,21 +115876,19 @@ var ts;
115807
115876
  getProgramDiagnostics: getProgramDiagnostics,
115808
115877
  getTypeChecker: getTypeChecker,
115809
115878
  getClassifiableNames: getClassifiableNames,
115810
- getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
115811
115879
  getCommonSourceDirectory: getCommonSourceDirectory,
115812
115880
  emit: emit,
115813
115881
  getCurrentDirectory: function () { return currentDirectory; },
115814
- getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
115815
- getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
115816
- getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
115817
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
115818
- getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
115819
- getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
115882
+ getNodeCount: function () { return getTypeChecker().getNodeCount(); },
115883
+ getIdentifierCount: function () { return getTypeChecker().getIdentifierCount(); },
115884
+ getSymbolCount: function () { return getTypeChecker().getSymbolCount(); },
115885
+ getTypeCount: function () { return getTypeChecker().getTypeCount(); },
115886
+ getInstantiationCount: function () { return getTypeChecker().getInstantiationCount(); },
115887
+ getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
115820
115888
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
115821
115889
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
115822
115890
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
115823
115891
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
115824
- dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
115825
115892
  getSourceFileFromReference: getSourceFileFromReference,
115826
115893
  getLibFileFromReference: getLibFileFromReference,
115827
115894
  sourceFileToPackageName: sourceFileToPackageName,
@@ -116410,14 +116477,8 @@ var ts;
116410
116477
  return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); });
116411
116478
  }
116412
116479
  }
116413
- function getDiagnosticsProducingTypeChecker() {
116414
- return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true));
116415
- }
116416
- function dropDiagnosticsProducingTypeChecker() {
116417
- diagnosticsProducingTypeChecker = undefined;
116418
- }
116419
116480
  function getTypeChecker() {
116420
- return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false));
116481
+ return typeChecker || (typeChecker = ts.createTypeChecker(program));
116421
116482
  }
116422
116483
  function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
116423
116484
  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);
@@ -116442,7 +116503,7 @@ var ts;
116442
116503
  // This is because in the -out scenario all files need to be emitted, and therefore all
116443
116504
  // files need to be type checked. And the way to specify that all files need to be type
116444
116505
  // checked is to not pass the file to getEmitResolver.
116445
- var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
116506
+ var emitResolver = getTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
116446
116507
  ts.performance.mark("beforeEmit");
116447
116508
  var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles,
116448
116509
  /*onlyBuildInfo*/ false, forceDtsEmit);
@@ -116522,15 +116583,7 @@ var ts;
116522
116583
  if (e instanceof ts.OperationCanceledException) {
116523
116584
  // We were canceled while performing the operation. Because our type checker
116524
116585
  // might be a bad state, we need to throw it away.
116525
- //
116526
- // Note: we are overly aggressive here. We do not actually *have* to throw away
116527
- // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
116528
- // the lifetimes of these two TypeCheckers the same. Also, we generally only
116529
- // cancel when the user has made a change anyways. And, in that case, we (the
116530
- // program instance) will get thrown away anyways. So trying to keep one of
116531
- // these type checkers alive doesn't serve much purpose.
116532
- noDiagnosticsTypeChecker = undefined;
116533
- diagnosticsProducingTypeChecker = undefined;
116586
+ typeChecker = undefined;
116534
116587
  }
116535
116588
  throw e;
116536
116589
  }
@@ -116546,7 +116599,7 @@ var ts;
116546
116599
  if (ts.skipTypeChecking(sourceFile, options, program)) {
116547
116600
  return ts.emptyArray;
116548
116601
  }
116549
- var typeChecker = getDiagnosticsProducingTypeChecker();
116602
+ var typeChecker = getTypeChecker();
116550
116603
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
116551
116604
  var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
116552
116605
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
@@ -116598,7 +116651,7 @@ var ts;
116598
116651
  }
116599
116652
  function getSuggestionDiagnostics(sourceFile, cancellationToken) {
116600
116653
  return runWithCancellationToken(function () {
116601
- return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
116654
+ return getTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
116602
116655
  });
116603
116656
  }
116604
116657
  /**
@@ -116818,7 +116871,7 @@ var ts;
116818
116871
  }
116819
116872
  function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
116820
116873
  return runWithCancellationToken(function () {
116821
- var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
116874
+ var resolver = getTypeChecker().getEmitResolver(sourceFile, cancellationToken);
116822
116875
  // Don't actually write any files since we're just getting diagnostics.
116823
116876
  return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
116824
116877
  });
@@ -116856,7 +116909,7 @@ var ts;
116856
116909
  return diagnostics;
116857
116910
  }
116858
116911
  function getGlobalDiagnostics() {
116859
- return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
116912
+ return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
116860
116913
  }
116861
116914
  function getConfigFileParsingDiagnostics() {
116862
116915
  return configFileParsingDiagnostics || ts.emptyArray;