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.
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.20220325";
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) {
@@ -53584,6 +53594,7 @@ var ts;
53584
53594
  return 0;
53585
53595
  }
53586
53596
  function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
53597
+ var _a, _b;
53587
53598
  var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
53588
53599
  var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
53589
53600
  source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
@@ -53622,6 +53633,9 @@ var ts;
53622
53633
  return;
53623
53634
  }
53624
53635
  reportRelationError(headMessage, source, target);
53636
+ 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))) {
53637
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
53638
+ }
53625
53639
  }
53626
53640
  function traceUnionsOrIntersectionsTooLarge(source, target) {
53627
53641
  if (!ts.tracing) {
@@ -54251,17 +54265,17 @@ var ts;
54251
54265
  if (sourceFlags & 8650752) {
54252
54266
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
54253
54267
  var constraint = getConstraintOfType(source);
54254
- if (!constraint || (sourceFlags & 262144 && constraint.flags & 1)) {
54268
+ if (!strictNullChecks && (!constraint || (sourceFlags & 262144 && constraint.flags & 1))) {
54255
54269
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
54256
54270
  resetErrorInfo(saveErrorInfo);
54257
54271
  return result;
54258
54272
  }
54259
54273
  }
54260
- else if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
54274
+ else if (constraint && (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState))) {
54261
54275
  resetErrorInfo(saveErrorInfo);
54262
54276
  return result;
54263
54277
  }
54264
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
54278
+ else if (constraint && (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState))) {
54265
54279
  resetErrorInfo(saveErrorInfo);
54266
54280
  return result;
54267
54281
  }
@@ -56036,11 +56050,13 @@ var ts;
56036
56050
  errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
56037
56051
  }
56038
56052
  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);
56053
+ addLazyDiagnostic(function () {
56054
+ if (noImplicitAny && ts.getObjectFlags(type) & 65536 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
56055
+ if (!reportWideningErrorsInType(type)) {
56056
+ reportImplicitAny(declaration, type, wideningKind);
56057
+ }
56042
56058
  }
56043
- }
56059
+ });
56044
56060
  }
56045
56061
  function applyToParameterTypes(source, target, callback) {
56046
56062
  var sourceCount = getParameterCount(source);
@@ -61812,6 +61828,7 @@ var ts;
61812
61828
  && !isOptionalPropertyDeclaration(valueDeclaration)
61813
61829
  && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
61814
61830
  && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
61831
+ && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32)
61815
61832
  && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
61816
61833
  diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
61817
61834
  }
@@ -62875,7 +62892,7 @@ var ts;
62875
62892
  var isTaggedTemplate = node.kind === 210;
62876
62893
  var isDecorator = node.kind === 165;
62877
62894
  var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
62878
- var reportErrors = !candidatesOutArray && produceDiagnostics;
62895
+ var reportErrors = !candidatesOutArray;
62879
62896
  var typeArguments;
62880
62897
  if (!isDecorator) {
62881
62898
  typeArguments = node.typeArguments;
@@ -63955,11 +63972,13 @@ var ts;
63955
63972
  checkSourceElement(type);
63956
63973
  exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
63957
63974
  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
- }
63975
+ if (!isErrorType(targetType)) {
63976
+ addLazyDiagnostic(function () {
63977
+ var widenedType = getWidenedType(exprType);
63978
+ if (!isTypeComparableTo(targetType, widenedType)) {
63979
+ 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);
63980
+ }
63981
+ });
63963
63982
  }
63964
63983
  return targetType;
63965
63984
  }
@@ -64643,39 +64662,40 @@ var ts;
64643
64662
  }
64644
64663
  }
64645
64664
  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;
64665
+ addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
64666
+ return;
64667
+ function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
64668
+ var functionFlags = ts.getFunctionFlags(func);
64669
+ var type = returnType && unwrapReturnType(returnType, functionFlags);
64670
+ if (type && maybeTypeOfKind(type, 1 | 16384)) {
64671
+ return;
64672
+ }
64673
+ if (func.kind === 168 || ts.nodeIsMissing(func.body) || func.body.kind !== 235 || !functionHasImplicitReturn(func)) {
64674
+ return;
64675
+ }
64676
+ var hasExplicitReturn = func.flags & 512;
64677
+ var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
64678
+ if (type && type.flags & 131072) {
64679
+ error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
64680
+ }
64681
+ else if (type && !hasExplicitReturn) {
64682
+ error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
64683
+ }
64684
+ else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
64685
+ error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
64686
+ }
64687
+ else if (compilerOptions.noImplicitReturns) {
64688
+ if (!type) {
64689
+ if (!hasExplicitReturn) {
64690
+ return;
64691
+ }
64692
+ var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
64693
+ if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
64694
+ return;
64695
+ }
64676
64696
  }
