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