typescript 4.7.0-dev.20220323 → 4.7.0-dev.20220327

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220323";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220327";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -5592,6 +5592,7 @@ var ts;
5592
5592
  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}'.", undefined, true),
5593
5593
  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."),
5594
5594
  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."),
5595
+ 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."),
5595
5596
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
5596
5597
  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."),
5597
5598
  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."),
@@ -36315,15 +36316,18 @@ var ts;
36315
36316
  var saveExceptionTarget = currentExceptionTarget;
36316
36317
  var saveActiveLabelList = activeLabelList;
36317
36318
  var saveHasExplicitReturn = hasExplicitReturn;
36318
- var isIIFE = containerFlags & 16 && !ts.hasSyntacticModifier(node, 256) &&
36319
- !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
36320
- if (!isIIFE) {
36319
+ var isImmediatelyInvoked = (containerFlags & 16 &&
36320
+ !ts.hasSyntacticModifier(node, 256) &&
36321
+ !node.asteriskToken &&
36322
+ !!ts.getImmediatelyInvokedFunctionExpression(node)) ||
36323
+ node.kind === 170;
36324
+ if (!isImmediatelyInvoked) {
36321
36325
  currentFlow = initFlowNode({ flags: 2 });
36322
36326
  if (containerFlags & (16 | 128)) {
36323
36327
  currentFlow.node = node;
36324
36328
  }
36325
36329
  }
36326
- currentReturnTarget = isIIFE || node.kind === 171 || node.kind === 170 || (ts.isInJSFile(node) && (node.kind === 256 || node.kind === 213)) ? createBranchLabel() : undefined;
36330
+ currentReturnTarget = isImmediatelyInvoked || node.kind === 171 || (ts.isInJSFile(node) && (node.kind === 256 || node.kind === 213)) ? createBranchLabel() : undefined;
36327
36331
  currentExceptionTarget = undefined;
36328
36332
  currentBreakTarget = undefined;
36329
36333
  currentContinueTarget = undefined;
@@ -36348,7 +36352,7 @@ var ts;
36348
36352
  node.returnFlowNode = currentFlow;
36349
36353
  }
36350
36354
  }
36351
- if (!isIIFE) {
36355
+ if (!isImmediatelyInvoked) {
36352
36356
  currentFlow = saveCurrentFlow;
36353
36357
  }
36354
36358
  currentBreakTarget = saveBreakTarget;
@@ -38865,7 +38869,7 @@ var ts;
38865
38869
  (preserveConstEnums && moduleState === 2);
38866
38870
  }
38867
38871
  ts.isInstantiatedModule = isInstantiatedModule;
38868
- function createTypeChecker(host, produceDiagnostics) {
38872
+ function createTypeChecker(host) {
38869
38873
  var getPackagesMap = ts.memoize(function () {
38870
38874
  var map = new ts.Map();
38871
38875
  host.getSourceFiles().forEach(function (sf) {
@@ -38878,6 +38882,10 @@ var ts;
38878
38882
  });
38879
38883
  return map;
38880
38884
  });
38885
+ var deferredDiagnosticsCallbacks = [];
38886
+ var addLazyDiagnostic = function (arg) {
38887
+ deferredDiagnosticsCallbacks.push(arg);
38888
+ };
38881
38889
  var cancellationToken;
38882
38890
  var requestedExternalEmitHelpers;
38883
38891
  var externalHelpersModule;
@@ -39220,7 +39228,7 @@ var ts;
39220
39228
  var diagnostics;
39221
39229
  try {
39222
39230
  cancellationToken = ct;
39223
- checkSourceFile(file);
39231
+ checkSourceFileWithEagerDiagnostics(file);
39224
39232
  ts.Debug.assert(!!(getNodeLinks(file).flags & 1));
39225
39233
  diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
39226
39234
  checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
@@ -40374,91 +40382,95 @@ var ts;
40374
40382
  }
40375
40383
  }
40376
40384
  if (!result) {
40377
- if (nameNotFoundMessage && produceDiagnostics) {
40378
- if (!errorLocation ||
40379
- !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
40380
- !checkAndReportErrorForExtendingInterface(errorLocation) &&
40381
- !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
40382
- !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
40383
- !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
40384
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
40385
- !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
40386
- var suggestion = void 0;
40387
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
40388
- suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
40389
- var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
40390
- if (isGlobalScopeAugmentationDeclaration) {
40391
- suggestion = undefined;
40392
- }
40393
- if (suggestion) {
40394
- var suggestionName = symbolToString(suggestion);
40395
- var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, false);
40396
- var message = meaning === 1920 || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
40397
- : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
40398
- : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
40399
- var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
40400
- addErrorOrSuggestion(!isUncheckedJS, diagnostic);
40401
- if (suggestion.valueDeclaration) {
40402
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
40385
+ if (nameNotFoundMessage) {
40386
+ addLazyDiagnostic(function () {
40387
+ if (!errorLocation ||
40388
+ !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
40389
+ !checkAndReportErrorForExtendingInterface(errorLocation) &&
40390
+ !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
40391
+ !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
40392
+ !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
40393
+ !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
40394
+ !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
40395
+ var suggestion = void 0;
40396
+ if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
40397
+ suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
40398
+ var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
40399
+ if (isGlobalScopeAugmentationDeclaration) {
40400
+ suggestion = undefined;
40403
40401
  }
40404
- }
40405
- }
40406
- if (!suggestion) {
40407
- if (nameArg) {
40408
- var lib = getSuggestedLibForNonExistentName(nameArg);
40409
- if (lib) {
40410
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
40402
+ if (suggestion) {
40403
+ var suggestionName = symbolToString(suggestion);
40404
+ var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, false);
40405
+ var message = meaning === 1920 || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
40406
+ : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
40407
+ : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
40408
+ var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
40409
+ addErrorOrSuggestion(!isUncheckedJS, diagnostic);
40410
+ if (suggestion.valueDeclaration) {
40411
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
40412
+ }
40411
40413
  }
40412
- else {
40413
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
40414
+ }
40415
+ if (!suggestion) {
40416
+ if (nameArg) {
40417
+ var lib = getSuggestedLibForNonExistentName(nameArg);
40418
+ if (lib) {
40419
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
40420
+ }
40421
+ else {
40422
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
40423
+ }
40414
40424
  }
40415
40425
  }
40426
+ suggestionCount++;
40416
40427
  }
40417
- suggestionCount++;
40418
- }
40428
+ });
40419
40429
  }
40420
40430
  return undefined;
40421
40431
  }
40422
- if (nameNotFoundMessage && produceDiagnostics) {
40423
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) {
40424
- var propertyName = propertyWithInvalidInitializer.name;
40425
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
40426
- return undefined;
40427
- }
40428
- if (errorLocation &&
40429
- (meaning & 2 ||
40430
- ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
40431
- var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
40432
- if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
40433
- checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
40434
- }
40435
- }
40436
- if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
40437
- var merged = getMergedSymbol(result);
40438
- if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
40439
- 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));
40432
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) {
40433
+ var propertyName = propertyWithInvalidInitializer.name;
40434
+ error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
40435
+ return undefined;
40436
+ }
40437
+ if (nameNotFoundMessage) {
40438
+ addLazyDiagnostic(function () {
40439
+ if (errorLocation &&
40440
+ (meaning & 2 ||
40441
+ ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
40442
+ var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
40443
+ if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
40444
+ checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
40445
+ }
40440
40446
  }
40441
- }
40442
- if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
40443
- var candidate = getMergedSymbol(getLateBoundSymbol(result));
40444
- var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
40445
- if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
40446
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
40447
+ if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
40448
+ var merged = getMergedSymbol(result);
40449
+ if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
40450
+ 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));
40451
+ }
40447
40452
  }