64697
+ error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
64677
64698
  }
64678
- error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
64679
64699
  }
64680
64700
  }
64681
64701
  function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
@@ -64901,47 +64921,48 @@ var ts;
64901
64921
  checkExpression(node.expression);
64902
64922
  return undefinedWideningType;
64903
64923
  }
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) {
64924
+ function checkAwaitExpressionGrammar(node) {
64925
+ var container = ts.getContainingFunctionOrClassStaticBlock(node);
64926
+ if (container && ts.isClassStaticBlockDeclaration(container)) {
64927
+ error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
64928
+ }
64929
+ else if (!(node.flags & 32768)) {
64930
+ if (ts.isInTopLevelContext(node)) {
64931
+ var sourceFile = ts.getSourceFileOfNode(node);
64932
+ if (!hasParseDiagnostics(sourceFile)) {
64933
+ var span = void 0;
64934
+ if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
64935
+ if (!span)
64922
64936
  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
- }
64937
+ 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);
64938
+ diagnostics.add(diagnostic);
64926
64939
  }
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
- }
64940
+ 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) {
64941
+ span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
64942
+ 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
64943
  diagnostics.add(diagnostic);
64938
64944
  }
64939
64945
  }
64940
64946
  }
64941
- if (isInParameterInitializerBeforeContainingFunction(node)) {
64942
- error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
64947
+ else {
64948
+ var sourceFile = ts.getSourceFileOfNode(node);
64949
+ if (!hasParseDiagnostics(sourceFile)) {
64950
+ var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
64951
+ 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);
64952
+ if (container && container.kind !== 171 && (ts.getFunctionFlags(container) & 2) === 0) {
64953
+ var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
64954
+ ts.addRelatedInfo(diagnostic, relatedInfo);
64955
+ }
64956
+ diagnostics.add(diagnostic);
64957
+ }
64943
64958
  }
64944
64959
  }
64960
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
64961
+ error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
64962
+ }
64963
+ }
64964
+ function checkAwaitExpression(node) {
64965
+ addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); });
64945
64966
  var operandType = checkExpression(node.expression);
64946
64967
  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
64968
  if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3)) {
@@ -65686,7 +65707,10 @@ var ts;
65686
65707
  }
65687
65708
  }
65688
65709
  function checkAssignmentOperator(valueType) {
65689
- if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
65710
+ if (ts.isAssignmentOperator(operator)) {
65711
+ addLazyDiagnostic(checkAssignmentOperatorWorker);
65712
+ }
65713
+ function checkAssignmentOperatorWorker() {
65690
65714
  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
65715
  && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
65692
65716
  var headMessage = void 0;
@@ -65775,14 +65799,7 @@ var ts;
65775
65799
  return [effectiveLeft, effectiveRight];
65776
65800
  }
65777
65801
  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
- }
65802
+ addLazyDiagnostic(checkYieldExpressionGrammar);
65786
65803
  var func = ts.getContainingFunction(node);
65787
65804
  if (!func)
65788
65805
  return anyType;
@@ -65821,14 +65838,24 @@ var ts;
65821
65838
  var type = getContextualIterationType(2, func);
65822
65839
  if (!type) {
65823
65840
  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);
65841
+ addLazyDiagnostic(function () {
65842
+ if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
65843
+ var contextualType = getContextualType(node);
65844
+ if (!contextualType || isTypeAny(contextualType)) {
65845
+ error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
65846
+ }
65828
65847
  }
65829
- }
65848
+ });
65830
65849
  }
65831
65850
  return type;
65851
+ function checkYieldExpressionGrammar() {
65852
+ if (!(node.flags & 8192)) {
65853
+ grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
65854
+ }
65855
+ if (isInParameterInitializerBeforeContainingFunction(node)) {
65856
+ error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
65857
+ }
65858
+ }
65832
65859
  }
65833
65860
  function checkConditionalExpression(node, checkMode) {
65834
65861
  checkTruthinessExpression(node.condition);
@@ -66357,9 +66384,7 @@ var ts;
66357
66384
  varianceTypeParameter = saveVarianceTypeParameter;
66358
66385
  }
66359
66386
  }