40448
- else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
40449
- error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
40453
+ if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
40454
+ var candidate = getMergedSymbol(getLateBoundSymbol(result));
40455
+ var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
40456
+ if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
40457
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
40458
+ }
40459
+ else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
40460
+ error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
40461
+ }
40450
40462
  }
40451
- }
40452
- if (result && errorLocation && meaning & 111551 && result.flags & 2097152 && !(result.flags & 111551) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
40453
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
40454
- if (typeOnlyDeclaration) {
40455
- var message = typeOnlyDeclaration.kind === 275
40456
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
40457
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
40458
- var unescapedName = ts.unescapeLeadingUnderscores(name);
40459
- addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
40463
+ if (result && errorLocation && meaning & 111551 && result.flags & 2097152 && !(result.flags & 111551) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
40464
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
40465
+ if (typeOnlyDeclaration) {
40466
+ var message = typeOnlyDeclaration.kind === 275
40467
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
40468
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
40469
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
40470
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
40471
+ }
40460
40472
  }
40461
- }
40473
+ });
40462
40474
  }
40463
40475
  return result;
40464
40476
  }
@@ -41920,9 +41932,7 @@ var ts;
41920
41932
  var result = new Type(checker, flags);
41921
41933
  typeCount++;
41922
41934
  result.id = typeCount;
41923
- if (produceDiagnostics) {
41924
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
41925
- }
41935
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
41926
41936
  return result;
41927
41937
  }
41928
41938
  function createOriginType(flags) {
@@ -46170,11 +46180,16 @@ var ts;
46170
46180
  }
46171
46181
  var type = resolveTypeOfAccessors(symbol, writing);
46172
46182
  if (!popTypeResolution()) {
46173
- type = anyType;
46174
- if (noImplicitAny) {
46175
- var getter = ts.getDeclarationOfKind(symbol, 172);
46176
- error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
46183
+ var getter = ts.getDeclarationOfKind(symbol, 172);
46184
+ if (getter) {
46185
+ if (ts.getEffectiveTypeAnnotationNode(getter)) {
46186
+ error(getter.name, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
46187
+ }
46188
+ else if (noImplicitAny) {
46189
+ error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
46190
+ }
46177
46191
  }
46192
+ type = anyType;
46178
46193
  }
46179
46194
  return type;
46180
46195
  }
@@ -53584,6 +53599,7 @@ var ts;
53584
53599
  return 0;
53585
53600
  }
53586
53601
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
53602
+ var _a, _b;
53587
53603
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
53588
53604
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
53589
53605
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -53622,6 +53638,9 @@ var ts;
53622
53638
  return;
53623
53639
  }
53624
53640
  reportRelationError(headMessage, source, target);
53641
+ if (strictNullChecks && source.flags & 8650752 && ((_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))) {
53642
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
53643
+ }
53625
53644
  }
53626
53645
  function traceUnionsOrIntersectionsTooLarge(source, target) {
53627
53646
  if (!ts.tracing) {
@@ -54251,17 +54270,17 @@ var ts;
54251
54270
  if (sourceFlags & 8650752) {
54252
54271
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
54253
54272
  var constraint = getConstraintOfType(source);
54254
- if (!constraint || (sourceFlags & 262144 && constraint.flags & 1)) {
54273
+ if (!strictNullChecks && (!constraint || (sourceFlags & 262144 && constraint.flags & 1))) {
54255
54274
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
54256
54275
  resetErrorInfo(saveErrorInfo);
54257
54276
  return result;
54258
54277
  }
54259
54278
  }
54260
- else if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54279
+ else if (constraint && (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState))) {
54261
54280
  resetErrorInfo(saveErrorInfo);
54262
54281
  return result;
54263
54282
  }
54264
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
54283
+ else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState))) {
54265
54284
  resetErrorInfo(saveErrorInfo);
54266
54285
  return result;
54267
54286
  }
@@ -56036,11 +56055,13 @@ var ts;
56036
56055
  errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
56037
56056
  }
56038
56057
  function reportErrorsFromWidening(declaration, type, wideningKind) {
56039
- if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 65536 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
56040
- if (!reportWideningErrorsInType(type)) {
56041
- reportImplicitAny(declaration, type, wideningKind);
56058
+ addLazyDiagnostic(function () {
56059
+ if (noImplicitAny && ts.getObjectFlags(type) & 65536 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
56060
+ if (!reportWideningErrorsInType(type)) {
56061
+ reportImplicitAny(declaration, type, wideningKind);
56062
+ }
56042
56063
  }
56043
- }
56064
+ });
56044
56065
  }
56045
56066
  function applyToParameterTypes(source, target, callback) {
56046
56067
  var sourceCount = getParameterCount(source);
@@ -60204,21 +60225,11 @@ var ts;
60204
60225
  }
60205
60226
  return false;
60206
60227
  }
60207
- function uniqueStrings(strings) {
60208
- var unique = new ts.Set(strings);
60209
- var result = [];
60210
- unique.forEach(function (str) { return result.push(str); });
60211
- return result;
60212
- }
60213
60228
  function discriminateContextualTypeByObjectMembers(node, contextualType) {
60214
- return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(uniqueStrings(ts.flatMap(contextualType.types, function (memberType) {
60215
- return ts.map(ts.filter(getPropertiesOfType(memberType), function (s) { var _a; return !!(s.flags & 16777216) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return s.escapedName; });
60216
- })), function (name) { return [function () { return undefinedType; }, name]; })), isTypeAssignableTo, contextualType);
60229
+ return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
60217
60230
  }
60218
60231
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
60219
- return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(uniqueStrings(ts.flatMap(contextualType.types, function (memberType) {
60220
- return ts.map(ts.filter(getPropertiesOfType(memberType), function (s) { var _a; return !!(s.flags & 16777216) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return s.escapedName; });
60221
- })), function (name) { return [function () { return undefinedType; }, name]; })), isTypeAssignableTo, contextualType);
60232
+ return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
60222
60233
  }
60223
60234
  function getApparentTypeOfContextualType(node, contextFlags) {
60224
60235
  var contextualType = ts.isObjectLiteralMethod(node) ?
@@ -61812,6 +61823,7 @@ var ts;
61812
61823
  && !isOptionalPropertyDeclaration(valueDeclaration)
61813
61824
  && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
61814
61825
  && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
61826
+ && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32)
61815
61827
  && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
61816
61828
  diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
61817
61829
  }
@@ -62875,7 +62887,7 @@ var ts;
62875
62887
  var isTaggedTemplate = node.kind === 210;
62876
62888
  var isDecorator = node.kind === 165;
62877
62889
  var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
62878
- var reportErrors = !candidatesOutArray && produceDiagnostics;
62890
+ var reportErrors = !candidatesOutArray;
62879
62891
  var typeArguments;
62880
62892
  if (!isDecorator) {
62881
62893
  typeArguments = node.typeArguments;
@@ -63955,11 +63967,13 @@ var ts;
63955
63967
  checkSourceElement(type);
63956
63968
  exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
63957
63969
  var targetType = getTypeFromTypeNode(type);
63958
- if (produceDiagnostics && !isErrorType(targetType)) {
63959
- var widenedType = getWidenedType(exprType);
63960
- if (!isTypeComparableTo(targetType, widenedType)) {
63961
- 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);
63962
- }
63970
+ if (!isErrorType(targetType)) {
63971
+ addLazyDiagnostic(function () {
63972
+ var widenedType = getWidenedType(exprType);
63973
+ if (!isTypeComparableTo(targetType, widenedType)) {
63974
+ 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);
63975
+ }
63976
+ });
63963
63977
  }
63964
63978
  return targetType;
63965
63979
  }
@@ -64643,39 +64657,40 @@ var ts;
64643
64657
  }
64644
64658
  }
64645
64659
  function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
64646
- if (!produceDiagnostics) {
64647
- return;
64648
- }
64649
- var functionFlags = ts.getFunctionFlags(func);
64650
- var type = returnType && unwrapReturnType(returnType, functionFlags);
64651
- if (type && maybeTypeOfKind(type, 1 | 16384)) {
64652
- return;
64653
- }
64654
- if (func.kind === 168 || ts.nodeIsMissing(func.body) || func.body.kind !== 235 || !functionHasImplicitReturn(func)) {
64655
- return;
64656
- }
64657
- var hasExplicitReturn = func.flags & 512;
64658
- var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
64659
- if (type && type.flags & 131072) {
64660
- error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
64661
- }
64662
- else if (type && !hasExplicitReturn) {
64663
- error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
64664
- }
64665
- else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
64666
- error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
64667
- }
64668
- else if (compilerOptions.noImplicitReturns) {
64669
- if (!type) {
64670
- if (!hasExplicitReturn) {
64671
- return;
64672
- }
64673
- var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
64674
- if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
64675
- return;
64660
+ addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
64661
+ return;
64662
+ function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
64663
+ var functionFlags = ts.getFunctionFlags(func);
64664
+ var type = returnType && unwrapReturnType(returnType, functionFlags);
64665
+ if (type && maybeTypeOfKind(type, 1 | 16384)) {
64666
+ return;
64667
+ }
64668
+ if (func.kind === 168 || ts.nodeIsMissing(func.body) || func.body.kind !== 235 || !functionHasImplicitReturn(func)) {
64669
+ return;
64670
+ }
64671
+ var hasExplicitReturn = func.flags & 512;
64672
+ var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
64673
+ if (type && type.flags & 131072) {
64674
+ error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
64675
+ }
64676
+ else if (type && !hasExplicitReturn) {
64677
+ error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
64678
+ }
64679
+ else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
64680
+ error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
64681
+ }
64682
+ else if (compilerOptions.noImplicitReturns) {
64683
+ if (!type) {
64684
+ if (!hasExplicitReturn) {
64685
+ return;
64686
+ }
64687
+ var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
64688
+ if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
64689
+ return;
64690
+ }
64676
64691
  }
64692
+ error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
64677
64693
  }
64678
- error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
64679
64694
  }
64680
64695
  }
64681
64696
  function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
@@ -64901,47 +64916,48 @@ var ts;
64901
64916
  checkExpression(node.expression);
64902
64917
  return undefinedWideningType;
64903
64918
  }
64904
- function checkAwaitExpression(node) {
64905
- if (produceDiagnostics) {
64906
- var container = ts.getContainingFunctionOrClassStaticBlock(node);
64907
- if (container && ts.isClassStaticBlockDeclaration(container)) {
64908
- error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
64909
- }
64910
- else if (!(node.flags & 32768)) {
64911
- if (ts.isInTopLevelContext(node)) {
64912
- var sourceFile = ts.getSourceFileOfNode(node);
64913
- if (!hasParseDiagnostics(sourceFile)) {
64914
- var span = void 0;
64915
- if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
64916
- if (!span)
64917
- span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
64918
- 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);
64919
- diagnostics.add(diagnostic);
64920
- }
64921
- 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) {
64919
+ function checkAwaitExpressionGrammar(node) {
64920
+ var container = ts.getContainingFunctionOrClassStaticBlock(node);
64921
+ if (container && ts.isClassStaticBlockDeclaration(container)) {
64922
+ error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
64923
+ }
64924
+ else if (!(node.flags & 32768)) {
64925
+ if (ts.isInTopLevelContext(node)) {
64926
+ var sourceFile = ts.getSourceFileOfNode(node);
64927
+ if (!hasParseDiagnostics(sourceFile)) {
64928
+ var span = void 0;
64929
+ if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
64930
+ if (!span)
64922
64931
  span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
64923
- 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);
64924
- diagnostics.add(diagnostic);
64925
- }
64932
+ 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);
64933
+ diagnostics.add(diagnostic);
64926
64934
  }
64927
- }
64928
- else {
64929
- var sourceFile = ts.getSourceFileOfNode(node);
64930
- if (!hasParseDiagnostics(sourceFile)) {
64931
- var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
64932
- 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);
64933
- if (container && container.kind !== 171 && (ts.getFunctionFlags(container) & 2) === 0) {
64934
- var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
64935
- ts.addRelatedInfo(diagnostic, relatedInfo);
64936
- }
64935
+ 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) {
64936
+ span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
64937
+ 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);
64937
64938
  diagnostics.add(diagnostic);
64938
64939
  }
64939
64940
  }
64940
64941
  }