66360
- if (produceDiagnostics) {
66361
- checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
66362
- }
66387
+ addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
66363
66388
  }
66364
66389
  function checkParameter(node) {
66365
66390
  checkGrammarDecoratorsAndModifiers(node);
@@ -66498,7 +66523,8 @@ var ts;
66498
66523
  if (node.type) {
66499
66524
  checkSourceElement(node.type);
66500
66525
  }
66501
- if (produceDiagnostics) {
66526
+ addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
66527
+ function checkSignatureDeclarationDiagnostics() {
66502
66528
  checkCollisionWithArgumentsInGeneratedCode(node);
66503
66529
  var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
66504
66530
  if (noImplicitAny && !returnTypeNode) {
@@ -66750,9 +66776,8 @@ var ts;
66750
66776
  if (ts.nodeIsMissing(node.body)) {
66751
66777
  return;
66752
66778
  }
66753
- if (!produceDiagnostics) {
66754
- return;
66755
- }
66779
+ addLazyDiagnostic(checkConstructorDeclarationDiagnostics);
66780
+ return;
66756
66781
  function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
66757
66782
  if (ts.isPrivateIdentifierClassElementDeclaration(n)) {
66758
66783
  return true;
@@ -66761,42 +66786,44 @@ var ts;
66761
66786
  !ts.isStatic(n) &&
66762
66787
  !!n.initializer;
66763
66788
  }
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;
66789
+ function checkConstructorDeclarationDiagnostics() {
66790
+ var containingClassDecl = node.parent;
66791
+ if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
66792
+ captureLexicalThis(node.parent, containingClassDecl);
66793
+ var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
66794
+ var superCall = findFirstSuperCall(node.body);
66795
+ if (superCall) {
66796
+ if (classExtendsNull) {
66797
+ error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
66798
+ }
66799
+ var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 || !useDefineForClassFields) &&
66800
+ (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
66801
+ ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476); }));
66802
+ if (superCallShouldBeRootLevel) {
66803
+ if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
66804
+ 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);
66805
+ }
66806
+ else {
66807
+ var superCallStatement = void 0;
66808
+ for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
66809
+ var statement = _a[_i];
66810
+ if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
66811
+ superCallStatement = statement;
66812
+ break;
66813
+ }
66814
+ if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
66815
+ break;
66816
+ }
66787
66817
  }
66788
- if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
66789
- break;
66818
+ if (superCallStatement === undefined) {
66819
+ 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
66820
  }
66791
66821
  }
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
66822
  }
66796
66823
  }
66797
- }
66798
- else if (!classExtendsNull) {
66799
- error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
66824
+ else if (!classExtendsNull) {
66825
+ error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
66826
+ }
66800
66827
  }
66801
66828
  }
66802
66829
  }
@@ -66814,7 +66841,10 @@ var ts;
66814
66841
  return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
66815
66842
  }
66816
66843
  function checkAccessorDeclaration(node) {
66817
- if (produceDiagnostics) {
66844
+ addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
66845
+ checkSourceElement(node.body);
66846
+ setNodeLinksForPrivateIdentifierScope(node);
66847
+ function checkAccessorDeclarationDiagnostics() {
66818
66848
  if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
66819
66849
  checkGrammarComputedPropertyName(node.name);
66820
66850
  checkDecorators(node);
@@ -66858,8 +66888,6 @@ var ts;
66858
66888
  checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
66859
66889
  }
66860
66890
  }
66861
- checkSourceElement(node.body);
66862
- setNodeLinksForPrivateIdentifierScope(node);
66863
66891
  }