64941
- if (isInParameterInitializerBeforeContainingFunction(node)) {
64942
- error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
64942
+ else {
64943
+ var sourceFile = ts.getSourceFileOfNode(node);
64944
+ if (!hasParseDiagnostics(sourceFile)) {
64945
+ var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
64946
+ 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);
64947
+ if (container && container.kind !== 171 && (ts.getFunctionFlags(container) & 2) === 0) {
64948
+ var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
64949
+ ts.addRelatedInfo(diagnostic, relatedInfo);
64950
+ }
64951
+ diagnostics.add(diagnostic);
64952
+ }
64943
64953
  }
64944
64954
  }
64955
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
64956
+ error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
64957
+ }
64958
+ }
64959
+ function checkAwaitExpression(node) {
64960
+ addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); });
64945
64961
  var operandType = checkExpression(node.expression);
64946
64962
  var awaitedType = checkAwaitedType(operandType, true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
64947
64963
  if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3)) {
@@ -65686,7 +65702,10 @@ var ts;
65686
65702
  }
65687
65703
  }
65688
65704
  function checkAssignmentOperator(valueType) {
65689
- if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
65705
+ if (ts.isAssignmentOperator(operator)) {
65706
+ addLazyDiagnostic(checkAssignmentOperatorWorker);
65707
+ }
65708
+ function checkAssignmentOperatorWorker() {
65690
65709
  if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access)
65691
65710
  && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
65692
65711
  var headMessage = void 0;
@@ -65775,14 +65794,7 @@ var ts;
65775
65794
  return [effectiveLeft, effectiveRight];
65776
65795
  }
65777
65796
  function checkYieldExpression(node) {
65778
- if (produceDiagnostics) {
65779
- if (!(node.flags & 8192)) {
65780
- grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
65781
- }
65782
- if (isInParameterInitializerBeforeContainingFunction(node)) {
65783
- error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
65784
- }
65785
- }
65797
+ addLazyDiagnostic(checkYieldExpressionGrammar);
65786
65798
  var func = ts.getContainingFunction(node);
65787
65799
  if (!func)
65788
65800
  return anyType;
@@ -65821,14 +65833,24 @@ var ts;
65821
65833
  var type = getContextualIterationType(2, func);
65822
65834
  if (!type) {
65823
65835
  type = anyType;
65824
- if (produceDiagnostics && noImplicitAny && !ts.expressionResultIsUnused(node)) {
65825
- var contextualType = getContextualType(node);
65826
- if (!contextualType || isTypeAny(contextualType)) {
65827
- error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
65836
+ addLazyDiagnostic(function () {
65837
+ if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
65838
+ var contextualType = getContextualType(node);
65839
+ if (!contextualType || isTypeAny(contextualType)) {
65840
+ error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
65841
+ }
65828
65842
  }
65829
- }
65843
+ });
65830
65844
  }
65831
65845
  return type;
65846
+ function checkYieldExpressionGrammar() {
65847
+ if (!(node.flags & 8192)) {
65848
+ grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
65849
+ }
65850
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
65851
+ error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
65852
+ }
65853
+ }
65832
65854
  }
65833
65855
  function checkConditionalExpression(node, checkMode) {
65834
65856
  checkTruthinessExpression(node.condition);
@@ -66357,9 +66379,7 @@ var ts;
66357
66379
  varianceTypeParameter = saveVarianceTypeParameter;
66358
66380
  }
66359
66381
  }
66360
- if (produceDiagnostics) {
66361
- checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
66362
- }
66382
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
66363
66383
  }
66364
66384
  function checkParameter(node) {
66365
66385
  checkGrammarDecoratorsAndModifiers(node);
@@ -66498,7 +66518,8 @@ var ts;
66498
66518
  if (node.type) {
66499
66519
  checkSourceElement(node.type);
66500
66520
  }
66501
- if (produceDiagnostics) {
66521
+ addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
66522
+ function checkSignatureDeclarationDiagnostics() {
66502
66523
  checkCollisionWithArgumentsInGeneratedCode(node);
66503
66524
  var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
66504
66525
  if (noImplicitAny && !returnTypeNode) {
@@ -66750,9 +66771,8 @@ var ts;
66750
66771
  if (ts.nodeIsMissing(node.body)) {
66751
66772
  return;
66752
66773
  }
66753
- if (!produceDiagnostics) {
66754
- return;
66755
- }
66774
+ addLazyDiagnostic(checkConstructorDeclarationDiagnostics);
66775
+ return;
66756
66776
  function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
66757
66777
  if (ts.isPrivateIdentifierClassElementDeclaration(n)) {
66758
66778
  return true;
@@ -66761,42 +66781,44 @@ var ts;
66761
66781
  !ts.isStatic(n) &&
66762
66782
  !!n.initializer;
66763
66783
  }
66764
- var containingClassDecl = node.parent;
66765
- if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
66766
- captureLexicalThis(node.parent, containingClassDecl);
66767
- var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
66768
- var superCall = findFirstSuperCall(node.body);
66769
- if (superCall) {
66770
- if (classExtendsNull) {
66771
- error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
66772
- }
66773
- var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 || !useDefineForClassFields) &&
66774
- (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
66775
- ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476); }));
66776
- if (superCallShouldBeRootLevel) {
66777
- if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
66778
- 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);
66779
- }
66780
- else {
66781
- var superCallStatement = void 0;
66782
- for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
66783
- var statement = _a[_i];
66784
- if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
66785
- superCallStatement = statement;
66786
- break;
66784
+ function checkConstructorDeclarationDiagnostics() {
66785
+ var containingClassDecl = node.parent;
66786
+ if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
66787
+ captureLexicalThis(node.parent, containingClassDecl);
66788
+ var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
66789
+ var superCall = findFirstSuperCall(node.body);
66790
+ if (superCall) {
66791
+ if (classExtendsNull) {
66792
+ error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
66793
+ }
66794
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 || !useDefineForClassFields) &&
66795
+ (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
66796
+ ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476); }));
66797
+ if (superCallShouldBeRootLevel) {
66798
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
66799
+ 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);
66800
+ }
66801
+ else {
66802
+ var superCallStatement = void 0;
66803
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
66804
+ var statement = _a[_i];
66805
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
66806
+ superCallStatement = statement;
66807
+ break;
66808
+ }
66809
+ if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
66810
+ break;
66811
+ }
66787
66812
  }
66788
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
66789
- break;
66813
+ if (superCallStatement === undefined) {
66814
+ 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);
66790
66815
  }
66791
66816
  }
66792
- if (superCallStatement === undefined) {
66793
- 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);
66794
- }
66795
66817
  }
66796
66818
  }
66797
- }
66798
- else if (!classExtendsNull) {
66799
- error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
66819
+ else if (!classExtendsNull) {
66820
+ error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
66821
+ }
66800
66822
  }
66801
66823
  }
66802
66824
  }
@@ -66814,7 +66836,10 @@ var ts;
66814
66836
  return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
66815
66837
  }
66816
66838
  function checkAccessorDeclaration(node) {
66817
- if (produceDiagnostics) {
66839
+ addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
66840
+ checkSourceElement(node.body);
66841
+ setNodeLinksForPrivateIdentifierScope(node);
66842
+ function checkAccessorDeclarationDiagnostics() {
66818
66843
  if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
66819
66844
  checkGrammarComputedPropertyName(node.name);
66820
66845
  checkDecorators(node);
@@ -66858,8 +66883,6 @@ var ts;
66858
66883
  checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
66859
66884
  }
66860
66885
  }
66861
- checkSourceElement(node.body);
66862
- setNodeLinksForPrivateIdentifierScope(node);
66863
66886
  }
66864
66887
  function checkMissingDeclaration(node) {
66865
66888
  checkDecorators(node);
@@ -66902,11 +66925,13 @@ var ts;
66902
66925
  ts.forEach(node.typeArguments, checkSourceElement);
66903
66926
  var type = getTypeFromTypeReference(node);
66904
66927
  if (!isErrorType(type)) {
66905
- if (node.typeArguments && produceDiagnostics) {
66906
- var typeParameters = getTypeParametersForTypeReference(node);
66907
- if (typeParameters) {
66908
- checkTypeArgumentConstraints(node, typeParameters);
66909
- }
66928
+ if (node.typeArguments) {
66929
+ addLazyDiagnostic(function () {
66930
+ var typeParameters = getTypeParametersForTypeReference(node);
66931
+ if (typeParameters) {
66932
+ checkTypeArgumentConstraints(node, typeParameters);
66933
+ }
66934
+ });
66910
66935
  }
66911
66936
  var symbol = getNodeLinks(node).resolvedSymbol;
66912
66937
  if (symbol) {
@@ -66934,7 +66959,8 @@ var ts;
66934
66959
  }
66935
66960
  function checkTypeLiteral(node) {
66936
66961
  ts.forEach(node.members, checkSourceElement);
66937
- if (produceDiagnostics) {
66962
+ addLazyDiagnostic(checkTypeLiteralDiagnostics);
66963
+ function checkTypeLiteralDiagnostics() {
66938
66964
  var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
66939
66965
  checkIndexConstraints(type, type.symbol);
66940
66966
  checkTypeForDuplicateIndexSignatures(node);
@@ -67119,9 +67145,9 @@ var ts;
67119
67145
  return flags & flagsToCheck;
67120
67146
  }
67121
67147
  function checkFunctionOrConstructorSymbol(symbol) {
67122
- if (!produceDiagnostics) {
67123
- return;
67124
- }
67148
+ addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
67149
+ }
67150
+ function checkFunctionOrConstructorSymbolWorker(symbol) {
67125
67151
  function getCanonicalOverload(overloads, implementation) {
67126
67152
  var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
67127
67153
  return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
@@ -67314,9 +67340,9 @@ var ts;
67314
67340
  }
67315
67341
  }
67316
67342
  function checkExportsOnMergedDeclarations(node) {
67317
- if (!produceDiagnostics) {
67318
- return;
67319
- }
67343
+ addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); });
67344
+ }
67345
+ function checkExportsOnMergedDeclarationsWorker(node) {
67320
67346
  var symbol = node.localSymbol;
67321
67347
  if (!symbol) {
67322
67348
  symbol = getSymbolOfNode(node);
@@ -67764,7 +67790,8 @@ var ts;
67764
67790
  ts.forEach(node.decorators, checkDecorator);
67765
67791
  }
67766
67792
  function checkFunctionDeclaration(node) {
67767
- if (produceDiagnostics) {
67793
+ addLazyDiagnostic(checkFunctionDeclarationDiagnostics);
67794
+ function checkFunctionDeclarationDiagnostics() {
67768
67795
  checkFunctionOrMethodDeclaration(node);
67769
67796
  checkGrammarForGenerator(node);
67770
67797
  checkCollisionsForDeclarationName(node, node.name);
@@ -67797,10 +67824,13 @@ var ts;
67797
67824
  checkSourceElement(node.typeExpression);
67798
67825
  }
67799
67826
  function checkJSDocFunctionType(node) {
67800
- if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
67801
- reportImplicitAny(node, anyType);
67802
- }
67827
+ addLazyDiagnostic(checkJSDocFunctionTypeImplicitAny);
67803
67828
  checkSignatureDeclaration(node);
67829
+ function checkJSDocFunctionTypeImplicitAny() {
67830
+ if (!node.type && !ts.isJSDocConstructSignature(node)) {
67831
+ reportImplicitAny(node, anyType);
67832
+ }
67833
+ }
67804
67834
  }
67805
67835
  function checkJSDocImplementsTag(node) {
67806
67836
  var classLike = ts.getEffectiveJSDocHost(node);
@@ -67866,23 +67896,27 @@ var ts;
67866
67896
  var body = node.kind === 168 ? undefined : node.body;
67867
67897
  checkSourceElement(body);
67868
67898
  checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
67869
- if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
67870
- if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
67871
- reportImplicitAny(node, anyType);
67872
- }
67873
- if (functionFlags & 1 && ts.nodeIsPresent(body)) {
67874
- getReturnTypeOfSignature(getSignatureFromDeclaration(node));
67875
- }
67876
- }
67899
+ addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics);
67877
67900
  if (ts.isInJSFile(node)) {
67878
67901
  var typeTag = ts.getJSDocTypeTag(node);
67879
67902
  if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
67880
67903
  error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
67881
67904
  }
67882
67905
  }
67906
+ function checkFunctionOrMethodDeclarationDiagnostics() {
67907
+ if (!ts.getEffectiveReturnTypeNode(node)) {
67908
+ if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
67909
+ reportImplicitAny(node, anyType);
67910
+ }
67911
+ if (functionFlags & 1 && ts.nodeIsPresent(body)) {
67912
+ getReturnTypeOfSignature(getSignatureFromDeclaration(node));
67913
+ }
67914
+ }
67915
+ }
67883
67916
  }
67884
67917
  function registerForUnusedIdentifiersCheck(node) {
67885
- if (produceDiagnostics) {
67918
+ addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
67919
+ function registerForUnusedIdentifiersCheckDiagnostics() {
67886
67920
  var sourceFile = ts.getSourceFileOfNode(node);
67887
67921
  var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
67888
67922
  if (!potentiallyUnusedIdentifiers) {
@@ -69311,22 +69345,27 @@ var ts;
69311
69345
  hasDuplicateDefaultClause = true;
69312
69346
  }
69313
69347
  }
69314
- if (produceDiagnostics && clause.kind === 289) {
69315
- var caseType = checkExpression(clause.expression);
69316
- var caseIsLiteral = isLiteralType(caseType);
69317
- var comparedExpressionType = expressionType;
69318
- if (!caseIsLiteral || !expressionIsLiteral) {
69319
- caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
69320
- comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
69321
- }
69322
- if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
69323
- checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
69324
- }
69348
+ if (clause.kind === 289) {
69349
+ addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause));
69325
69350
  }