66864
66892
  function checkMissingDeclaration(node) {
66865
66893
  checkDecorators(node);
@@ -66902,11 +66930,13 @@ var ts;
66902
66930
  ts.forEach(node.typeArguments, checkSourceElement);
66903
66931
  var type = getTypeFromTypeReference(node);
66904
66932
  if (!isErrorType(type)) {
66905
- if (node.typeArguments && produceDiagnostics) {
66906
- var typeParameters = getTypeParametersForTypeReference(node);
66907
- if (typeParameters) {
66908
- checkTypeArgumentConstraints(node, typeParameters);
66909
- }
66933
+ if (node.typeArguments) {
66934
+ addLazyDiagnostic(function () {
66935
+ var typeParameters = getTypeParametersForTypeReference(node);
66936
+ if (typeParameters) {
66937
+ checkTypeArgumentConstraints(node, typeParameters);
66938
+ }
66939
+ });
66910
66940
  }
66911
66941
  var symbol = getNodeLinks(node).resolvedSymbol;
66912
66942
  if (symbol) {
@@ -66934,7 +66964,8 @@ var ts;
66934
66964
  }
66935
66965
  function checkTypeLiteral(node) {
66936
66966
  ts.forEach(node.members, checkSourceElement);
66937
- if (produceDiagnostics) {
66967
+ addLazyDiagnostic(checkTypeLiteralDiagnostics);
66968
+ function checkTypeLiteralDiagnostics() {
66938
66969
  var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
66939
66970
  checkIndexConstraints(type, type.symbol);
66940
66971
  checkTypeForDuplicateIndexSignatures(node);
@@ -67119,9 +67150,9 @@ var ts;
67119
67150
  return flags & flagsToCheck;
67120
67151
  }
67121
67152
  function checkFunctionOrConstructorSymbol(symbol) {
67122
- if (!produceDiagnostics) {
67123
- return;
67124
- }
67153
+ addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
67154
+ }
67155
+ function checkFunctionOrConstructorSymbolWorker(symbol) {
67125
67156
  function getCanonicalOverload(overloads, implementation) {
67126
67157
  var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
67127
67158
  return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
@@ -67314,9 +67345,9 @@ var ts;
67314
67345
  }
67315
67346
  }
67316
67347
  function checkExportsOnMergedDeclarations(node) {
67317
- if (!produceDiagnostics) {
67318
- return;
67319
- }
67348
+ addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); });
67349
+ }
67350
+ function checkExportsOnMergedDeclarationsWorker(node) {
67320
67351
  var symbol = node.localSymbol;
67321
67352
  if (!symbol) {
67322
67353
  symbol = getSymbolOfNode(node);
@@ -67764,7 +67795,8 @@ var ts;
67764
67795
  ts.forEach(node.decorators, checkDecorator);
67765
67796
  }
67766
67797
  function checkFunctionDeclaration(node) {
67767
- if (produceDiagnostics) {
67798
+ addLazyDiagnostic(checkFunctionDeclarationDiagnostics);
67799
+ function checkFunctionDeclarationDiagnostics() {
67768
67800
  checkFunctionOrMethodDeclaration(node);
67769
67801
  checkGrammarForGenerator(node);
67770
67802
  checkCollisionsForDeclarationName(node, node.name);
@@ -67797,10 +67829,13 @@ var ts;
67797
67829
  checkSourceElement(node.typeExpression);
67798
67830
  }
67799
67831
  function checkJSDocFunctionType(node) {
67800
- if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
67801
- reportImplicitAny(node, anyType);
67802
- }
67832
+ addLazyDiagnostic(checkJSDocFunctionTypeImplicitAny);
67803
67833
  checkSignatureDeclaration(node);
67834
+ function checkJSDocFunctionTypeImplicitAny() {
67835
+ if (!node.type && !ts.isJSDocConstructSignature(node)) {
67836
+ reportImplicitAny(node, anyType);
67837
+ }
67838
+ }
67804
67839
  }
67805
67840
  function checkJSDocImplementsTag(node) {
67806
67841
  var classLike = ts.getEffectiveJSDocHost(node);
@@ -67866,23 +67901,27 @@ var ts;
67866
67901
  var body = node.kind === 168 ? undefined : node.body;
67867
67902
  checkSourceElement(body);
67868
67903
  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
- }
67904
+ addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics);
67877
67905
  if (ts.isInJSFile(node)) {
67878
67906
  var typeTag = ts.getJSDocTypeTag(node);
67879
67907
  if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
67880
67908
  error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
67881
67909
  }
67882
67910
  }
67911
+ function checkFunctionOrMethodDeclarationDiagnostics() {
67912
+ if (!ts.getEffectiveReturnTypeNode(node)) {
67913
+ if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
67914
+ reportImplicitAny(node, anyType);
67915
+ }
67916
+ if (functionFlags & 1 && ts.nodeIsPresent(body)) {
67917
+ getReturnTypeOfSignature(getSignatureFromDeclaration(node));
67918
+ }
67919
+ }
67920
+ }
67883
67921
  }