69326
69351
  ts.forEach(clause.statements, checkSourceElement);
69327
69352
  if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
69328
69353
  error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
69329
69354
  }
69355
+ function createLazyCaseClauseDiagnostics(clause) {
69356
+ return function () {
69357
+ var caseType = checkExpression(clause.expression);
69358
+ var caseIsLiteral = isLiteralType(caseType);
69359
+ var comparedExpressionType = expressionType;
69360
+ if (!caseIsLiteral || !expressionIsLiteral) {
69361
+ caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
69362
+ comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
69363
+ }
69364
+ if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
69365
+ checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
69366
+ }
69367
+ };
69368
+ }
69330
69369
  });
69331
69370
  if (node.caseBlock.locals) {
69332
69371
  registerForUnusedIdentifiersCheck(node.caseBlock);
@@ -69526,26 +69565,29 @@ var ts;
69526
69565
  }
69527
69566
  }
69528
69567
  function checkTypeParameters(typeParameterDeclarations) {
69568
+ var seenDefault = false;
69529
69569
  if (typeParameterDeclarations) {
69530
- var seenDefault = false;
69531
69570
  for (var i = 0; i < typeParameterDeclarations.length; i++) {
69532
69571
  var node = typeParameterDeclarations[i];
69533
69572
  checkTypeParameter(node);
69534
- if (produceDiagnostics) {
69535
- if (node.default) {
69536
- seenDefault = true;
69537
- checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
69538
- }
69539
- else if (seenDefault) {
69540
- error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
69541
- }
69542
- for (var j = 0; j < i; j++) {
69543
- if (typeParameterDeclarations[j].symbol === node.symbol) {
69544
- error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
69545
- }
69573
+ addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
69574
+ }
69575
+ }
69576
+ function createCheckTypeParameterDiagnostic(node, i) {
69577
+ return function () {
69578
+ if (node.default) {
69579
+ seenDefault = true;
69580
+ checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
69581
+ }
69582
+ else if (seenDefault) {
69583
+ error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
69584
+ }
69585
+ for (var j = 0; j < i; j++) {
69586
+ if (typeParameterDeclarations[j].symbol === node.symbol) {
69587
+ error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
69546
69588
  }
69547
69589
  }
69548
- }
69590
+ };
69549
69591
  }
69550
69592
  }
69551
69593
  function checkTypeParametersNotReferenced(root, typeParameters, index) {
@@ -69663,82 +69705,87 @@ var ts;
69663
69705
  if (extendsNode && extendsNode !== baseTypeNode) {
69664
69706
  checkExpression(extendsNode.expression);
69665
69707
  }
69666
- var baseTypes = getBaseTypes(type);
69667
- if (baseTypes.length && produceDiagnostics) {
69668
- var baseType_1 = baseTypes[0];
69669
- var baseConstructorType = getBaseConstructorTypeOfClass(type);
69670
- var staticBaseType = getApparentType(baseConstructorType);
69671
- checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
69672
- checkSourceElement(baseTypeNode.expression);
69673
- if (ts.some(baseTypeNode.typeArguments)) {
69674
- ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
69675
- for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
69676
- var constructor = _a[_i];
69677
- if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
69678
- break;
69708
+ var baseTypes_2 = getBaseTypes(type);
69709
+ if (baseTypes_2.length) {
69710
+ addLazyDiagnostic(function () {
69711
+ var baseType = baseTypes_2[0];
69712
+ var baseConstructorType = getBaseConstructorTypeOfClass(type);
69713
+ var staticBaseType = getApparentType(baseConstructorType);
69714
+ checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
69715
+ checkSourceElement(baseTypeNode.expression);
69716
+ if (ts.some(baseTypeNode.typeArguments)) {
69717
+ ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
69718
+ for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
69719
+ var constructor = _a[_i];
69720
+ if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
69721
+ break;
69722
+ }
69679
69723
  }
69680
69724
  }
69681
- }
69682
- var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
69683
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
69684
- issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
69685
- }
69686
- else {
69687
- checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
69688
- }
69689
- if (baseConstructorType.flags & 8650752) {
69690
- if (!isMixinConstructorType(staticType)) {
69691
- error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
69725
+ var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
69726
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
69727
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
69692
69728
  }
69693
69729
  else {
69694
- var constructSignatures = getSignaturesOfType(baseConstructorType, 1);
69695
- if (constructSignatures.some(function (signature) { return signature.flags & 4; }) && !ts.hasSyntacticModifier(node, 128)) {
69696
- 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);
69730
+ checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
69731
+ }
69732
+ if (baseConstructorType.flags & 8650752) {
69733
+ if (!isMixinConstructorType(staticType)) {
69734
+ error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
69735
+ }
69736
+ else {
69737
+ var constructSignatures = getSignaturesOfType(baseConstructorType, 1);
69738
+ if (constructSignatures.some(function (signature) { return signature.flags & 4; }) && !ts.hasSyntacticModifier(node, 128)) {
69739
+ 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);
69740
+ }
69697
69741
  }
69698
69742
  }
69699
- }
69700
- if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
69701
- var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
69702
- if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
69703
- error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
69743
+ if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
69744
+ var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
69745
+ if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType); })) {
69746
+ error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
69747
+ }
69704
69748
  }
69705
- }
69706
- checkKindsOfPropertyMemberOverrides(type, baseType_1);
69749
+ checkKindsOfPropertyMemberOverrides(type, baseType);
69750
+ });
69707
69751
  }
69708
69752
  }
69709
69753
  checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
69710
69754
  var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
69711
69755
  if (implementedTypeNodes) {
69712
- for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
69713
- var typeRefNode = implementedTypeNodes_1[_b];
69756
+ for (var _i = 0, implementedTypeNodes_1 = implementedTypeNodes; _i < implementedTypeNodes_1.length; _i++) {
69757
+ var typeRefNode = implementedTypeNodes_1[_i];
69714
69758
  if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
69715
69759
  error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
69716
69760
  }
69717
69761
  checkTypeReferenceNode(typeRefNode);
69718
- if (produceDiagnostics) {
69719
- var t = getReducedType(getTypeFromTypeNode(typeRefNode));
69720
- if (!isErrorType(t)) {
69721
- if (isValidBaseType(t)) {
69722
- var genericDiag = t.symbol && t.symbol.flags & 32 ?
69723
- ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
69724
- ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
69725
- var baseWithThis = getTypeWithThisArgument(t, type.thisType);
69726
- if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
69727
- issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
69728
- }
69729
- }
69730
- else {
69731
- error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
69732
- }
69733
- }
69734
- }
69762
+ addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
69735
69763
  }
69736
69764
  }
69737
- if (produceDiagnostics) {
69765
+ addLazyDiagnostic(function () {
69738
69766
  checkIndexConstraints(type, symbol);
69739
69767
  checkIndexConstraints(staticType, symbol, true);
69740
69768
  checkTypeForDuplicateIndexSignatures(node);
69741
69769
  checkPropertyInitialization(node);
69770
+ });
69771
+ function createImplementsDiagnostics(typeRefNode) {
69772
+ return function () {
69773
+ var t = getReducedType(getTypeFromTypeNode(typeRefNode));
69774
+ if (!isErrorType(t)) {
69775
+ if (isValidBaseType(t)) {
69776
+ var genericDiag = t.symbol && t.symbol.flags & 32 ?
69777
+ ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
69778
+ ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
69779
+ var baseWithThis = getTypeWithThisArgument(t, type.thisType);
69780
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
69781
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
69782
+ }
69783
+ }
69784
+ else {
69785
+ error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
69786
+ }
69787
+ }
69788
+ };
69742
69789
  }
69743
69790
  }
69744
69791
  function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
@@ -70005,8 +70052,8 @@ var ts;
70005
70052
  ts.forEach(properties, function (p) {
70006
70053
  seen.set(p.escapedName, p);
70007
70054
  });
70008
- for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
70009
- var base = baseTypes_2[_i];
70055
+ for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
70056
+ var base = baseTypes_3[_i];
70010
70057
  var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
70011
70058
  for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
70012
70059
  var prop = properties_4[_a];
@@ -70028,8 +70075,8 @@ var ts;
70028
70075
  seen.set(p.escapedName, { prop: p, containingType: type });
70029
70076
  });
70030
70077
  var ok = true;
70031
- for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
70032
- var base = baseTypes_3[_i];
70078
+ for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
70079
+ var base = baseTypes_4[_i];
70033
70080
  var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
70034
70081
  for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
70035
70082
  var prop = properties_6[_a];
@@ -70111,7 +70158,7 @@ var ts;
70111
70158
  if (!checkGrammarDecoratorsAndModifiers(node))
70112
70159
  checkGrammarInterfaceDeclaration(node);
70113
70160
  checkTypeParameters(node.typeParameters);
70114
- if (produceDiagnostics) {
70161
+ addLazyDiagnostic(function () {
70115
70162
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
70116
70163
  checkExportsOnMergedDeclarations(node);
70117
70164
  var symbol = getSymbolOfNode(node);
@@ -70129,7 +70176,7 @@ var ts;
70129
70176
  }
70130
70177
  }
70131
70178
  checkObjectTypeForDuplicateDeclarations(node);
70132
- }
70179
+ });
70133
70180
  ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
70134
70181
  if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
70135
70182
  error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
@@ -70137,10 +70184,10 @@ var ts;
70137
70184
  checkTypeReferenceNode(heritageElement);
70138
70185
  });
70139
70186
  ts.forEach(node.members, checkSourceElement);
70140
- if (produceDiagnostics) {
70187
+ addLazyDiagnostic(function () {
70141
70188
  checkTypeForDuplicateIndexSignatures(node);
70142
70189
  registerForUnusedIdentifiersCheck(node);
70143
- }
70190
+ });
70144
70191
  }
70145
70192
  function checkTypeAliasDeclaration(node) {
70146
70193
  checkGrammarDecoratorsAndModifiers(node);
@@ -70321,9 +70368,9 @@ var ts;
70321
70368
  ts.isStringLiteralLike(node.argumentExpression);
70322
70369
  }
70323
70370
  function checkEnumDeclaration(node) {
70324
- if (!produceDiagnostics) {
70325
- return;
70326
- }
70371
+ addLazyDiagnostic(function () { return checkEnumDeclarationWorker(node); });
70372
+ }
70373
+ function checkEnumDeclarationWorker(node) {
70327
70374
  checkGrammarDecoratorsAndModifiers(node);
70328
70375
  checkCollisionsForDeclarationName(node, node.name);
70329
70376
  checkExportsOnMergedDeclarations(node);
@@ -70394,7 +70441,14 @@ var ts;
70394
70441
  }
70395
70442
  }
70396
70443
  function checkModuleDeclaration(node) {
70397
- if (produceDiagnostics) {
70444
+ if (node.body) {
70445
+ checkSourceElement(node.body);
70446
+ if (!ts.isGlobalScopeAugmentation(node)) {
70447
+ registerForUnusedIdentifiersCheck(node);
70448
+ }
70449
+ }
70450
+ addLazyDiagnostic(checkModuleDeclarationDiagnostics);
70451
+ function checkModuleDeclarationDiagnostics() {
70398
70452
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
70399
70453
  var inAmbientContext = node.flags & 8388608;
70400
70454
  if (isGlobalAugmentation && !inAmbientContext) {
@@ -70465,12 +70519,6 @@ var ts;
70465
70519
  }
70466
70520
  }
70467
70521
  }
70468
- if (node.body) {
70469
- checkSourceElement(node.body);
70470
- if (!ts.isGlobalScopeAugmentation(node)) {
70471
- registerForUnusedIdentifiersCheck(node);
70472
- }
70473
- }
70474
70522
  }
70475
70523
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
70476
70524
  var _a;
@@ -71329,13 +71377,15 @@ var ts;
71329
71377
  if (ts.isExternalOrCommonJsModule(node)) {
71330
71378
  registerForUnusedIdentifiersCheck(node);
71331
71379
  }
71332
- if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
71333
- checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
71334
- if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
71335
- diagnostics.add(diag);
71336
- }
71337
- });
71338
- }
71380
+ addLazyDiagnostic(function () {
71381
+ if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
71382
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
71383
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
71384
+ diagnostics.add(diag);
71385
+ }
71386
+ });
71387
+ }
71388
+ });
71339
71389
  if (compilerOptions.importsNotUsedAsValues === 2 &&
71340
71390
  !node.isDeclarationFile &&
71341
71391
  ts.isExternalModule(node)) {
@@ -71372,12 +71422,26 @@ var ts;
71372
71422
  cancellationToken = undefined;
71373
71423
  }
71374
71424
  }