67884
67922
  function registerForUnusedIdentifiersCheck(node) {
67885
- if (produceDiagnostics) {
67923
+ addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
67924
+ function registerForUnusedIdentifiersCheckDiagnostics() {
67886
67925
  var sourceFile = ts.getSourceFileOfNode(node);
67887
67926
  var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
67888
67927
  if (!potentiallyUnusedIdentifiers) {
@@ -69311,22 +69350,27 @@ var ts;
69311
69350
  hasDuplicateDefaultClause = true;
69312
69351
  }
69313
69352
  }
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
- }
69353
+ if (clause.kind === 289) {
69354
+ addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause));
69325
69355
  }
69326
69356
  ts.forEach(clause.statements, checkSourceElement);
69327
69357
  if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
69328
69358
  error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
69329
69359
  }
69360
+ function createLazyCaseClauseDiagnostics(clause) {
69361
+ return function () {
69362
+ var caseType = checkExpression(clause.expression);
69363
+ var caseIsLiteral = isLiteralType(caseType);
69364
+ var comparedExpressionType = expressionType;
69365
+ if (!caseIsLiteral || !expressionIsLiteral) {
69366
+ caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
69367
+ comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
69368
+ }
69369
+ if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
69370
+ checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
69371
+ }
69372
+ };
69373
+ }
69330
69374
  });
69331
69375
  if (node.caseBlock.locals) {
69332
69376
  registerForUnusedIdentifiersCheck(node.caseBlock);
@@ -69526,26 +69570,29 @@ var ts;
69526
69570
  }
69527
69571
  }
69528
69572
  function checkTypeParameters(typeParameterDeclarations) {
69573
+ var seenDefault = false;
69529
69574
  if (typeParameterDeclarations) {
69530
- var seenDefault = false;
69531
69575
  for (var i = 0; i < typeParameterDeclarations.length; i++) {
69532
69576
  var node = typeParameterDeclarations[i];
69533
69577
  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
- }
69578
+ addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
69579
+ }
69580
+ }
69581
+ function createCheckTypeParameterDiagnostic(node, i) {
69582
+ return function () {
69583
+ if (node.default) {
69584
+ seenDefault = true;
69585
+ checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
69586
+ }
69587
+ else if (seenDefault) {
69588
+ error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
69589
+ }
69590
+ for (var j = 0; j < i; j++) {
69591
+ if (typeParameterDeclarations[j].symbol === node.symbol) {
69592
+ error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
69546
69593
  }
69547
69594
  }
69548
- }
69595
+ };
69549
69596
  }
69550
69597
  }
69551
69598
  function checkTypeParametersNotReferenced(root, typeParameters, index) {
@@ -69663,82 +69710,87 @@ var ts;
69663
69710
  if (extendsNode && extendsNode !== baseTypeNode) {
69664
69711
  checkExpression(extendsNode.expression);
69665
69712
  }
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;
69713
+ var baseTypes_2 = getBaseTypes(type);
69714
+ if (baseTypes_2.length) {
69715
+ addLazyDiagnostic(function () {
69716
+ var baseType = baseTypes_2[0];
69717
+ var baseConstructorType = getBaseConstructorTypeOfClass(type);
69718
+ var staticBaseType = getApparentType(baseConstructorType);
69719
+ checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
69720
+ checkSourceElement(baseTypeNode.expression);
69721
+ if (ts.some(baseTypeNode.typeArguments)) {
69722
+ ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
69723
+ for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
69724
+ var constructor = _a[_i];
69725
+ if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
69726
+ break;
69727
+ }
69679
69728
  }
69680
69729
  }
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);
69730
+ var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
69731
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
69732
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
69692
69733
  }
69693
69734
  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);
69735
+ checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
69736
+ }
69737
+ if (baseConstructorType.flags & 8650752) {
69738
+ if (!isMixinConstructorType(staticType)) {
69739
+ error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
69740
+ }
69741
+ else {
69742
+ var constructSignatures = getSignaturesOfType(baseConstructorType, 1);
69743
+ if (constructSignatures.some(function (signature) { return signature.flags & 4; }) && !ts.hasSyntacticModifier(node, 128)) {
69744
+ 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);
69745
+ }
69697
69746
  }
69698
69747
  }
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);
69748
+ if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
69749
+ var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
69750
+ if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType); })) {
69751
+ error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
69752
+ }
69704
69753
  }
69705
- }
69706
- checkKindsOfPropertyMemberOverrides(type, baseType_1);
69754
+ checkKindsOfPropertyMemberOverrides(type, baseType);
69755
+ });
69707
69756
  }
69708
69757
  }
69709
69758
  checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
69710
69759
  var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
69711
69760
  if (implementedTypeNodes) {
69712
- for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
69713
- var typeRefNode = implementedTypeNodes_1[_b];
69761
+ for (var _i = 0, implementedTypeNodes_1 = implementedTypeNodes; _i < implementedTypeNodes_1.length; _i++) {
69762
+ var typeRefNode = implementedTypeNodes_1[_i];
69714
69763
  if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
69715
69764
  error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
69716
69765
  }
69717
69766
  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
- }
69767
+ addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
69735
69768
  }
69736
69769
  }
69737
- if (produceDiagnostics) {
69770
+ addLazyDiagnostic(function () {
69738
69771
  checkIndexConstraints(type, symbol);
69739
69772
  checkIndexConstraints(staticType, symbol, true);
69740
69773
  checkTypeForDuplicateIndexSignatures(node);
69741
69774
  checkPropertyInitialization(node);
69775
+ });
69776
+ function createImplementsDiagnostics(typeRefNode) {
69777
+ return function () {
69778
+ var t = getReducedType(getTypeFromTypeNode(typeRefNode));
69779
+ if (!isErrorType(t)) {
69780
+ if (isValidBaseType(t)) {
69781
+ var genericDiag = t.symbol && t.symbol.flags & 32 ?
69782
+ ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
69783
+ ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
69784
+ var baseWithThis = getTypeWithThisArgument(t, type.thisType);
69785
+ if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
69786
+ issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
69787
+ }
69788
+ }
69789
+ else {
69790
+ error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
69791
+ }
69792
+ }
69793
+ };
69742
69794
  }
69743
69795
  }
69744
69796
  function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
@@ -70005,8 +70057,8 @@ var ts;
70005
70057
  ts.forEach(properties, function (p) {
70006
70058
  seen.set(p.escapedName, p);
70007
70059
  });
70008
- for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
70009
- var base = baseTypes_2[_i];
70060
+ for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
70061
+ var base = baseTypes_3[_i];
70010
70062
  var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
70011
70063
  for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
70012
70064
  var prop = properties_4[_a];
@@ -70028,8 +70080,8 @@ var ts;
70028
70080
  seen.set(p.escapedName, { prop: p, containingType: type });
70029
70081
  });
70030
70082
  var ok = true;
70031
- for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
70032
- var base = baseTypes_3[_i];
70083
+ for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
70084
+ var base = baseTypes_4[_i];
70033
70085
  var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
70034
70086
  for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
70035
70087
  var prop = properties_6[_a];
@@ -70111,7 +70163,7 @@ var ts;
70111
70163
  if (!checkGrammarDecoratorsAndModifiers(node))
70112
70164
  checkGrammarInterfaceDeclaration(node);
70113
70165
  checkTypeParameters(node.typeParameters);
70114
- if (produceDiagnostics) {
70166
+ addLazyDiagnostic(function () {
70115
70167
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
70116
70168
  checkExportsOnMergedDeclarations(node);
70117
70169
  var symbol = getSymbolOfNode(node);
@@ -70129,7 +70181,7 @@ var ts;
70129
70181
  }
70130
70182
  }
70131
70183
  checkObjectTypeForDuplicateDeclarations(node);
70132
- }
70184
+ });
70133
70185
  ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
70134
70186
  if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
70135
70187
  error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
@@ -70137,10 +70189,10 @@ var ts;
70137
70189
  checkTypeReferenceNode(heritageElement);
70138
70190
  });
70139
70191
  ts.forEach(node.members, checkSourceElement);
70140
- if (produceDiagnostics) {
70192
+ addLazyDiagnostic(function () {
70141
70193
  checkTypeForDuplicateIndexSignatures(node);
70142
70194
  registerForUnusedIdentifiersCheck(node);
70143
- }
70195
+ });
70144
70196
  }
70145
70197
  function checkTypeAliasDeclaration(node) {
70146
70198
  checkGrammarDecoratorsAndModifiers(node);
@@ -70321,9 +70373,9 @@ var ts;
70321
70373
  ts.isStringLiteralLike(node.argumentExpression);
70322
70374
  }
70323
70375
  function checkEnumDeclaration(node) {
70324
- if (!produceDiagnostics) {
70325
- return;
70326
- }
70376
+ addLazyDiagnostic(function () { return checkEnumDeclarationWorker(node); });
70377
+ }
70378
+ function checkEnumDeclarationWorker(node) {
70327
70379
  checkGrammarDecoratorsAndModifiers(node);
70328
70380
  checkCollisionsForDeclarationName(node, node.name);
70329
70381
  checkExportsOnMergedDeclarations(node);
@@ -70394,7 +70446,14 @@ var ts;
70394
70446
  }