71425
+ function ensurePendingDiagnosticWorkComplete() {
71426
+ for (var _i = 0, deferredDiagnosticsCallbacks_1 = deferredDiagnosticsCallbacks; _i < deferredDiagnosticsCallbacks_1.length; _i++) {
71427
+ var cb = deferredDiagnosticsCallbacks_1[_i];
71428
+ cb();
71429
+ }
71430
+ deferredDiagnosticsCallbacks = [];
71431
+ }
71432
+ function checkSourceFileWithEagerDiagnostics(sourceFile) {
71433
+ ensurePendingDiagnosticWorkComplete();
71434
+ var oldAddLazyDiagnostics = addLazyDiagnostic;
71435
+ addLazyDiagnostic = function (cb) { return cb(); };
71436
+ checkSourceFile(sourceFile);
71437
+ addLazyDiagnostic = oldAddLazyDiagnostics;
71438
+ }
71375
71439
  function getDiagnosticsWorker(sourceFile) {
71376
- throwIfNonDiagnosticsProducing();
71377
71440
  if (sourceFile) {
71441
+ ensurePendingDiagnosticWorkComplete();
71378
71442
  var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
71379
71443
  var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
71380
- checkSourceFile(sourceFile);
71444
+ checkSourceFileWithEagerDiagnostics(sourceFile);
71381
71445
  var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
71382
71446
  var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
71383
71447
  if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
@@ -71389,18 +71453,13 @@ var ts;
71389
71453
  }
71390
71454
  return semanticDiagnostics;
71391
71455
  }
71392
- ts.forEach(host.getSourceFiles(), checkSourceFile);
71456
+ ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
71393
71457
  return diagnostics.getDiagnostics();
71394
71458
  }
71395
71459
  function getGlobalDiagnostics() {
71396
- throwIfNonDiagnosticsProducing();
71460
+ ensurePendingDiagnosticWorkComplete();
71397
71461
  return diagnostics.getGlobalDiagnostics();
71398
71462
  }
71399
- function throwIfNonDiagnosticsProducing() {
71400
- if (!produceDiagnostics) {
71401
- throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
71402
- }
71403
- }
71404
71463
  function getSymbolsInScope(location, meaning) {
71405
71464
  if (location.flags & 16777216) {
71406
71465
  return [];
@@ -95394,8 +95453,7 @@ var ts;
95394
95453
  var files;
95395
95454
  var symlinks;
95396
95455
  var commonSourceDirectory;
95397
- var diagnosticsProducingTypeChecker;
95398
- var noDiagnosticsTypeChecker;
95456
+ var typeChecker;
95399
95457
  var classifiableNames;
95400
95458
  var ambientModuleNameToUnmodifiedFileName = new ts.Map();
95401
95459
  var fileReasons = ts.createMultiMap();
@@ -95599,21 +95657,19 @@ var ts;
95599
95657
  getProgramDiagnostics: getProgramDiagnostics,
95600
95658
  getTypeChecker: getTypeChecker,
95601
95659
  getClassifiableNames: getClassifiableNames,
95602
- getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
95603
95660
  getCommonSourceDirectory: getCommonSourceDirectory,
95604
95661
  emit: emit,
95605
95662
  getCurrentDirectory: function () { return currentDirectory; },
95606
- getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
95607
- getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
95608
- getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
95609
- getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
95610
- getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
95611
- getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
95663
+ getNodeCount: function () { return getTypeChecker().getNodeCount(); },
95664
+ getIdentifierCount: function () { return getTypeChecker().getIdentifierCount(); },
95665
+ getSymbolCount: function () { return getTypeChecker().getSymbolCount(); },
95666
+ getTypeCount: function () { return getTypeChecker().getTypeCount(); },
95667
+ getInstantiationCount: function () { return getTypeChecker().getInstantiationCount(); },
95668
+ getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
95612
95669
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
95613
95670
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
95614
95671
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
95615
95672
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
95616
- dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
95617
95673
  getSourceFileFromReference: getSourceFileFromReference,
95618
95674
  getLibFileFromReference: getLibFileFromReference,
95619
95675
  sourceFileToPackageName: sourceFileToPackageName,
@@ -96100,14 +96156,8 @@ var ts;
96100
96156
  return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); });
96101
96157
  }
96102
96158
  }
96103
- function getDiagnosticsProducingTypeChecker() {
96104
- return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
96105
- }
96106
- function dropDiagnosticsProducingTypeChecker() {
96107
- diagnosticsProducingTypeChecker = undefined;
96108
- }
96109
96159
  function getTypeChecker() {
96110
- return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
96160
+ return typeChecker || (typeChecker = ts.createTypeChecker(program));
96111
96161
  }
96112
96162
  function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
96113
96163
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, true);
@@ -96124,7 +96174,7 @@ var ts;
96124
96174
  if (result)
96125
96175
  return result;
96126
96176
  }
96127
- var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
96177
+ var emitResolver = getTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
96128
96178
  ts.performance.mark("beforeEmit");
96129
96179
  var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
96130
96180
  ts.performance.mark("afterEmit");
@@ -96198,8 +96248,7 @@ var ts;
96198
96248
  }
96199
96249
  catch (e) {
96200
96250
  if (e instanceof ts.OperationCanceledException) {
96201
- noDiagnosticsTypeChecker = undefined;
96202
- diagnosticsProducingTypeChecker = undefined;
96251
+ typeChecker = undefined;
96203
96252
  }
96204
96253
  throw e;
96205
96254
  }
@@ -96215,7 +96264,7 @@ var ts;
96215
96264
  if (ts.skipTypeChecking(sourceFile, options, program)) {
96216
96265
  return ts.emptyArray;
96217
96266
  }
96218
- var typeChecker = getDiagnosticsProducingTypeChecker();
96267
+ var typeChecker = getTypeChecker();
96219
96268
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
96220
96269
  var isJs = sourceFile.scriptKind === 1 || sourceFile.scriptKind === 2;
96221
96270
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
@@ -96256,7 +96305,7 @@ var ts;
96256
96305
  }
96257
96306
  function getSuggestionDiagnostics(sourceFile, cancellationToken) {
96258
96307
  return runWithCancellationToken(function () {
96259
- return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
96308
+ return getTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
96260
96309
  });
96261
96310
  }
96262
96311
  function markPrecedingCommentDirectiveLine(diagnostic, directives) {
@@ -96455,7 +96504,7 @@ var ts;
96455
96504
  }
96456
96505
  function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
96457
96506
  return runWithCancellationToken(function () {
96458
- var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
96507
+ var resolver = getTypeChecker().getEmitResolver(sourceFile, cancellationToken);
96459
96508
  return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
96460
96509
  });
96461
96510
  }
@@ -96492,7 +96541,7 @@ var ts;
96492
96541
  return diagnostics;
96493
96542
  }
96494
96543
  function getGlobalDiagnostics() {
96495
- return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
96544
+ return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
96496
96545
  }
96497
96546
  function getConfigFileParsingDiagnostics() {
96498
96547
  return configFileParsingDiagnostics || ts.emptyArray;