70395
70447
  }
70396
70448
  function checkModuleDeclaration(node) {
70397
- if (produceDiagnostics) {
70449
+ if (node.body) {
70450
+ checkSourceElement(node.body);
70451
+ if (!ts.isGlobalScopeAugmentation(node)) {
70452
+ registerForUnusedIdentifiersCheck(node);
70453
+ }
70454
+ }
70455
+ addLazyDiagnostic(checkModuleDeclarationDiagnostics);
70456
+ function checkModuleDeclarationDiagnostics() {
70398
70457
  var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
70399
70458
  var inAmbientContext = node.flags & 8388608;
70400
70459
  if (isGlobalAugmentation && !inAmbientContext) {
@@ -70465,12 +70524,6 @@ var ts;
70465
70524
  }
70466
70525
  }
70467
70526
  }
70468
- if (node.body) {
70469
- checkSourceElement(node.body);
70470
- if (!ts.isGlobalScopeAugmentation(node)) {
70471
- registerForUnusedIdentifiersCheck(node);
70472
- }
70473
- }
70474
70527
  }
70475
70528
  function checkModuleAugmentationElement(node, isGlobalAugmentation) {
70476
70529
  var _a;
@@ -71329,13 +71382,15 @@ var ts;
71329
71382
  if (ts.isExternalOrCommonJsModule(node)) {
71330
71383
  registerForUnusedIdentifiersCheck(node);
71331
71384
  }
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
- }
71385
+ addLazyDiagnostic(function () {
71386
+ if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
71387
+ checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
71388
+ if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
71389
+ diagnostics.add(diag);
71390
+ }
71391
+ });
71392
+ }
71393
+ });
71339
71394
  if (compilerOptions.importsNotUsedAsValues === 2 &&
71340
71395
  !node.isDeclarationFile &&
71341
71396
  ts.isExternalModule(node)) {
@@ -71372,12 +71427,26 @@ var ts;
71372
71427
  cancellationToken = undefined;
71373
71428
  }
71374
71429
  }
71430
+ function ensurePendingDiagnosticWorkComplete() {
71431
+ for (var _i = 0, deferredDiagnosticsCallbacks_1 = deferredDiagnosticsCallbacks; _i < deferredDiagnosticsCallbacks_1.length; _i++) {
71432
+ var cb = deferredDiagnosticsCallbacks_1[_i];
71433
+ cb();
71434
+ }
71435
+ deferredDiagnosticsCallbacks = [];
71436
+ }
71437
+ function checkSourceFileWithEagerDiagnostics(sourceFile) {
71438
+ ensurePendingDiagnosticWorkComplete();
71439
+ var oldAddLazyDiagnostics = addLazyDiagnostic;
71440
+ addLazyDiagnostic = function (cb) { return cb(); };
71441
+ checkSourceFile(sourceFile);
71442
+ addLazyDiagnostic = oldAddLazyDiagnostics;
71443
+ }
71375
71444
  function getDiagnosticsWorker(sourceFile) {
71376
- throwIfNonDiagnosticsProducing();
71377
71445
  if (sourceFile) {
71446
+ ensurePendingDiagnosticWorkComplete();
71378
71447
  var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
71379
71448
  var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
71380
- checkSourceFile(sourceFile);
71449
+ checkSourceFileWithEagerDiagnostics(sourceFile);
71381
71450
  var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
71382
71451
  var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
71383
71452
  if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
@@ -71389,18 +71458,13 @@ var ts;
71389
71458
  }
71390
71459
  return semanticDiagnostics;
71391
71460
  }
71392
- ts.forEach(host.getSourceFiles(), checkSourceFile);
71461
+ ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
71393
71462
  return diagnostics.getDiagnostics();
71394
71463
  }
71395
71464
  function getGlobalDiagnostics() {
71396
- throwIfNonDiagnosticsProducing();
71465
+ ensurePendingDiagnosticWorkComplete();
71397
71466
  return diagnostics.getGlobalDiagnostics();
71398
71467
  }
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
71468
  function getSymbolsInScope(location, meaning) {
71405
71469
  if (location.flags & 16777216) {
71406
71470
  return [];
@@ -95394,8 +95458,7 @@ var ts;
95394
95458
  var files;
95395
95459
  var symlinks;
95396
95460
  var commonSourceDirectory;
95397
- var diagnosticsProducingTypeChecker;
95398
- var noDiagnosticsTypeChecker;
95461
+ var typeChecker;
95399
95462
  var classifiableNames;
95400
95463
  var ambientModuleNameToUnmodifiedFileName = new ts.Map();
95401
95464
  var fileReasons = ts.createMultiMap();
@@ -95599,21 +95662,19 @@ var ts;
95599
95662
  getProgramDiagnostics: getProgramDiagnostics,
95600
95663
  getTypeChecker: getTypeChecker,
95601
95664
  getClassifiableNames: getClassifiableNames,
95602
- getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
95603
95665
  getCommonSourceDirectory: getCommonSourceDirectory,
95604
95666
  emit: emit,
95605
95667
  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(); },
95668
+ getNodeCount: function () { return getTypeChecker().getNodeCount(); },
95669
+ getIdentifierCount: function () { return getTypeChecker().getIdentifierCount(); },
95670
+ getSymbolCount: function () { return getTypeChecker().getSymbolCount(); },
95671
+ getTypeCount: function () { return getTypeChecker().getTypeCount(); },
95672
+ getInstantiationCount: function () { return getTypeChecker().getInstantiationCount(); },
95673
+ getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
95612
95674
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
95613
95675
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
95614
95676
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
95615
95677
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
95616
- dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
95617
95678
  getSourceFileFromReference: getSourceFileFromReference,
95618
95679
  getLibFileFromReference: getLibFileFromReference,
95619
95680
  sourceFileToPackageName: sourceFileToPackageName,
@@ -96100,14 +96161,8 @@ var ts;
96100
96161
  return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); });
96101
96162
  }
96102
96163
  }
96103
- function getDiagnosticsProducingTypeChecker() {
96104
- return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
96105
- }
96106
- function dropDiagnosticsProducingTypeChecker() {
96107
- diagnosticsProducingTypeChecker = undefined;
96108
- }
96109
96164
  function getTypeChecker() {
96110
- return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
96165
+ return typeChecker || (typeChecker = ts.createTypeChecker(program));
96111
96166
  }
96112
96167
  function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
96113
96168
  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 +96179,7 @@ var ts;
96124
96179
  if (result)
96125
96180
  return result;
96126
96181
  }
96127
- var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
96182
+ var emitResolver = getTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
96128
96183
  ts.performance.mark("beforeEmit");
96129
96184
  var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
96130
96185
  ts.performance.mark("afterEmit");
@@ -96198,8 +96253,7 @@ var ts;
96198
96253
  }
96199
96254
  catch (e) {
96200
96255
  if (e instanceof ts.OperationCanceledException) {
96201
- noDiagnosticsTypeChecker = undefined;
96202
- diagnosticsProducingTypeChecker = undefined;
96256
+ typeChecker = undefined;
96203
96257
  }
96204
96258
  throw e;
96205
96259
  }
@@ -96215,7 +96269,7 @@ var ts;
96215
96269
  if (ts.skipTypeChecking(sourceFile, options, program)) {
96216
96270
  return ts.emptyArray;
96217
96271
  }
96218
- var typeChecker = getDiagnosticsProducingTypeChecker();
96272
+ var typeChecker = getTypeChecker();
96219
96273
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
96220
96274
  var isJs = sourceFile.scriptKind === 1 || sourceFile.scriptKind === 2;
96221
96275
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
@@ -96256,7 +96310,7 @@ var ts;
96256
96310
  }
96257
96311
  function getSuggestionDiagnostics(sourceFile, cancellationToken) {
96258
96312
  return runWithCancellationToken(function () {
96259
- return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
96313
+ return getTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
96260
96314
  });
96261
96315
  }
96262
96316
  function markPrecedingCommentDirectiveLine(diagnostic, directives) {
@@ -96455,7 +96509,7 @@ var ts;
96455
96509
  }
96456
96510
  function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
96457
96511
  return runWithCancellationToken(function () {
96458
- var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
96512
+ var resolver = getTypeChecker().getEmitResolver(sourceFile, cancellationToken);
96459
96513
  return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
96460
96514
  });
96461
96515
  }
@@ -96492,7 +96546,7 @@ var ts;
96492
96546
  return diagnostics;
96493
96547
  }
96494
96548
  function getGlobalDiagnostics() {
96495
- return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
96549
+ return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
96496
96550
  }
96497
96551
  function getConfigFileParsingDiagnostics() {
96498
96552
  return configFileParsingDiagnostics || ts.emptyArray;