@typescript-deploys/pr-build 4.7.0-pr-48294-7 → 4.7.0-pr-36747-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cs/diagnosticMessages.generated.json +35 -35
- package/lib/de/diagnosticMessages.generated.json +35 -35
- package/lib/es/diagnosticMessages.generated.json +28 -28
- package/lib/fr/diagnosticMessages.generated.json +17 -17
- package/lib/it/diagnosticMessages.generated.json +37 -37
- package/lib/ja/diagnosticMessages.generated.json +16 -16
- package/lib/ko/diagnosticMessages.generated.json +36 -36
- package/lib/pl/diagnosticMessages.generated.json +20 -20
- package/lib/pt-br/diagnosticMessages.generated.json +26 -26
- package/lib/ru/diagnosticMessages.generated.json +24 -24
- package/lib/tr/diagnosticMessages.generated.json +6 -6
- package/lib/tsc.js +485 -463
- package/lib/tsserver.js +735 -590
- package/lib/tsserverlibrary.js +735 -590
- package/lib/typescript.js +714 -588
- package/lib/typescriptServices.js +714 -588
- package/lib/typingsInstaller.js +566 -530
- package/lib/zh-cn/diagnosticMessages.generated.json +25 -25
- package/lib/zh-tw/diagnosticMessages.generated.json +37 -37
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220321";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8444,6 +8444,7 @@ var ts;
|
|
|
8444
8444
|
Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
|
|
8445
8445
|
Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
|
|
8446
8446
|
Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
|
|
8447
|
+
A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled: diag(1272, ts.DiagnosticCategory.Error, "A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_w_1272", "A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled."),
|
|
8447
8448
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8448
8449
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8449
8450
|
Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
|
|
@@ -41089,7 +41090,10 @@ var ts;
|
|
|
41089
41090
|
* file to. e.g. outDir
|
|
41090
41091
|
*/
|
|
41091
41092
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
41092
|
-
|
|
41093
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName });
|
|
41094
|
+
var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
|
|
41095
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
41096
|
+
return result;
|
|
41093
41097
|
}
|
|
41094
41098
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
41095
41099
|
/*@internal*/
|
|
@@ -47663,7 +47667,7 @@ var ts;
|
|
|
47663
47667
|
(preserveConstEnums && moduleState === 2 /* ConstEnumOnly */);
|
|
47664
47668
|
}
|
|
47665
47669
|
ts.isInstantiatedModule = isInstantiatedModule;
|
|
47666
|
-
function createTypeChecker(host
|
|
47670
|
+
function createTypeChecker(host) {
|
|
47667
47671
|
var getPackagesMap = ts.memoize(function () {
|
|
47668
47672
|
// A package name maps to true when we detect it has .d.ts files.
|
|
47669
47673
|
// This is useful as an approximation of whether a package bundles its own types.
|
|
@@ -47680,6 +47684,10 @@ var ts;
|
|
|
47680
47684
|
});
|
|
47681
47685
|
return map;
|
|
47682
47686
|
});
|
|
47687
|
+
var deferredDiagnosticsCallbacks = [];
|
|
47688
|
+
var addLazyDiagnostic = function (arg) {
|
|
47689
|
+
deferredDiagnosticsCallbacks.push(arg);
|
|
47690
|
+
};
|
|
47683
47691
|
// Cancellation that controls whether or not we can cancel in the middle of type checking.
|
|
47684
47692
|
// In general cancelling is *not* safe for the type checker. We might be in the middle of
|
|
47685
47693
|
// computing something, and we will leave our internals in an inconsistent state. Callers
|
|
@@ -48042,8 +48050,8 @@ var ts;
|
|
|
48042
48050
|
// Do this in a finally block so we can ensure that it gets reset back to nothing after
|
|
48043
48051
|
// this call is done.
|
|
48044
48052
|
cancellationToken = ct;
|
|
48045
|
-
// Ensure file is type checked
|
|
48046
|
-
|
|
48053
|
+
// Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused
|
|
48054
|
+
checkSourceFileWithEagerDiagnostics(file);
|
|
48047
48055
|
ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
48048
48056
|
diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
48049
48057
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
|
|
@@ -49378,110 +49386,114 @@ var ts;
|
|
|
49378
49386
|
}
|
|
49379
49387
|
}
|
|
49380
49388
|
if (!result) {
|
|
49381
|
-
if (nameNotFoundMessage
|
|
49382
|
-
|
|
49383
|
-
!
|
|
49384
|
-
!
|
|
49385
|
-
|
|
49386
|
-
|
|
49387
|
-
|
|
49388
|
-
|
|
49389
|
-
|
|
49390
|
-
|
|
49391
|
-
|
|
49392
|
-
|
|
49393
|
-
|
|
49394
|
-
|
|
49395
|
-
|
|
49396
|
-
|
|
49397
|
-
if (suggestion) {
|
|
49398
|
-
var suggestionName = symbolToString(suggestion);
|
|
49399
|
-
var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
|
|
49400
|
-
var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
|
|
49401
|
-
: isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
|
|
49402
|
-
: ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
|
|
49403
|
-
var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
|
|
49404
|
-
addErrorOrSuggestion(!isUncheckedJS, diagnostic);
|
|
49405
|
-
if (suggestion.valueDeclaration) {
|
|
49406
|
-
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
|
|
49389
|
+
if (nameNotFoundMessage) {
|
|
49390
|
+
addLazyDiagnostic(function () {
|
|
49391
|
+
if (!errorLocation ||
|
|
49392
|
+
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
49393
|
+
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
49394
|
+
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
49395
|
+
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
49396
|
+
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
49397
|
+
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
49398
|
+
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
49399
|
+
var suggestion = void 0;
|
|
49400
|
+
if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
49401
|
+
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
49402
|
+
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
49403
|
+
if (isGlobalScopeAugmentationDeclaration) {
|
|
49404
|
+
suggestion = undefined;
|
|
49407
49405
|
}
|
|
49408
|
-
|
|
49409
|
-
|
|
49410
|
-
|
|
49411
|
-
|
|
49412
|
-
|
|
49413
|
-
|
|
49414
|
-
|
|
49406
|
+
if (suggestion) {
|
|
49407
|
+
var suggestionName = symbolToString(suggestion);
|
|
49408
|
+
var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
|
|
49409
|
+
var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
|
|
49410
|
+
: isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
|
|
49411
|
+
: ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
|
|
49412
|
+
var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
|
|
49413
|
+
addErrorOrSuggestion(!isUncheckedJS, diagnostic);
|
|
49414
|
+
if (suggestion.valueDeclaration) {
|
|
49415
|
+
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
|
|
49416
|
+
}
|
|
49415
49417
|
}
|
|
49416
|
-
|
|
49417
|
-
|
|
49418
|
+
}
|
|
49419
|
+
if (!suggestion) {
|
|
49420
|
+
if (nameArg) {
|
|
49421
|
+
var lib = getSuggestedLibForNonExistentName(nameArg);
|
|
49422
|
+
if (lib) {
|
|
49423
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
|
|
49424
|
+
}
|
|
49425
|
+
else {
|
|
49426
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
49427
|
+
}
|
|
49418
49428
|
}
|
|
49419
49429
|
}
|
|
49430
|
+
suggestionCount++;
|
|
49420
49431
|
}
|
|
49421
|
-
|
|
49422
|
-
}
|
|
49432
|
+
});
|
|
49423
49433
|
}
|
|
49424
49434
|
return undefined;
|
|
49425
49435
|
}
|
|
49436
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
49437
|
+
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
49438
|
+
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
49439
|
+
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
49440
|
+
var propertyName = propertyWithInvalidInitializer.name;
|
|
49441
|
+
error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
|
|
49442
|
+
return undefined;
|
|
49443
|
+
}
|
|
49426
49444
|
// Perform extra checks only if error reporting was requested
|
|
49427
|
-
if (nameNotFoundMessage
|
|
49428
|
-
|
|
49429
|
-
//
|
|
49430
|
-
//
|
|
49431
|
-
//
|
|
49432
|
-
|
|
49433
|
-
|
|
49434
|
-
|
|
49435
|
-
|
|
49436
|
-
|
|
49437
|
-
|
|
49438
|
-
|
|
49439
|
-
|
|
49440
|
-
|
|
49441
|
-
|
|
49442
|
-
|
|
49443
|
-
|
|
49444
|
-
|
|
49445
|
-
|
|
49446
|
-
|
|
49447
|
-
|
|
49448
|
-
|
|
49449
|
-
|
|
49450
|
-
|
|
49451
|
-
|
|
49452
|
-
|
|
49453
|
-
|
|
49454
|
-
|
|
49455
|
-
|
|
49456
|
-
|
|
49457
|
-
|
|
49458
|
-
|
|
49459
|
-
|
|
49460
|
-
|
|
49461
|
-
|
|
49462
|
-
|
|
49463
|
-
|
|
49464
|
-
|
|
49465
|
-
|
|
49466
|
-
|
|
49467
|
-
|
|
49468
|
-
|
|
49469
|
-
|
|
49470
|
-
|
|
49471
|
-
|
|
49472
|
-
|
|
49473
|
-
|
|
49474
|
-
|
|
49475
|
-
|
|
49476
|
-
|
|
49477
|
-
if (typeOnlyDeclaration) {
|
|
49478
|
-
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
49479
|
-
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
49480
|
-
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
49481
|
-
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
49482
|
-
addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
49445
|
+
if (nameNotFoundMessage) {
|
|
49446
|
+
addLazyDiagnostic(function () {
|
|
49447
|
+
// Only check for block-scoped variable if we have an error location and are looking for the
|
|
49448
|
+
// name with variable meaning
|
|
49449
|
+
// For example,
|
|
49450
|
+
// declare module foo {
|
|
49451
|
+
// interface bar {}
|
|
49452
|
+
// }
|
|
49453
|
+
// const foo/*1*/: foo/*2*/.bar;
|
|
49454
|
+
// The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
|
|
49455
|
+
// block-scoped variable and namespace module. However, only when we
|
|
49456
|
+
// try to resolve name in /*1*/ which is used in variable position,
|
|
49457
|
+
// we want to check for block-scoped
|
|
49458
|
+
if (errorLocation &&
|
|
49459
|
+
(meaning & 2 /* BlockScopedVariable */ ||
|
|
49460
|
+
((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) {
|
|
49461
|
+
var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
|
|
49462
|
+
if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
|
|
49463
|
+
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
|
49464
|
+
}
|
|
49465
|
+
}
|
|
49466
|
+
// If we're in an external module, we can't reference value symbols created from UMD export declarations
|
|
49467
|
+
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
|
|
49468
|
+
var merged = getMergedSymbol(result);
|
|
49469
|
+
if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
|
|
49470
|
+
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));
|
|
49471
|
+
}
|
|
49472
|
+
}
|
|
49473
|
+
// 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
|
|
49474
|
+
if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) {
|
|
49475
|
+
var candidate = getMergedSymbol(getLateBoundSymbol(result));
|
|
49476
|
+
var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
|
|
49477
|
+
// A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
|
|
49478
|
+
if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
|
|
49479
|
+
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
|
|
49480
|
+
}
|
|
49481
|
+
// And it cannot refer to any declarations which come after it
|
|
49482
|
+
else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
|
|
49483
|
+
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
|
|
49484
|
+
}
|
|
49485
|
+
}
|
|
49486
|
+
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
49487
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
49488
|
+
if (typeOnlyDeclaration) {
|
|
49489
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
49490
|
+
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
49491
|
+
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
49492
|
+
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
49493
|
+
addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
49494
|
+
}
|
|
49483
49495
|
}
|
|
49484
|
-
}
|
|
49496
|
+
});
|
|
49485
49497
|
}
|
|
49486
49498
|
return result;
|
|
49487
49499
|
}
|
|
@@ -51127,9 +51139,7 @@ var ts;
|
|
|
51127
51139
|
var result = new Type(checker, flags);
|
|
51128
51140
|
typeCount++;
|
|
51129
51141
|
result.id = typeCount;
|
|
51130
|
-
|
|
51131
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
|
|
51132
|
-
}
|
|
51142
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
|
|
51133
51143
|
return result;
|
|
51134
51144
|
}
|
|
51135
51145
|
function createOriginType(flags) {
|
|
@@ -55112,7 +55122,7 @@ var ts;
|
|
|
55112
55122
|
if (!omitTypeAlias) {
|
|
55113
55123
|
return errorType;
|
|
55114
55124
|
}
|
|
55115
|
-
return
|
|
55125
|
+
return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
|
|
55116
55126
|
}
|
|
55117
55127
|
var members = ts.createSymbolTable();
|
|
55118
55128
|
for (var _b = 0, spreadableProperties_1 = spreadableProperties; _b < spreadableProperties_1.length; _b++) {
|
|
@@ -56879,7 +56889,7 @@ var ts;
|
|
|
56879
56889
|
}
|
|
56880
56890
|
}
|
|
56881
56891
|
if (memberTypeList.length) {
|
|
56882
|
-
var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined
|
|
56892
|
+
var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined);
|
|
56883
56893
|
if (enumType_1.flags & 1048576 /* Union */) {
|
|
56884
56894
|
enumType_1.flags |= 1024 /* EnumLiteral */;
|
|
56885
56895
|
enumType_1.symbol = symbol;
|
|
@@ -59602,7 +59612,7 @@ var ts;
|
|
|
59602
59612
|
type.resolvedTypeArguments = source.resolvedTypeArguments;
|
|
59603
59613
|
return type;
|
|
59604
59614
|
}
|
|
59605
|
-
function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments
|
|
59615
|
+
function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) {
|
|
59606
59616
|
if (!aliasSymbol) {
|
|
59607
59617
|
aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
59608
59618
|
var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
|
|
@@ -59614,7 +59624,6 @@ var ts;
|
|
|
59614
59624
|
type.mapper = mapper;
|
|
59615
59625
|
type.aliasSymbol = aliasSymbol;
|
|
59616
59626
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
59617
|
-
type.aliasMapper = aliasMapper;
|
|
59618
59627
|
return type;
|
|
59619
59628
|
}
|
|
59620
59629
|
function getTypeArguments(type) {
|
|
@@ -59679,7 +59688,7 @@ var ts;
|
|
|
59679
59688
|
}
|
|
59680
59689
|
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
|
59681
59690
|
}
|
|
59682
|
-
function
|
|
59691
|
+
function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
|
|
59683
59692
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
59684
59693
|
if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
|
|
59685
59694
|
return getStringMappingType(symbol, typeArguments[0]);
|
|
@@ -59693,33 +59702,6 @@ var ts;
|
|
|
59693
59702
|
}
|
|
59694
59703
|
return instantiation;
|
|
59695
59704
|
}
|
|
59696
|
-
function getLocalTypeAliasInstantiation(symbol, typeArguments, outerTypeParameterMapper, aliasSymbol, aliasTypeArguments) {
|
|
59697
|
-
var type = getDeclaredTypeOfSymbol(symbol);
|
|
59698
|
-
if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
|
|
59699
|
-
return getStringMappingType(symbol, typeArguments[0]);
|
|
59700
|
-
}
|
|
59701
|
-
var links = getSymbolLinks(symbol);
|
|
59702
|
-
var outerTypeParameters = getOuterTypeParametersOfAlias(symbol);
|
|
59703
|
-
var mappedOuterParams = outerTypeParameterMapper && outerTypeParameters && instantiateTypes(outerTypeParameters, outerTypeParameterMapper);
|
|
59704
|
-
var typeParameters = links.typeParameters;
|
|
59705
|
-
var id = getTypeListId(ts.concatenate(mappedOuterParams, typeArguments)) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
59706
|
-
var instantiation = links.instantiations.get(id);
|
|
59707
|
-
if (!instantiation) {
|
|
59708
|
-
var outerTypeArgumentMapper = outerTypeParameters && mappedOuterParams && createTypeMapper(outerTypeParameters, mappedOuterParams);
|
|
59709
|
-
var argumentMapper = createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)));
|
|
59710
|
-
var combinedMapper = outerTypeArgumentMapper ? combineTypeMappers(argumentMapper, outerTypeArgumentMapper) : argumentMapper;
|
|
59711
|
-
links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, combinedMapper, aliasSymbol, aliasTypeArguments));
|
|
59712
|
-
}
|
|
59713
|
-
return instantiation;
|
|
59714
|
-
}
|
|
59715
|
-
function getOuterTypeParametersOfAlias(symbol) {
|
|
59716
|
-
var _a;
|
|
59717
|
-
var links = getSymbolLinks(symbol);
|
|
59718
|
-
if (!links.outerTypeParameters) {
|
|
59719
|
-
links.outerTypeParameters = ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) && getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true);
|
|
59720
|
-
}
|
|
59721
|
-
return links.outerTypeParameters;
|
|
59722
|
-
}
|
|
59723
59705
|
/**
|
|
59724
59706
|
* Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
|
|
59725
59707
|
* references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
|
|
@@ -59755,7 +59737,7 @@ var ts;
|
|
|
59755
59737
|
// a .d.ts file. See #43622 for an example.
|
|
59756
59738
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
59757
59739
|
var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined;
|
|
59758
|
-
return
|
|
59740
|
+
return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
|
|
59759
59741
|
}
|
|
59760
59742
|
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
|
59761
59743
|
}
|
|
@@ -60670,7 +60652,14 @@ var ts;
|
|
|
60670
60652
|
result.types = types;
|
|
60671
60653
|
return result;
|
|
60672
60654
|
}
|
|
60673
|
-
|
|
60655
|
+
// We sort and deduplicate the constituent types based on object identity. If the subtypeReduction
|
|
60656
|
+
// flag is specified we also reduce the constituent type set to only include types that aren't subtypes
|
|
60657
|
+
// of other types. Subtype reduction is expensive for large union types and is possible only when union
|
|
60658
|
+
// types are known not to circularly reference themselves (as is the case with union types created by
|
|
60659
|
+
// expression constructs such as array literals and the || and ?: operators). Named types can
|
|
60660
|
+
// circularly reference themselves and therefore cannot be subtype reduced during their declaration.
|
|
60661
|
+
// For example, "type Item = string | (() => Item" is a named type that circularly references itself.
|
|
60662
|
+
function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
|
|
60674
60663
|
if (unionReduction === void 0) { unionReduction = 1 /* Literal */; }
|
|
60675
60664
|
if (types.length === 0) {
|
|
60676
60665
|
return neverType;
|
|
@@ -60739,7 +60728,7 @@ var ts;
|
|
|
60739
60728
|
}
|
|
60740
60729
|
var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
|
|
60741
60730
|
(includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
|
|
60742
|
-
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments,
|
|
60731
|
+
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
60743
60732
|
}
|
|
60744
60733
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
60745
60734
|
var first;
|
|
@@ -60777,7 +60766,7 @@ var ts;
|
|
|
60777
60766
|
return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
|
|
60778
60767
|
}
|
|
60779
60768
|
// This function assumes the constituent type list is sorted and deduplicated.
|
|
60780
|
-
function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments,
|
|
60769
|
+
function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) {
|
|
60781
60770
|
if (types.length === 0) {
|
|
60782
60771
|
return neverType;
|
|
60783
60772
|
}
|
|
@@ -60797,7 +60786,6 @@ var ts;
|
|
|
60797
60786
|
type.origin = origin;
|
|
60798
60787
|
type.aliasSymbol = aliasSymbol;
|
|
60799
60788
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
60800
|
-
type.aliasMapper = aliasMapper;
|
|
60801
60789
|
if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
|
|
60802
60790
|
type.flags |= 16 /* Boolean */;
|
|
60803
60791
|
type.intrinsicName = "boolean";
|
|
@@ -60810,7 +60798,7 @@ var ts;
|
|
|
60810
60798
|
var links = getNodeLinks(node);
|
|
60811
60799
|
if (!links.resolvedType) {
|
|
60812
60800
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
60813
|
-
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)
|
|
60801
|
+
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
60814
60802
|
}
|
|
60815
60803
|
return links.resolvedType;
|
|
60816
60804
|
}
|
|
@@ -60969,16 +60957,25 @@ var ts;
|
|
|
60969
60957
|
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
|
|
60970
60958
|
return true;
|
|
60971
60959
|
}
|
|
60972
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments
|
|
60960
|
+
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
60973
60961
|
var result = createType(2097152 /* Intersection */);
|
|
60974
60962
|
result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
|
|
60975
60963
|
result.types = types;
|
|
60976
60964
|
result.aliasSymbol = aliasSymbol;
|
|
60977
60965
|
result.aliasTypeArguments = aliasTypeArguments;
|
|
60978
|
-
result.aliasMapper = aliasMapper;
|
|
60979
60966
|
return result;
|
|
60980
60967
|
}
|
|
60981
|
-
|
|
60968
|
+
// We normalize combinations of intersection and union types based on the distributive property of the '&'
|
|
60969
|
+
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
|
|
60970
|
+
// types with union type constituents into equivalent union types with intersection type constituents and
|
|
60971
|
+
// effectively ensure that union types are always at the top level in type representations.
|
|
60972
|
+
//
|
|
60973
|
+
// We do not perform structural deduplication on intersection types. Intersection types are created only by the &
|
|
60974
|
+
// type operator and we can't reduce those because we want to support recursive intersection types. For example,
|
|
60975
|
+
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
|
60976
|
+
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
|
60977
|
+
// for intersections of types with signatures can be deterministic.
|
|
60978
|
+
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
60982
60979
|
var typeMembershipMap = new ts.Map();
|
|
60983
60980
|
var includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
60984
60981
|
var typeSet = ts.arrayFrom(typeMembershipMap.values());
|
|
@@ -61038,16 +61035,16 @@ var ts;
|
|
|
61038
61035
|
// When the intersection creates a reduced set (which might mean that *all* union types have
|
|
61039
61036
|
// disappeared), we restart the operation to get a new set of combined flags. Once we have
|
|
61040
61037
|
// reduced we'll never reduce again, so this occurs at most once.
|
|
61041
|
-
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments
|
|
61038
|
+
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
61042
61039
|
}
|
|
61043
61040
|
else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
|
|
61044
61041
|
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
|
|
61045
61042
|
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
61046
|
-
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
61043
|
+
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
61047
61044
|
}
|
|
61048
61045
|
else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
|
|
61049
61046
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
61050
|
-
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
61047
|
+
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
61051
61048
|
}
|
|
61052
61049
|
else {
|
|
61053
61050
|
// We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of
|
|
@@ -61060,7 +61057,7 @@ var ts;
|
|
|
61060
61057
|
// We attach a denormalized origin type when at least one constituent of the cross-product union is an
|
|
61061
61058
|
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
|
|
61062
61059
|
var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
|
|
61063
|
-
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments,
|
|
61060
|
+
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
61064
61061
|
}
|
|
61065
61062
|
}
|
|
61066
61063
|
else {
|
|
@@ -61106,7 +61103,7 @@ var ts;
|
|
|
61106
61103
|
var links = getNodeLinks(node);
|
|
61107
61104
|
if (!links.resolvedType) {
|
|
61108
61105
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
61109
|
-
links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)
|
|
61106
|
+
links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
61110
61107
|
}
|
|
61111
61108
|
return links.resolvedType;
|
|
61112
61109
|
}
|
|
@@ -61225,7 +61222,7 @@ var ts;
|
|
|
61225
61222
|
var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ?
|
|
61226
61223
|
info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; });
|
|
61227
61224
|
return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
|
|
61228
|
-
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined,
|
|
61225
|
+
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
|
|
61229
61226
|
}
|
|
61230
61227
|
/**
|
|
61231
61228
|
* A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
|
|
@@ -61258,7 +61255,7 @@ var ts;
|
|
|
61258
61255
|
return type;
|
|
61259
61256
|
}
|
|
61260
61257
|
var extractTypeAlias = getGlobalExtractSymbol();
|
|
61261
|
-
return extractTypeAlias ?
|
|
61258
|
+
return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
|
|
61262
61259
|
}
|
|
61263
61260
|
function getIndexTypeOrString(type) {
|
|
61264
61261
|
var indexType = getExtractStringType(getIndexType(type));
|
|
@@ -61388,14 +61385,13 @@ var ts;
|
|
|
61388
61385
|
result.type = type;
|
|
61389
61386
|
return result;
|
|
61390
61387
|
}
|
|
61391
|
-
function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments
|
|
61388
|
+
function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) {
|
|
61392
61389
|
var type = createType(8388608 /* IndexedAccess */);
|
|
61393
61390
|
type.objectType = objectType;
|
|
61394
61391
|
type.indexType = indexType;
|
|
61395
61392
|
type.accessFlags = accessFlags;
|
|
61396
61393
|
type.aliasSymbol = aliasSymbol;
|
|
61397
61394
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
61398
|
-
type.aliasMapper = aliasMapper;
|
|
61399
61395
|
return type;
|
|
61400
61396
|
}
|
|
61401
61397
|
/**
|
|
@@ -61753,9 +61749,9 @@ var ts;
|
|
|
61753
61749
|
var templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
61754
61750
|
return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
|
|
61755
61751
|
}
|
|
61756
|
-
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61752
|
+
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61757
61753
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
61758
|
-
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61754
|
+
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
61759
61755
|
}
|
|
61760
61756
|
function indexTypeLessThan(indexType, limit) {
|
|
61761
61757
|
return everyType(indexType, function (t) {
|
|
@@ -61769,7 +61765,7 @@ var ts;
|
|
|
61769
61765
|
return false;
|
|
61770
61766
|
});
|
|
61771
61767
|
}
|
|
61772
|
-
function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61768
|
+
function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61773
61769
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
61774
61770
|
if (objectType === wildcardType || indexType === wildcardType) {
|
|
61775
61771
|
return wildcardType;
|
|
@@ -61800,7 +61796,7 @@ var ts;
|
|
|
61800
61796
|
var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
61801
61797
|
var type = indexedAccessTypes.get(id);
|
|
61802
61798
|
if (!type) {
|
|
61803
|
-
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments
|
|
61799
|
+
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments));
|
|
61804
61800
|
}
|
|
61805
61801
|
return type;
|
|
61806
61802
|
}
|
|
@@ -61830,8 +61826,8 @@ var ts;
|
|
|
61830
61826
|
return undefined;
|
|
61831
61827
|
}
|
|
61832
61828
|
return accessFlags & 4 /* Writing */
|
|
61833
|
-
? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments
|
|
61834
|
-
: getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
61829
|
+
? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
|
|
61830
|
+
: getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
61835
61831
|
}
|
|
61836
61832
|
return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */);
|
|
61837
61833
|
}
|
|
@@ -61841,7 +61837,7 @@ var ts;
|
|
|
61841
61837
|
var objectType = getTypeFromTypeNode(node.objectType);
|
|
61842
61838
|
var indexType = getTypeFromTypeNode(node.indexType);
|
|
61843
61839
|
var potentialAlias = getAliasSymbolForTypeNode(node);
|
|
61844
|
-
var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)
|
|
61840
|
+
var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
|
|
61845
61841
|
links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ &&
|
|
61846
61842
|
resolved.objectType === objectType &&
|
|
61847
61843
|
resolved.indexType === indexType ?
|
|
@@ -62008,7 +62004,6 @@ var ts;
|
|
|
62008
62004
|
result.combinedMapper = combinedMapper;
|
|
62009
62005
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
62010
62006
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
62011
|
-
result.aliasMapper = result.aliasSymbol ? mapper : undefined;
|
|
62012
62007
|
return "break";
|
|
62013
62008
|
};
|
|
62014
62009
|
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
@@ -62804,7 +62799,7 @@ var ts;
|
|
|
62804
62799
|
var result = target.instantiations.get(id);
|
|
62805
62800
|
if (!result) {
|
|
62806
62801
|
var newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
62807
|
-
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments
|
|
62802
|
+
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
|
|
62808
62803
|
target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
|
|
62809
62804
|
instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
62810
62805
|
target.instantiations.set(id, result);
|
|
@@ -62893,7 +62888,7 @@ var ts;
|
|
|
62893
62888
|
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
62894
62889
|
}
|
|
62895
62890
|
return t;
|
|
62896
|
-
}, aliasSymbol, aliasTypeArguments
|
|
62891
|
+
}, aliasSymbol, aliasTypeArguments);
|
|
62897
62892
|
}
|
|
62898
62893
|
}
|
|
62899
62894
|
// If the constraint type of the instantiation is the wildcard type, return the wildcard type.
|
|
@@ -62962,7 +62957,6 @@ var ts;
|
|
|
62962
62957
|
result.mapper = mapper;
|
|
62963
62958
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
62964
62959
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
62965
|
-
result.aliasMapper = mapper;
|
|
62966
62960
|
return result;
|
|
62967
62961
|
}
|
|
62968
62962
|
function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
@@ -62982,7 +62976,7 @@ var ts;
|
|
|
62982
62976
|
// distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
|
|
62983
62977
|
// result is (A extends U ? X : Y) | (B extends U ? X : Y).
|
|
62984
62978
|
result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ?
|
|
62985
|
-
mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments
|
|
62979
|
+
mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
|
|
62986
62980
|
getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
|
|
62987
62981
|
root.instantiations.set(id, result);
|
|
62988
62982
|
}
|
|
@@ -63042,8 +63036,8 @@ var ts;
|
|
|
63042
63036
|
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
63043
63037
|
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
63044
63038
|
return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ?
|
|
63045
|
-
getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments
|
|
63046
|
-
getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments
|
|
63039
|
+
getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
|
|
63040
|
+
getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments);
|
|
63047
63041
|
}
|
|
63048
63042
|
if (flags & 4194304 /* Index */) {
|
|
63049
63043
|
return getIndexType(instantiateType(type.type, mapper));
|
|
@@ -63057,7 +63051,7 @@ var ts;
|
|
|
63057
63051
|
if (flags & 8388608 /* IndexedAccess */) {
|
|
63058
63052
|
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
63059
63053
|
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
63060
|
-
return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments
|
|
63054
|
+
return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments);
|
|
63061
63055
|
}
|
|
63062
63056
|
if (flags & 16777216 /* Conditional */) {
|
|
63063
63057
|
return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
|
|
@@ -65051,10 +65045,7 @@ var ts;
|
|
|
65051
65045
|
if (variances === ts.emptyArray) {
|
|
65052
65046
|
return 1 /* Unknown */;
|
|
65053
65047
|
}
|
|
65054
|
-
var
|
|
65055
|
-
var sourceArgs = outerTypeParameters && source.aliasMapper ? ts.concatenate(source.aliasTypeArguments, instantiateTypes(outerTypeParameters, source.aliasMapper)) : source.aliasTypeArguments;
|
|
65056
|
-
var targetArgs = outerTypeParameters && target.aliasMapper ? ts.concatenate(target.aliasTypeArguments, instantiateTypes(outerTypeParameters, target.aliasMapper)) : target.aliasTypeArguments;
|
|
65057
|
-
var varianceResult = relateVariances(sourceArgs, targetArgs, variances, intersectionState);
|
|
65048
|
+
var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
|
|
65058
65049
|
if (varianceResult !== undefined) {
|
|
65059
65050
|
return varianceResult;
|
|
65060
65051
|
}
|
|
@@ -66343,11 +66334,8 @@ var ts;
|
|
|
66343
66334
|
}
|
|
66344
66335
|
function getAliasVariances(symbol) {
|
|
66345
66336
|
var links = getSymbolLinks(symbol);
|
|
66346
|
-
|
|
66347
|
-
|
|
66348
|
-
return getVariancesWorker(params, links, function (_links, param, marker) {
|
|
66349
|
-
var mapper = makeUnaryTypeMapper(param, marker);
|
|
66350
|
-
var type = getLocalTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, mapper), mapper);
|
|
66337
|
+
return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
|
|
66338
|
+
var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
|
|
66351
66339
|
type.aliasTypeArgumentsContainsMarker = true;
|
|
66352
66340
|
return type;
|
|
66353
66341
|
});
|
|
@@ -67004,7 +66992,7 @@ var ts;
|
|
|
67004
66992
|
}
|
|
67005
66993
|
// If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
|
|
67006
66994
|
return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
|
|
67007
|
-
|
|
66995
|
+
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
|
|
67008
66996
|
reducedType;
|
|
67009
66997
|
}
|
|
67010
66998
|
function getNonNullableType(type) {
|
|
@@ -67347,12 +67335,14 @@ var ts;
|
|
|
67347
67335
|
errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
|
|
67348
67336
|
}
|
|
67349
67337
|
function reportErrorsFromWidening(declaration, type, wideningKind) {
|
|
67350
|
-
|
|
67351
|
-
|
|
67352
|
-
|
|
67353
|
-
|
|
67338
|
+
addLazyDiagnostic(function () {
|
|
67339
|
+
if (noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
|
|
67340
|
+
// Report implicit any error within type if possible, otherwise report error on declaration
|
|
67341
|
+
if (!reportWideningErrorsInType(type)) {
|
|
67342
|
+
reportImplicitAny(declaration, type, wideningKind);
|
|
67343
|
+
}
|
|
67354
67344
|
}
|
|
67355
|
-
}
|
|
67345
|
+
});
|
|
67356
67346
|
}
|
|
67357
67347
|
function applyToParameterTypes(source, target, callback) {
|
|
67358
67348
|
var sourceCount = getParameterCount(source);
|
|
@@ -69230,7 +69220,7 @@ var ts;
|
|
|
69230
69220
|
newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered);
|
|
69231
69221
|
}
|
|
69232
69222
|
}
|
|
69233
|
-
return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined,
|
|
69223
|
+
return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin);
|
|
69234
69224
|
}
|
|
69235
69225
|
return type.flags & 131072 /* Never */ || f(type) ? type : neverType;
|
|
69236
69226
|
}
|
|
@@ -69266,9 +69256,9 @@ var ts;
|
|
|
69266
69256
|
}
|
|
69267
69257
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
69268
69258
|
}
|
|
69269
|
-
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments
|
|
69259
|
+
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
69270
69260
|
return type.flags & 1048576 /* Union */ && aliasSymbol ?
|
|
69271
|
-
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
69261
|
+
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
69272
69262
|
mapType(type, mapper);
|
|
69273
69263
|
}
|
|
69274
69264
|
function extractTypesOfKind(type, kind) {
|
|
@@ -72453,7 +72443,7 @@ var ts;
|
|
|
72453
72443
|
var params = getSymbolLinks(managedSym).typeParameters;
|
|
72454
72444
|
if (ts.length(params) >= 2) {
|
|
72455
72445
|
var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
|
|
72456
|
-
return
|
|
72446
|
+
return getTypeAliasInstantiation(managedSym, args);
|
|
72457
72447
|
}
|
|
72458
72448
|
}
|
|
72459
72449
|
if (ts.length(declaredManagedType.typeParameters) >= 2) {
|
|
@@ -75344,7 +75334,7 @@ var ts;
|
|
|
75344
75334
|
var isTaggedTemplate = node.kind === 209 /* TaggedTemplateExpression */;
|
|
75345
75335
|
var isDecorator = node.kind === 164 /* Decorator */;
|
|
75346
75336
|
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
|
|
75347
|
-
var reportErrors = !candidatesOutArray
|
|
75337
|
+
var reportErrors = !candidatesOutArray;
|
|
75348
75338
|
var typeArguments;
|
|
75349
75339
|
if (!isDecorator) {
|
|
75350
75340
|
typeArguments = node.typeArguments;
|
|
@@ -76624,11 +76614,13 @@ var ts;
|
|
|
76624
76614
|
checkSourceElement(type);
|
|
76625
76615
|
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
|
|
76626
76616
|
var targetType = getTypeFromTypeNode(type);
|
|
76627
|
-
if (
|
|
76628
|
-
|
|
76629
|
-
|
|
76630
|
-
|
|
76631
|
-
|
|
76617
|
+
if (!isErrorType(targetType)) {
|
|
76618
|
+
addLazyDiagnostic(function () {
|
|
76619
|
+
var widenedType = getWidenedType(exprType);
|
|
76620
|
+
if (!isTypeComparableTo(targetType, widenedType)) {
|
|
76621
|
+
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);
|
|
76622
|
+
}
|
|
76623
|
+
});
|
|
76632
76624
|
}
|
|
76633
76625
|
return targetType;
|
|
76634
76626
|
}
|
|
@@ -77388,47 +77380,48 @@ var ts;
|
|
|
77388
77380
|
* @param returnType - return type of the function, can be undefined if return type is not explicitly specified
|
|
77389
77381
|
*/
|
|
77390
77382
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
77391
|
-
|
|
77392
|
-
|
|
77393
|
-
|
|
77394
|
-
|
|
77395
|
-
|
|
77396
|
-
|
|
77397
|
-
|
|
77398
|
-
|
|
77399
|
-
|
|
77400
|
-
|
|
77401
|
-
|
|
77402
|
-
|
|
77403
|
-
|
|
77404
|
-
|
|
77405
|
-
|
|
77406
|
-
|
|
77407
|
-
|
|
77408
|
-
|
|
77409
|
-
|
|
77410
|
-
|
|
77411
|
-
|
|
77412
|
-
|
|
77413
|
-
|
|
77414
|
-
|
|
77415
|
-
|
|
77416
|
-
|
|
77417
|
-
|
|
77418
|
-
|
|
77419
|
-
|
|
77420
|
-
|
|
77421
|
-
|
|
77422
|
-
|
|
77423
|
-
|
|
77424
|
-
|
|
77425
|
-
|
|
77426
|
-
|
|
77427
|
-
|
|
77428
|
-
|
|
77383
|
+
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
77384
|
+
return;
|
|
77385
|
+
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
77386
|
+
var functionFlags = ts.getFunctionFlags(func);
|
|
77387
|
+
var type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
77388
|
+
// Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
|
|
77389
|
+
if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
|
|
77390
|
+
return;
|
|
77391
|
+
}
|
|
77392
|
+
// If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
|
|
77393
|
+
// also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
|
|
77394
|
+
if (func.kind === 167 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 234 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
77395
|
+
return;
|
|
77396
|
+
}
|
|
77397
|
+
var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
|
|
77398
|
+
var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
|
|
77399
|
+
if (type && type.flags & 131072 /* Never */) {
|
|
77400
|
+
error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
77401
|
+
}
|
|
77402
|
+
else if (type && !hasExplicitReturn) {
|
|
77403
|
+
// minimal check: function has syntactic return type annotation and no explicit return statements in the body
|
|
77404
|
+
// this function does not conform to the specification.
|
|
77405
|
+
error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
|
77406
|
+
}
|
|
77407
|
+
else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
|
|
77408
|
+
error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
77409
|
+
}
|
|
77410
|
+
else if (compilerOptions.noImplicitReturns) {
|
|
77411
|
+
if (!type) {
|
|
77412
|
+
// If return type annotation is omitted check if function has any explicit return statements.
|
|
77413
|
+
// If it does not have any - its inferred return type is void - don't do any checks.
|
|
77414
|
+
// Otherwise get inferred return type from function body and report error only if it is not void / anytype
|
|
77415
|
+
if (!hasExplicitReturn) {
|
|
77416
|
+
return;
|
|
77417
|
+
}
|
|
77418
|
+
var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
|
|
77419
|
+
if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
|
|
77420
|
+
return;
|
|
77421
|
+
}
|
|
77429
77422
|
}
|
|
77423
|
+
error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
|
|
77430
77424
|
}
|
|
77431
|
-
error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
|
|
77432
77425
|
}
|
|
77433
77426
|
}
|
|
77434
77427
|
function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
|
|
@@ -77688,49 +77681,50 @@ var ts;
|
|
|
77688
77681
|
checkExpression(node.expression);
|
|
77689
77682
|
return undefinedWideningType;
|
|
77690
77683
|
}
|
|
77691
|
-
function
|
|
77684
|
+
function checkAwaitExpressionGrammar(node) {
|
|
77692
77685
|
// Grammar checking
|
|
77693
|
-
|
|
77694
|
-
|
|
77695
|
-
|
|
77696
|
-
|
|
77697
|
-
|
|
77698
|
-
|
|
77699
|
-
|
|
77700
|
-
|
|
77701
|
-
|
|
77702
|
-
|
|
77703
|
-
if (!
|
|
77704
|
-
if (!span)
|
|
77705
|
-
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77706
|
-
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);
|
|
77707
|
-
diagnostics.add(diagnostic);
|
|
77708
|
-
}
|
|
77709
|
-
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 */) {
|
|
77686
|
+
var container = ts.getContainingFunctionOrClassStaticBlock(node);
|
|
77687
|
+
if (container && ts.isClassStaticBlockDeclaration(container)) {
|
|
77688
|
+
error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
|
|
77689
|
+
}
|
|
77690
|
+
else if (!(node.flags & 32768 /* AwaitContext */)) {
|
|
77691
|
+
if (ts.isInTopLevelContext(node)) {
|
|
77692
|
+
var sourceFile = ts.getSourceFileOfNode(node);
|
|
77693
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
77694
|
+
var span = void 0;
|
|
77695
|
+
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
77696
|
+
if (!span)
|
|
77710
77697
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77711
|
-
|
|
77712
|
-
|
|
77713
|
-
}
|
|
77698
|
+
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);
|
|
77699
|
+
diagnostics.add(diagnostic);
|
|
77714
77700
|
}
|
|
77715
|
-
|
|
77716
|
-
|
|
77717
|
-
|
|
77718
|
-
var sourceFile = ts.getSourceFileOfNode(node);
|
|
77719
|
-
if (!hasParseDiagnostics(sourceFile)) {
|
|
77720
|
-
var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77721
|
-
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);
|
|
77722
|
-
if (container && container.kind !== 170 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
|
|
77723
|
-
var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
|
|
77724
|
-
ts.addRelatedInfo(diagnostic, relatedInfo);
|
|
77725
|
-
}
|
|
77701
|
+
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 */) {
|
|
77702
|
+
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77703
|
+
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);
|
|
77726
77704
|
diagnostics.add(diagnostic);
|
|
77727
77705
|
}
|
|
77728
77706
|
}
|
|
77729
77707
|
}
|
|
77730
|
-
|
|
77731
|
-
|
|
77708
|
+
else {
|
|
77709
|
+
// use of 'await' in non-async function
|
|
77710
|
+
var sourceFile = ts.getSourceFileOfNode(node);
|
|
77711
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
77712
|
+
var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77713
|
+
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);
|
|
77714
|
+
if (container && container.kind !== 170 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
|
|
77715
|
+
var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
|
|
77716
|
+
ts.addRelatedInfo(diagnostic, relatedInfo);
|
|
77717
|
+
}
|
|
77718
|
+
diagnostics.add(diagnostic);
|
|
77719
|
+
}
|
|
77732
77720
|
}
|
|
77733
77721
|
}
|
|
77722
|
+
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
77723
|
+
error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
77724
|
+
}
|
|
77725
|
+
}
|
|
77726
|
+
function checkAwaitExpression(node) {
|
|
77727
|
+
addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); });
|
|
77734
77728
|
var operandType = checkExpression(node.expression);
|
|
77735
77729
|
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);
|
|
77736
77730
|
if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
|
|
@@ -78554,7 +78548,10 @@ var ts;
|
|
|
78554
78548
|
}
|
|
78555
78549
|
}
|
|
78556
78550
|
function checkAssignmentOperator(valueType) {
|
|
78557
|
-
if (
|
|
78551
|
+
if (ts.isAssignmentOperator(operator)) {
|
|
78552
|
+
addLazyDiagnostic(checkAssignmentOperatorWorker);
|
|
78553
|
+
}
|
|
78554
|
+
function checkAssignmentOperatorWorker() {
|
|
78558
78555
|
// TypeScript 1.0 spec (April 2014): 4.17
|
|
78559
78556
|
// An assignment of the form
|
|
78560
78557
|
// VarExpr = ValueExpr
|
|
@@ -78653,15 +78650,7 @@ var ts;
|
|
|
78653
78650
|
return [effectiveLeft, effectiveRight];
|
|
78654
78651
|
}
|
|
78655
78652
|
function checkYieldExpression(node) {
|
|
78656
|
-
|
|
78657
|
-
if (produceDiagnostics) {
|
|
78658
|
-
if (!(node.flags & 8192 /* YieldContext */)) {
|
|
78659
|
-
grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
|
|
78660
|
-
}
|
|
78661
|
-
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
78662
|
-
error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
78663
|
-
}
|
|
78664
|
-
}
|
|
78653
|
+
addLazyDiagnostic(checkYieldExpressionGrammar);
|
|
78665
78654
|
var func = ts.getContainingFunction(node);
|
|
78666
78655
|
if (!func)
|
|
78667
78656
|
return anyType;
|
|
@@ -78707,14 +78696,24 @@ var ts;
|
|
|
78707
78696
|
var type = getContextualIterationType(2 /* Next */, func);
|
|
78708
78697
|
if (!type) {
|
|
78709
78698
|
type = anyType;
|
|
78710
|
-
|
|
78711
|
-
|
|
78712
|
-
|
|
78713
|
-
|
|
78699
|
+
addLazyDiagnostic(function () {
|
|
78700
|
+
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
78701
|
+
var contextualType = getContextualType(node);
|
|
78702
|
+
if (!contextualType || isTypeAny(contextualType)) {
|
|
78703
|
+
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
78704
|
+
}
|
|
78714
78705
|
}
|
|
78715
|
-
}
|
|
78706
|
+
});
|
|
78716
78707
|
}
|
|
78717
78708
|
return type;
|
|
78709
|
+
function checkYieldExpressionGrammar() {
|
|
78710
|
+
if (!(node.flags & 8192 /* YieldContext */)) {
|
|
78711
|
+
grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
|
|
78712
|
+
}
|
|
78713
|
+
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
78714
|
+
error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
78715
|
+
}
|
|
78716
|
+
}
|
|
78718
78717
|
}
|
|
78719
78718
|
function checkConditionalExpression(node, checkMode) {
|
|
78720
78719
|
checkTruthinessExpression(node.condition);
|
|
@@ -79297,9 +79296,7 @@ var ts;
|
|
|
79297
79296
|
if (constraintType && defaultType) {
|
|
79298
79297
|
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
|
79299
79298
|
}
|
|
79300
|
-
|
|
79301
|
-
checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
|
|
79302
|
-
}
|
|
79299
|
+
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79303
79300
|
}
|
|
79304
79301
|
function checkParameter(node) {
|
|
79305
79302
|
// Grammar checking
|
|
@@ -79453,7 +79450,8 @@ var ts;
|
|
|
79453
79450
|
if (node.type) {
|
|
79454
79451
|
checkSourceElement(node.type);
|
|
79455
79452
|
}
|
|
79456
|
-
|
|
79453
|
+
addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
|
|
79454
|
+
function checkSignatureDeclarationDiagnostics() {
|
|
79457
79455
|
checkCollisionWithArgumentsInGeneratedCode(node);
|
|
79458
79456
|
var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
|
|
79459
79457
|
if (noImplicitAny && !returnTypeNode) {
|
|
@@ -79743,9 +79741,8 @@ var ts;
|
|
|
79743
79741
|
if (ts.nodeIsMissing(node.body)) {
|
|
79744
79742
|
return;
|
|
79745
79743
|
}
|
|
79746
|
-
|
|
79747
|
-
|
|
79748
|
-
}
|
|
79744
|
+
addLazyDiagnostic(checkConstructorDeclarationDiagnostics);
|
|
79745
|
+
return;
|
|
79749
79746
|
function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
|
|
79750
79747
|
if (ts.isPrivateIdentifierClassElementDeclaration(n)) {
|
|
79751
79748
|
return true;
|
|
@@ -79754,54 +79751,56 @@ var ts;
|
|
|
79754
79751
|
!ts.isStatic(n) &&
|
|
79755
79752
|
!!n.initializer;
|
|
79756
79753
|
}
|
|
79757
|
-
|
|
79758
|
-
|
|
79759
|
-
|
|
79760
|
-
|
|
79761
|
-
|
|
79762
|
-
|
|
79763
|
-
|
|
79764
|
-
|
|
79765
|
-
|
|
79766
|
-
if (
|
|
79767
|
-
|
|
79768
|
-
|
|
79769
|
-
|
|
79770
|
-
|
|
79771
|
-
|
|
79772
|
-
|
|
79773
|
-
|
|
79774
|
-
(ts.
|
|
79775
|
-
ts.some(node.
|
|
79776
|
-
|
|
79777
|
-
|
|
79778
|
-
// See GH #8277
|
|
79779
|
-
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
79780
|
-
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);
|
|
79781
|
-
}
|
|
79782
|
-
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
79783
|
-
else {
|
|
79784
|
-
var superCallStatement = void 0;
|
|
79785
|
-
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
79786
|
-
var statement = _a[_i];
|
|
79787
|
-
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
79788
|
-
superCallStatement = statement;
|
|
79789
|
-
break;
|
|
79790
|
-
}
|
|
79791
|
-
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
79792
|
-
break;
|
|
79793
|
-
}
|
|
79794
|
-
}
|
|
79754
|
+
function checkConstructorDeclarationDiagnostics() {
|
|
79755
|
+
// TS 1.0 spec (April 2014): 8.3.2
|
|
79756
|
+
// Constructors of classes with no extends clause may not contain super calls, whereas
|
|
79757
|
+
// constructors of derived classes must contain at least one super call somewhere in their function body.
|
|
79758
|
+
var containingClassDecl = node.parent;
|
|
79759
|
+
if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
|
|
79760
|
+
captureLexicalThis(node.parent, containingClassDecl);
|
|
79761
|
+
var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
|
|
79762
|
+
var superCall = findFirstSuperCall(node.body);
|
|
79763
|
+
if (superCall) {
|
|
79764
|
+
if (classExtendsNull) {
|
|
79765
|
+
error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
79766
|
+
}
|
|
79767
|
+
// A super call must be root-level in a constructor if both of the following are true:
|
|
79768
|
+
// - The containing class is a derived class.
|
|
79769
|
+
// - The constructor declares parameter properties
|
|
79770
|
+
// or the containing class declares instance member variables with initializers.
|
|
79771
|
+
var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
79772
|
+
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
79773
|
+
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
79774
|
+
if (superCallShouldBeRootLevel) {
|
|
79795
79775
|
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
79796
79776
|
// See GH #8277
|
|
79797
|
-
if (
|
|
79798
|
-
error(
|
|
79777
|
+
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
79778
|
+
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);
|
|
79779
|
+
}
|
|
79780
|
+
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
79781
|
+
else {
|
|
79782
|
+
var superCallStatement = void 0;
|
|
79783
|
+
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
79784
|
+
var statement = _a[_i];
|
|
79785
|
+
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
79786
|
+
superCallStatement = statement;
|
|
79787
|
+
break;
|
|
79788
|
+
}
|
|
79789
|
+
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
79790
|
+
break;
|
|
79791
|
+
}
|
|
79792
|
+
}
|
|
79793
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
79794
|
+
// See GH #8277
|
|
79795
|
+
if (superCallStatement === undefined) {
|
|
79796
|
+
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);
|
|
79797
|
+
}
|
|
79799
79798
|
}
|
|
79800
79799
|
}
|
|
79801
79800
|
}
|
|
79802
|
-
|
|
79803
|
-
|
|
79804
|
-
|
|
79801
|
+
else if (!classExtendsNull) {
|
|
79802
|
+
error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
|
|
79803
|
+
}
|
|
79805
79804
|
}
|
|
79806
79805
|
}
|
|
79807
79806
|
}
|
|
@@ -79819,7 +79818,10 @@ var ts;
|
|
|
79819
79818
|
return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
|
|
79820
79819
|
}
|
|
79821
79820
|
function checkAccessorDeclaration(node) {
|
|
79822
|
-
|
|
79821
|
+
addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
|
|
79822
|
+
checkSourceElement(node.body);
|
|
79823
|
+
setNodeLinksForPrivateIdentifierScope(node);
|
|
79824
|
+
function checkAccessorDeclarationDiagnostics() {
|
|
79823
79825
|
// Grammar checking accessors
|
|
79824
79826
|
if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
|
|
79825
79827
|
checkGrammarComputedPropertyName(node.name);
|
|
@@ -79869,8 +79871,6 @@ var ts;
|
|
|
79869
79871
|
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
|
|
79870
79872
|
}
|
|
79871
79873
|
}
|
|
79872
|
-
checkSourceElement(node.body);
|
|
79873
|
-
setNodeLinksForPrivateIdentifierScope(node);
|
|
79874
79874
|
}
|
|
79875
79875
|
function checkMissingDeclaration(node) {
|
|
79876
79876
|
checkDecorators(node);
|
|
@@ -79913,11 +79913,13 @@ var ts;
|
|
|
79913
79913
|
ts.forEach(node.typeArguments, checkSourceElement);
|
|
79914
79914
|
var type = getTypeFromTypeReference(node);
|
|
79915
79915
|
if (!isErrorType(type)) {
|
|
79916
|
-
if (node.typeArguments
|
|
79917
|
-
|
|
79918
|
-
|
|
79919
|
-
|
|
79920
|
-
|
|
79916
|
+
if (node.typeArguments) {
|
|
79917
|
+
addLazyDiagnostic(function () {
|
|
79918
|
+
var typeParameters = getTypeParametersForTypeReference(node);
|
|
79919
|
+
if (typeParameters) {
|
|
79920
|
+
checkTypeArgumentConstraints(node, typeParameters);
|
|
79921
|
+
}
|
|
79922
|
+
});
|
|
79921
79923
|
}
|
|
79922
79924
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
79923
79925
|
if (symbol) {
|
|
@@ -79945,7 +79947,8 @@ var ts;
|
|
|
79945
79947
|
}
|
|
79946
79948
|
function checkTypeLiteral(node) {
|
|
79947
79949
|
ts.forEach(node.members, checkSourceElement);
|
|
79948
|
-
|
|
79950
|
+
addLazyDiagnostic(checkTypeLiteralDiagnostics);
|
|
79951
|
+
function checkTypeLiteralDiagnostics() {
|
|
79949
79952
|
var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
|
|
79950
79953
|
checkIndexConstraints(type, type.symbol);
|
|
79951
79954
|
checkTypeForDuplicateIndexSignatures(node);
|
|
@@ -80136,9 +80139,9 @@ var ts;
|
|
|
80136
80139
|
return flags & flagsToCheck;
|
|
80137
80140
|
}
|
|
80138
80141
|
function checkFunctionOrConstructorSymbol(symbol) {
|
|
80139
|
-
|
|
80140
|
-
|
|
80141
|
-
|
|
80142
|
+
addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
|
|
80143
|
+
}
|
|
80144
|
+
function checkFunctionOrConstructorSymbolWorker(symbol) {
|
|
80142
80145
|
function getCanonicalOverload(overloads, implementation) {
|
|
80143
80146
|
// Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
|
|
80144
80147
|
// Error on all deviations from this canonical set of flags
|
|
@@ -80359,9 +80362,9 @@ var ts;
|
|
|
80359
80362
|
}
|
|
80360
80363
|
}
|
|
80361
80364
|
function checkExportsOnMergedDeclarations(node) {
|
|
80362
|
-
|
|
80363
|
-
|
|
80364
|
-
|
|
80365
|
+
addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); });
|
|
80366
|
+
}
|
|
80367
|
+
function checkExportsOnMergedDeclarationsWorker(node) {
|
|
80365
80368
|
// if localSymbol is defined on node then node itself is exported - check is required
|
|
80366
80369
|
var symbol = node.localSymbol;
|
|
80367
80370
|
if (!symbol) {
|
|
@@ -80597,7 +80600,7 @@ var ts;
|
|
|
80597
80600
|
if (awaitedSymbol) {
|
|
80598
80601
|
// Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
|
|
80599
80602
|
// an `Awaited<T | U>` would suffice.
|
|
80600
|
-
return
|
|
80603
|
+
return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
|
|
80601
80604
|
}
|
|
80602
80605
|
}
|
|
80603
80606
|
}
|
|
@@ -80848,20 +80851,31 @@ var ts;
|
|
|
80848
80851
|
* marked as referenced to prevent import elision.
|
|
80849
80852
|
*/
|
|
80850
80853
|
function markTypeNodeAsReferenced(node) {
|
|
80851
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
80854
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
|
|
80852
80855
|
}
|
|
80853
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
80856
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
80854
80857
|
if (!typeName)
|
|
80855
80858
|
return;
|
|
80856
80859
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
80857
80860
|
var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
|
|
80858
80861
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
|
80859
|
-
if (rootSymbol
|
|
80860
|
-
|
|
80861
|
-
|
|
80862
|
-
|
|
80863
|
-
|
|
80864
|
-
|
|
80862
|
+
if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) {
|
|
80863
|
+
if (symbolIsValue(rootSymbol)
|
|
80864
|
+
&& !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
|
|
80865
|
+
&& !getTypeOnlyAliasDeclaration(rootSymbol)) {
|
|
80866
|
+
markAliasSymbolAsReferenced(rootSymbol);
|
|
80867
|
+
}
|
|
80868
|
+
else if (forDecoratorMetadata
|
|
80869
|
+
&& compilerOptions.isolatedModules
|
|
80870
|
+
&& ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015
|
|
80871
|
+
&& !symbolIsValue(rootSymbol)
|
|
80872
|
+
&& !ts.some(rootSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration)) {
|
|
80873
|
+
var diag = error(typeName, ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled);
|
|
80874
|
+
var aliasDeclaration = ts.find(rootSymbol.declarations || ts.emptyArray, isAliasSymbolDeclaration);
|
|
80875
|
+
if (aliasDeclaration) {
|
|
80876
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(aliasDeclaration, ts.Diagnostics._0_was_imported_here, ts.idText(rootName)));
|
|
80877
|
+
}
|
|
80878
|
+
}
|
|
80865
80879
|
}
|
|
80866
80880
|
}
|
|
80867
80881
|
/**
|
|
@@ -80874,7 +80888,7 @@ var ts;
|
|
|
80874
80888
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
80875
80889
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
80876
80890
|
if (entityName && ts.isEntityName(entityName)) {
|
|
80877
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
80891
|
+
markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
|
|
80878
80892
|
}
|
|
80879
80893
|
}
|
|
80880
80894
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -80994,7 +81008,8 @@ var ts;
|
|
|
80994
81008
|
ts.forEach(node.decorators, checkDecorator);
|
|
80995
81009
|
}
|
|
80996
81010
|
function checkFunctionDeclaration(node) {
|
|
80997
|
-
|
|
81011
|
+
addLazyDiagnostic(checkFunctionDeclarationDiagnostics);
|
|
81012
|
+
function checkFunctionDeclarationDiagnostics() {
|
|
80998
81013
|
checkFunctionOrMethodDeclaration(node);
|
|
80999
81014
|
checkGrammarForGenerator(node);
|
|
81000
81015
|
checkCollisionsForDeclarationName(node, node.name);
|
|
@@ -81028,10 +81043,13 @@ var ts;
|
|
|
81028
81043
|
checkSourceElement(node.typeExpression);
|
|
81029
81044
|
}
|
|
81030
81045
|
function checkJSDocFunctionType(node) {
|
|
81031
|
-
|
|
81032
|
-
reportImplicitAny(node, anyType);
|
|
81033
|
-
}
|
|
81046
|
+
addLazyDiagnostic(checkJSDocFunctionTypeImplicitAny);
|
|
81034
81047
|
checkSignatureDeclaration(node);
|
|
81048
|
+
function checkJSDocFunctionTypeImplicitAny() {
|
|
81049
|
+
if (!node.type && !ts.isJSDocConstructSignature(node)) {
|
|
81050
|
+
reportImplicitAny(node, anyType);
|
|
81051
|
+
}
|
|
81052
|
+
}
|
|
81035
81053
|
}
|
|
81036
81054
|
function checkJSDocImplementsTag(node) {
|
|
81037
81055
|
var classLike = ts.getEffectiveJSDocHost(node);
|
|
@@ -81112,19 +81130,7 @@ var ts;
|
|
|
81112
81130
|
var body = node.kind === 167 /* MethodSignature */ ? undefined : node.body;
|
|
81113
81131
|
checkSourceElement(body);
|
|
81114
81132
|
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
|
|
81115
|
-
|
|
81116
|
-
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
|
|
81117
|
-
// in an ambient context
|
|
81118
|
-
if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
|
|
81119
|
-
reportImplicitAny(node, anyType);
|
|
81120
|
-
}
|
|
81121
|
-
if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
|
|
81122
|
-
// A generator with a body and no type annotation can still cause errors. It can error if the
|
|
81123
|
-
// yielded values have no common supertype, or it can give an implicit any error if it has no
|
|
81124
|
-
// yielded values. The only way to trigger these errors is to try checking its return type.
|
|
81125
|
-
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
|
|
81126
|
-
}
|
|
81127
|
-
}
|
|
81133
|
+
addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics);
|
|
81128
81134
|
// A js function declaration can have a @type tag instead of a return type node, but that type must have a call signature
|
|
81129
81135
|
if (ts.isInJSFile(node)) {
|
|
81130
81136
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
@@ -81132,10 +81138,26 @@ var ts;
|
|
|
81132
81138
|
error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
|
|
81133
81139
|
}
|
|
81134
81140
|
}
|
|
81141
|
+
function checkFunctionOrMethodDeclarationDiagnostics() {
|
|
81142
|
+
if (!ts.getEffectiveReturnTypeNode(node)) {
|
|
81143
|
+
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
|
|
81144
|
+
// in an ambient context
|
|
81145
|
+
if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
|
|
81146
|
+
reportImplicitAny(node, anyType);
|
|
81147
|
+
}
|
|
81148
|
+
if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
|
|
81149
|
+
// A generator with a body and no type annotation can still cause errors. It can error if the
|
|
81150
|
+
// yielded values have no common supertype, or it can give an implicit any error if it has no
|
|
81151
|
+
// yielded values. The only way to trigger these errors is to try checking its return type.
|
|
81152
|
+
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
|
|
81153
|
+
}
|
|
81154
|
+
}
|
|
81155
|
+
}
|
|
81135
81156
|
}
|
|
81136
81157
|
function registerForUnusedIdentifiersCheck(node) {
|
|
81137
|
-
|
|
81138
|
-
|
|
81158
|
+
addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
|
|
81159
|
+
function registerForUnusedIdentifiersCheckDiagnostics() {
|
|
81160
|
+
// May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
|
|
81139
81161
|
var sourceFile = ts.getSourceFileOfNode(node);
|
|
81140
81162
|
var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
|
|
81141
81163
|
if (!potentiallyUnusedIdentifiers) {
|
|
@@ -82909,26 +82931,31 @@ var ts;
|
|
|
82909
82931
|
hasDuplicateDefaultClause = true;
|
|
82910
82932
|
}
|
|
82911
82933
|
}
|
|
82912
|
-
if (
|
|
82913
|
-
|
|
82914
|
-
// In a 'switch' statement, each 'case' expression must be of a type that is comparable
|
|
82915
|
-
// to or from the type of the 'switch' expression.
|
|
82916
|
-
var caseType = checkExpression(clause.expression);
|
|
82917
|
-
var caseIsLiteral = isLiteralType(caseType);
|
|
82918
|
-
var comparedExpressionType = expressionType;
|
|
82919
|
-
if (!caseIsLiteral || !expressionIsLiteral) {
|
|
82920
|
-
caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
|
|
82921
|
-
comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
|
|
82922
|
-
}
|
|
82923
|
-
if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
|
|
82924
|
-
// expressionType is not comparable to caseType, try the reversed check and report errors if it fails
|
|
82925
|
-
checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
|
|
82926
|
-
}
|
|
82934
|
+
if (clause.kind === 288 /* CaseClause */) {
|
|
82935
|
+
addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause));
|
|
82927
82936
|
}
|
|
82928
82937
|
ts.forEach(clause.statements, checkSourceElement);
|
|
82929
82938
|
if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
|
|
82930
82939
|
error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
|
|
82931
82940
|
}
|
|
82941
|
+
function createLazyCaseClauseDiagnostics(clause) {
|
|
82942
|
+
return function () {
|
|
82943
|
+
// TypeScript 1.0 spec (April 2014): 5.9
|
|
82944
|
+
// In a 'switch' statement, each 'case' expression must be of a type that is comparable
|
|
82945
|
+
// to or from the type of the 'switch' expression.
|
|
82946
|
+
var caseType = checkExpression(clause.expression);
|
|
82947
|
+
var caseIsLiteral = isLiteralType(caseType);
|
|
82948
|
+
var comparedExpressionType = expressionType;
|
|
82949
|
+
if (!caseIsLiteral || !expressionIsLiteral) {
|
|
82950
|
+
caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
|
|
82951
|
+
comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
|
|
82952
|
+
}
|
|
82953
|
+
if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
|
|
82954
|
+
// expressionType is not comparable to caseType, try the reversed check and report errors if it fails
|
|
82955
|
+
checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
|
|
82956
|
+
}
|
|
82957
|
+
};
|
|
82958
|
+
}
|
|
82932
82959
|
});
|
|
82933
82960
|
if (node.caseBlock.locals) {
|
|
82934
82961
|
registerForUnusedIdentifiersCheck(node.caseBlock);
|
|
@@ -83149,26 +83176,29 @@ var ts;
|
|
|
83149
83176
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
83150
83177
|
*/
|
|
83151
83178
|
function checkTypeParameters(typeParameterDeclarations) {
|
|
83179
|
+
var seenDefault = false;
|
|
83152
83180
|
if (typeParameterDeclarations) {
|
|
83153
|
-
var seenDefault = false;
|
|
83154
83181
|
for (var i = 0; i < typeParameterDeclarations.length; i++) {
|
|
83155
83182
|
var node = typeParameterDeclarations[i];
|
|
83156
83183
|
checkTypeParameter(node);
|
|
83157
|
-
|
|
83158
|
-
|
|
83159
|
-
|
|
83160
|
-
|
|
83161
|
-
|
|
83162
|
-
|
|
83163
|
-
|
|
83164
|
-
|
|
83165
|
-
|
|
83166
|
-
|
|
83167
|
-
|
|
83168
|
-
|
|
83184
|
+
addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
|
|
83185
|
+
}
|
|
83186
|
+
}
|
|
83187
|
+
function createCheckTypeParameterDiagnostic(node, i) {
|
|
83188
|
+
return function () {
|
|
83189
|
+
if (node.default) {
|
|
83190
|
+
seenDefault = true;
|
|
83191
|
+
checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
|
|
83192
|
+
}
|
|
83193
|
+
else if (seenDefault) {
|
|
83194
|
+
error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
|
|
83195
|
+
}
|
|
83196
|
+
for (var j = 0; j < i; j++) {
|
|
83197
|
+
if (typeParameterDeclarations[j].symbol === node.symbol) {
|
|
83198
|
+
error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
|
|
83169
83199
|
}
|
|
83170
83200
|
}
|
|
83171
|
-
}
|
|
83201
|
+
};
|
|
83172
83202
|
}
|
|
83173
83203
|
}
|
|
83174
83204
|
/** Check that type parameter defaults only reference previously declared type parameters */
|
|
@@ -83300,85 +83330,90 @@ var ts;
|
|
|
83300
83330
|
if (extendsNode && extendsNode !== baseTypeNode) {
|
|
83301
83331
|
checkExpression(extendsNode.expression);
|
|
83302
83332
|
}
|
|
83303
|
-
var
|
|
83304
|
-
if (
|
|
83305
|
-
|
|
83306
|
-
|
|
83307
|
-
|
|
83308
|
-
|
|
83309
|
-
|
|
83310
|
-
|
|
83311
|
-
ts.
|
|
83312
|
-
|
|
83313
|
-
var
|
|
83314
|
-
|
|
83315
|
-
|
|
83333
|
+
var baseTypes_2 = getBaseTypes(type);
|
|
83334
|
+
if (baseTypes_2.length) {
|
|
83335
|
+
addLazyDiagnostic(function () {
|
|
83336
|
+
var baseType = baseTypes_2[0];
|
|
83337
|
+
var baseConstructorType = getBaseConstructorTypeOfClass(type);
|
|
83338
|
+
var staticBaseType = getApparentType(baseConstructorType);
|
|
83339
|
+
checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
|
|
83340
|
+
checkSourceElement(baseTypeNode.expression);
|
|
83341
|
+
if (ts.some(baseTypeNode.typeArguments)) {
|
|
83342
|
+
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
|
|
83343
|
+
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
|
|
83344
|
+
var constructor = _a[_i];
|
|
83345
|
+
if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
|
|
83346
|
+
break;
|
|
83347
|
+
}
|
|
83316
83348
|
}
|
|
83317
83349
|
}
|
|
83318
|
-
|
|
83319
|
-
|
|
83320
|
-
|
|
83321
|
-
issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
|
|
83322
|
-
}
|
|
83323
|
-
else {
|
|
83324
|
-
// Report static side error only when instance type is assignable
|
|
83325
|
-
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
|
|
83326
|
-
}
|
|
83327
|
-
if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
|
|
83328
|
-
if (!isMixinConstructorType(staticType)) {
|
|
83329
|
-
error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
|
|
83350
|
+
var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
|
|
83351
|
+
if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
|
|
83352
|
+
issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
|
|
83330
83353
|
}
|
|
83331
83354
|
else {
|
|
83332
|
-
|
|
83333
|
-
|
|
83334
|
-
|
|
83355
|
+
// Report static side error only when instance type is assignable
|
|
83356
|
+
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
|
|
83357
|
+
}
|
|
83358
|
+
if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
|
|
83359
|
+
if (!isMixinConstructorType(staticType)) {
|
|
83360
|
+
error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
|
|
83361
|
+
}
|
|
83362
|
+
else {
|
|
83363
|
+
var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
|
|
83364
|
+
if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
|
|
83365
|
+
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);
|
|
83366
|
+
}
|
|
83335
83367
|
}
|
|
83336
83368
|
}
|
|
83337
|
-
|
|
83338
|
-
|
|
83339
|
-
|
|
83340
|
-
|
|
83341
|
-
|
|
83342
|
-
|
|
83343
|
-
|
|
83369
|
+
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
|
|
83370
|
+
// When the static base type is a "class-like" constructor function (but not actually a class), we verify
|
|
83371
|
+
// that all instantiated base constructor signatures return the same type.
|
|
83372
|
+
var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
|
|
83373
|
+
if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType); })) {
|
|
83374
|
+
error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
|
|
83375
|
+
}
|
|
83344
83376
|
}
|
|
83345
|
-
|
|
83346
|
-
|
|
83377
|
+
checkKindsOfPropertyMemberOverrides(type, baseType);
|
|
83378
|
+
});
|
|
83347
83379
|
}
|
|
83348
83380
|
}
|
|
83349
83381
|
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
|
|
83350
83382
|
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
|
|
83351
83383
|
if (implementedTypeNodes) {
|
|
83352
|
-
for (var
|
|
83353
|
-
var typeRefNode = implementedTypeNodes_1[
|
|
83384
|
+
for (var _i = 0, implementedTypeNodes_1 = implementedTypeNodes; _i < implementedTypeNodes_1.length; _i++) {
|
|
83385
|
+
var typeRefNode = implementedTypeNodes_1[_i];
|
|
83354
83386
|
if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
|
|
83355
83387
|
error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
|
|
83356
83388
|
}
|
|
83357
83389
|
checkTypeReferenceNode(typeRefNode);
|
|
83358
|
-
|
|
83359
|
-
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
83360
|
-
if (!isErrorType(t)) {
|
|
83361
|
-
if (isValidBaseType(t)) {
|
|
83362
|
-
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
83363
|
-
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
83364
|
-
ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
|
|
83365
|
-
var baseWithThis = getTypeWithThisArgument(t, type.thisType);
|
|
83366
|
-
if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
|
|
83367
|
-
issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
|
|
83368
|
-
}
|
|
83369
|
-
}
|
|
83370
|
-
else {
|
|
83371
|
-
error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
|
83372
|
-
}
|
|
83373
|
-
}
|
|
83374
|
-
}
|
|
83390
|
+
addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
|
|
83375
83391
|
}
|
|
83376
83392
|
}
|
|
83377
|
-
|
|
83393
|
+
addLazyDiagnostic(function () {
|
|
83378
83394
|
checkIndexConstraints(type, symbol);
|
|
83379
83395
|
checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
|
|
83380
83396
|
checkTypeForDuplicateIndexSignatures(node);
|
|
83381
83397
|
checkPropertyInitialization(node);
|
|
83398
|
+
});
|
|
83399
|
+
function createImplementsDiagnostics(typeRefNode) {
|
|
83400
|
+
return function () {
|
|
83401
|
+
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
83402
|
+
if (!isErrorType(t)) {
|
|
83403
|
+
if (isValidBaseType(t)) {
|
|
83404
|
+
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
83405
|
+
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
83406
|
+
ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
|
|
83407
|
+
var baseWithThis = getTypeWithThisArgument(t, type.thisType);
|
|
83408
|
+
if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
|
|
83409
|
+
issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
|
|
83410
|
+
}
|
|
83411
|
+
}
|
|
83412
|
+
else {
|
|
83413
|
+
error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
|
83414
|
+
}
|
|
83415
|
+
}
|
|
83416
|
+
};
|
|
83382
83417
|
}
|
|
83383
83418
|
}
|
|
83384
83419
|
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
|
|
@@ -83702,8 +83737,8 @@ var ts;
|
|
|
83702
83737
|
ts.forEach(properties, function (p) {
|
|
83703
83738
|
seen.set(p.escapedName, p);
|
|
83704
83739
|
});
|
|
83705
|
-
for (var _i = 0,
|
|
83706
|
-
var base =
|
|
83740
|
+
for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
|
|
83741
|
+
var base = baseTypes_3[_i];
|
|
83707
83742
|
var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
|
|
83708
83743
|
for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
|
|
83709
83744
|
var prop = properties_4[_a];
|
|
@@ -83725,8 +83760,8 @@ var ts;
|
|
|
83725
83760
|
seen.set(p.escapedName, { prop: p, containingType: type });
|
|
83726
83761
|
});
|
|
83727
83762
|
var ok = true;
|
|
83728
|
-
for (var _i = 0,
|
|
83729
|
-
var base =
|
|
83763
|
+
for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
|
|
83764
|
+
var base = baseTypes_4[_i];
|
|
83730
83765
|
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
|
|
83731
83766
|
for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
|
|
83732
83767
|
var prop = properties_6[_a];
|
|
@@ -83810,7 +83845,7 @@ var ts;
|
|
|
83810
83845
|
if (!checkGrammarDecoratorsAndModifiers(node))
|
|
83811
83846
|
checkGrammarInterfaceDeclaration(node);
|
|
83812
83847
|
checkTypeParameters(node.typeParameters);
|
|
83813
|
-
|
|
83848
|
+
addLazyDiagnostic(function () {
|
|
83814
83849
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
|
|
83815
83850
|
checkExportsOnMergedDeclarations(node);
|
|
83816
83851
|
var symbol = getSymbolOfNode(node);
|
|
@@ -83830,7 +83865,7 @@ var ts;
|
|
|
83830
83865
|
}
|
|
83831
83866
|
}
|
|
83832
83867
|
checkObjectTypeForDuplicateDeclarations(node);
|
|
83833
|
-
}
|
|
83868
|
+
});
|
|
83834
83869
|
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
|
|
83835
83870
|
if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
|
|
83836
83871
|
error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
|
|
@@ -83838,10 +83873,10 @@ var ts;
|
|
|
83838
83873
|
checkTypeReferenceNode(heritageElement);
|
|
83839
83874
|
});
|
|
83840
83875
|
ts.forEach(node.members, checkSourceElement);
|
|
83841
|
-
|
|
83876
|
+
addLazyDiagnostic(function () {
|
|
83842
83877
|
checkTypeForDuplicateIndexSignatures(node);
|
|
83843
83878
|
registerForUnusedIdentifiersCheck(node);
|
|
83844
|
-
}
|
|
83879
|
+
});
|
|
83845
83880
|
}
|
|
83846
83881
|
function checkTypeAliasDeclaration(node) {
|
|
83847
83882
|
// Grammar checking
|
|
@@ -84030,9 +84065,9 @@ var ts;
|
|
|
84030
84065
|
ts.isStringLiteralLike(node.argumentExpression);
|
|
84031
84066
|
}
|
|
84032
84067
|
function checkEnumDeclaration(node) {
|
|
84033
|
-
|
|
84034
|
-
|
|
84035
|
-
|
|
84068
|
+
addLazyDiagnostic(function () { return checkEnumDeclarationWorker(node); });
|
|
84069
|
+
}
|
|
84070
|
+
function checkEnumDeclarationWorker(node) {
|
|
84036
84071
|
// Grammar checking
|
|
84037
84072
|
checkGrammarDecoratorsAndModifiers(node);
|
|
84038
84073
|
checkCollisionsForDeclarationName(node, node.name);
|
|
@@ -84112,7 +84147,14 @@ var ts;
|
|
|
84112
84147
|
}
|
|
84113
84148
|
}
|
|
84114
84149
|
function checkModuleDeclaration(node) {
|
|
84115
|
-
if (
|
|
84150
|
+
if (node.body) {
|
|
84151
|
+
checkSourceElement(node.body);
|
|
84152
|
+
if (!ts.isGlobalScopeAugmentation(node)) {
|
|
84153
|
+
registerForUnusedIdentifiersCheck(node);
|
|
84154
|
+
}
|
|
84155
|
+
}
|
|
84156
|
+
addLazyDiagnostic(checkModuleDeclarationDiagnostics);
|
|
84157
|
+
function checkModuleDeclarationDiagnostics() {
|
|
84116
84158
|
// Grammar checking
|
|
84117
84159
|
var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
|
|
84118
84160
|
var inAmbientContext = node.flags & 8388608 /* Ambient */;
|
|
@@ -84195,12 +84237,6 @@ var ts;
|
|
|
84195
84237
|
}
|
|
84196
84238
|
}
|
|
84197
84239
|
}
|
|
84198
|
-
if (node.body) {
|
|
84199
|
-
checkSourceElement(node.body);
|
|
84200
|
-
if (!ts.isGlobalScopeAugmentation(node)) {
|
|
84201
|
-
registerForUnusedIdentifiersCheck(node);
|
|
84202
|
-
}
|
|
84203
|
-
}
|
|
84204
84240
|
}
|
|
84205
84241
|
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
|
|
84206
84242
|
var _a;
|
|
@@ -84526,7 +84562,7 @@ var ts;
|
|
|
84526
84562
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
84527
84563
|
return;
|
|
84528
84564
|
}
|
|
84529
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
84565
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
84530
84566
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
84531
84567
|
}
|
|
84532
84568
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
@@ -85137,13 +85173,16 @@ var ts;
|
|
|
85137
85173
|
if (ts.isExternalOrCommonJsModule(node)) {
|
|
85138
85174
|
registerForUnusedIdentifiersCheck(node);
|
|
85139
85175
|
}
|
|
85140
|
-
|
|
85141
|
-
|
|
85142
|
-
|
|
85143
|
-
|
|
85144
|
-
|
|
85145
|
-
|
|
85146
|
-
|
|
85176
|
+
addLazyDiagnostic(function () {
|
|
85177
|
+
// This relies on the results of other lazy diagnostics, so must be computed after them
|
|
85178
|
+
if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
|
|
85179
|
+
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
|
|
85180
|
+
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
|
|
85181
|
+
diagnostics.add(diag);
|
|
85182
|
+
}
|
|
85183
|
+
});
|
|
85184
|
+
}
|
|
85185
|
+
});
|
|
85147
85186
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
85148
85187
|
!node.isDeclarationFile &&
|
|
85149
85188
|
ts.isExternalModule(node)) {
|
|
@@ -85183,15 +85222,35 @@ var ts;
|
|
|
85183
85222
|
cancellationToken = undefined;
|
|
85184
85223
|
}
|
|
85185
85224
|
}
|
|
85225
|
+
function ensurePendingDiagnosticWorkComplete() {
|
|
85226
|
+
// Invoke any existing lazy diagnostics to add them, clear the backlog of diagnostics
|
|
85227
|
+
for (var _i = 0, deferredDiagnosticsCallbacks_1 = deferredDiagnosticsCallbacks; _i < deferredDiagnosticsCallbacks_1.length; _i++) {
|
|
85228
|
+
var cb = deferredDiagnosticsCallbacks_1[_i];
|
|
85229
|
+
cb();
|
|
85230
|
+
}
|
|
85231
|
+
deferredDiagnosticsCallbacks = [];
|
|
85232
|
+
}
|
|
85233
|
+
function checkSourceFileWithEagerDiagnostics(sourceFile) {
|
|
85234
|
+
ensurePendingDiagnosticWorkComplete();
|
|
85235
|
+
// then setup diagnostics for immediate invocation (as we are about to collect them, and
|
|
85236
|
+
// this avoids the overhead of longer-lived callbacks we don't need to allocate)
|
|
85237
|
+
// This also serves to make the shift to possibly lazy diagnostics transparent to serial command-line scenarios
|
|
85238
|
+
// (as in those cases, all the diagnostics will still be computed as the appropriate place in the tree,
|
|
85239
|
+
// thus much more likely retaining the same union ordering as before we had lazy diagnostics)
|
|
85240
|
+
var oldAddLazyDiagnostics = addLazyDiagnostic;
|
|
85241
|
+
addLazyDiagnostic = function (cb) { return cb(); };
|
|
85242
|
+
checkSourceFile(sourceFile);
|
|
85243
|
+
addLazyDiagnostic = oldAddLazyDiagnostics;
|
|
85244
|
+
}
|
|
85186
85245
|
function getDiagnosticsWorker(sourceFile) {
|
|
85187
|
-
throwIfNonDiagnosticsProducing();
|
|
85188
85246
|
if (sourceFile) {
|
|
85247
|
+
ensurePendingDiagnosticWorkComplete();
|
|
85189
85248
|
// Some global diagnostics are deferred until they are needed and
|
|
85190
85249
|
// may not be reported in the first call to getGlobalDiagnostics.
|
|
85191
85250
|
// We should catch these changes and report them.
|
|
85192
85251
|
var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
|
|
85193
85252
|
var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
|
|
85194
|
-
|
|
85253
|
+
checkSourceFileWithEagerDiagnostics(sourceFile);
|
|
85195
85254
|
var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
|
85196
85255
|
var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
|
|
85197
85256
|
if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
|
|
@@ -85209,18 +85268,13 @@ var ts;
|
|
|
85209
85268
|
}
|
|
85210
85269
|
// Global diagnostics are always added when a file is not provided to
|
|
85211
85270
|
// getDiagnostics
|
|
85212
|
-
ts.forEach(host.getSourceFiles(),
|
|
85271
|
+
ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
|
|
85213
85272
|
return diagnostics.getDiagnostics();
|
|
85214
85273
|
}
|
|
85215
85274
|
function getGlobalDiagnostics() {
|
|
85216
|
-
|
|
85275
|
+
ensurePendingDiagnosticWorkComplete();
|
|
85217
85276
|
return diagnostics.getGlobalDiagnostics();
|
|
85218
85277
|
}
|
|
85219
|
-
function throwIfNonDiagnosticsProducing() {
|
|
85220
|
-
if (!produceDiagnostics) {
|
|
85221
|
-
throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
|
|
85222
|
-
}
|
|
85223
|
-
}
|
|
85224
85278
|
// Language service support
|
|
85225
85279
|
function getSymbolsInScope(location, meaning) {
|
|
85226
85280
|
if (location.flags & 16777216 /* InWithStatement */) {
|
|
@@ -87703,10 +87757,9 @@ var ts;
|
|
|
87703
87757
|
}
|
|
87704
87758
|
var parent = ts.walkUpParenthesizedTypes(node.parent);
|
|
87705
87759
|
if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
|
|
87706
|
-
|
|
87707
|
-
if (
|
|
87708
|
-
|
|
87709
|
-
parent = parent.parent.parent;
|
|
87760
|
+
var host_2 = ts.getJSDocHost(parent);
|
|
87761
|
+
if (host_2) {
|
|
87762
|
+
parent = ts.getSingleVariableOfVariableStatement(host_2) || host_2;
|
|
87710
87763
|
}
|
|
87711
87764
|
}
|
|
87712
87765
|
switch (parent.kind) {
|
|
@@ -115670,8 +115723,7 @@ var ts;
|
|
|
115670
115723
|
var files;
|
|
115671
115724
|
var symlinks;
|
|
115672
115725
|
var commonSourceDirectory;
|
|
115673
|
-
var
|
|
115674
|
-
var noDiagnosticsTypeChecker;
|
|
115726
|
+
var typeChecker;
|
|
115675
115727
|
var classifiableNames;
|
|
115676
115728
|
var ambientModuleNameToUnmodifiedFileName = new ts.Map();
|
|
115677
115729
|
var fileReasons = ts.createMultiMap();
|
|
@@ -115917,21 +115969,19 @@ var ts;
|
|
|
115917
115969
|
getProgramDiagnostics: getProgramDiagnostics,
|
|
115918
115970
|
getTypeChecker: getTypeChecker,
|
|
115919
115971
|
getClassifiableNames: getClassifiableNames,
|
|
115920
|
-
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
|
|
115921
115972
|
getCommonSourceDirectory: getCommonSourceDirectory,
|
|
115922
115973
|
emit: emit,
|
|
115923
115974
|
getCurrentDirectory: function () { return currentDirectory; },
|
|
115924
|
-
getNodeCount: function () { return
|
|
115925
|
-
getIdentifierCount: function () { return
|
|
115926
|
-
getSymbolCount: function () { return
|
|
115927
|
-
getTypeCount: function () { return
|
|
115928
|
-
getInstantiationCount: function () { return
|
|
115929
|
-
getRelationCacheSizes: function () { return
|
|
115975
|
+
getNodeCount: function () { return getTypeChecker().getNodeCount(); },
|
|
115976
|
+
getIdentifierCount: function () { return getTypeChecker().getIdentifierCount(); },
|
|
115977
|
+
getSymbolCount: function () { return getTypeChecker().getSymbolCount(); },
|
|
115978
|
+
getTypeCount: function () { return getTypeChecker().getTypeCount(); },
|
|
115979
|
+
getInstantiationCount: function () { return getTypeChecker().getInstantiationCount(); },
|
|
115980
|
+
getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
|
|
115930
115981
|
getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
|
|
115931
115982
|
getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
|
|
115932
115983
|
isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
|
|
115933
115984
|
isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
|
|
115934
|
-
dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
|
|
115935
115985
|
getSourceFileFromReference: getSourceFileFromReference,
|
|
115936
115986
|
getLibFileFromReference: getLibFileFromReference,
|
|
115937
115987
|
sourceFileToPackageName: sourceFileToPackageName,
|
|
@@ -116520,14 +116570,8 @@ var ts;
|
|
|
116520
116570
|
return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); });
|
|
116521
116571
|
}
|
|
116522
116572
|
}
|
|
116523
|
-
function getDiagnosticsProducingTypeChecker() {
|
|
116524
|
-
return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true));
|
|
116525
|
-
}
|
|
116526
|
-
function dropDiagnosticsProducingTypeChecker() {
|
|
116527
|
-
diagnosticsProducingTypeChecker = undefined;
|
|
116528
|
-
}
|
|
116529
116573
|
function getTypeChecker() {
|
|
116530
|
-
return
|
|
116574
|
+
return typeChecker || (typeChecker = ts.createTypeChecker(program));
|
|
116531
116575
|
}
|
|
116532
116576
|
function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
|
|
116533
116577
|
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);
|
|
@@ -116552,7 +116596,7 @@ var ts;
|
|
|
116552
116596
|
// This is because in the -out scenario all files need to be emitted, and therefore all
|
|
116553
116597
|
// files need to be type checked. And the way to specify that all files need to be type
|
|
116554
116598
|
// checked is to not pass the file to getEmitResolver.
|
|
116555
|
-
var emitResolver =
|
|
116599
|
+
var emitResolver = getTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
|
|
116556
116600
|
ts.performance.mark("beforeEmit");
|
|
116557
116601
|
var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles,
|
|
116558
116602
|
/*onlyBuildInfo*/ false, forceDtsEmit);
|
|
@@ -116632,15 +116676,7 @@ var ts;
|
|
|
116632
116676
|
if (e instanceof ts.OperationCanceledException) {
|
|
116633
116677
|
// We were canceled while performing the operation. Because our type checker
|
|
116634
116678
|
// might be a bad state, we need to throw it away.
|
|
116635
|
-
|
|
116636
|
-
// Note: we are overly aggressive here. We do not actually *have* to throw away
|
|
116637
|
-
// the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
|
|
116638
|
-
// the lifetimes of these two TypeCheckers the same. Also, we generally only
|
|
116639
|
-
// cancel when the user has made a change anyways. And, in that case, we (the
|
|
116640
|
-
// program instance) will get thrown away anyways. So trying to keep one of
|
|
116641
|
-
// these type checkers alive doesn't serve much purpose.
|
|
116642
|
-
noDiagnosticsTypeChecker = undefined;
|
|
116643
|
-
diagnosticsProducingTypeChecker = undefined;
|
|
116679
|
+
typeChecker = undefined;
|
|
116644
116680
|
}
|
|
116645
116681
|
throw e;
|
|
116646
116682
|
}
|
|
@@ -116656,7 +116692,7 @@ var ts;
|
|
|
116656
116692
|
if (ts.skipTypeChecking(sourceFile, options, program)) {
|
|
116657
116693
|
return ts.emptyArray;
|
|
116658
116694
|
}
|
|
116659
|
-
var typeChecker =
|
|
116695
|
+
var typeChecker = getTypeChecker();
|
|
116660
116696
|
ts.Debug.assert(!!sourceFile.bindDiagnostics);
|
|
116661
116697
|
var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
|
|
116662
116698
|
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
|
|
@@ -116708,7 +116744,7 @@ var ts;
|
|
|
116708
116744
|
}
|
|
116709
116745
|
function getSuggestionDiagnostics(sourceFile, cancellationToken) {
|
|
116710
116746
|
return runWithCancellationToken(function () {
|
|
116711
|
-
return
|
|
116747
|
+
return getTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
|
|
116712
116748
|
});
|
|
116713
116749
|
}
|
|
116714
116750
|
/**
|
|
@@ -116926,7 +116962,7 @@ var ts;
|
|
|
116926
116962
|
}
|
|
116927
116963
|
function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
|
|
116928
116964
|
return runWithCancellationToken(function () {
|
|
116929
|
-
var resolver =
|
|
116965
|
+
var resolver = getTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
|
116930
116966
|
// Don't actually write any files since we're just getting diagnostics.
|
|
116931
116967
|
return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
|
|
116932
116968
|
});
|
|
@@ -116964,7 +117000,7 @@ var ts;
|
|
|
116964
117000
|
return diagnostics;
|
|
116965
117001
|
}
|
|
116966
117002
|
function getGlobalDiagnostics() {
|
|
116967
|
-
return rootNames.length ? ts.sortAndDeduplicateDiagnostics(
|
|
117003
|
+
return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
|
|
116968
117004
|
}
|
|
116969
117005
|
function getConfigFileParsingDiagnostics() {
|
|
116970
117006
|
return configFileParsingDiagnostics || ts.emptyArray;
|
|
@@ -130941,14 +130977,15 @@ var ts;
|
|
|
130941
130977
|
SortText["SuggestedClassMembers"] = "14";
|
|
130942
130978
|
SortText["GlobalsOrKeywords"] = "15";
|
|
130943
130979
|
SortText["AutoImportSuggestions"] = "16";
|
|
130944
|
-
SortText["
|
|
130945
|
-
SortText["
|
|
130946
|
-
SortText["
|
|
130947
|
-
SortText["
|
|
130948
|
-
SortText["
|
|
130949
|
-
SortText["
|
|
130950
|
-
SortText["
|
|
130951
|
-
SortText["
|
|
130980
|
+
SortText["ClassMemberSnippets"] = "17";
|
|
130981
|
+
SortText["JavascriptIdentifiers"] = "18";
|
|
130982
|
+
SortText["DeprecatedLocalDeclarationPriority"] = "19";
|
|
130983
|
+
SortText["DeprecatedLocationPriority"] = "20";
|
|
130984
|
+
SortText["DeprecatedOptionalMember"] = "21";
|
|
130985
|
+
SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "22";
|
|
130986
|
+
SortText["DeprecatedSuggestedClassMembers"] = "23";
|
|
130987
|
+
SortText["DeprecatedGlobalsOrKeywords"] = "24";
|
|
130988
|
+
SortText["DeprecatedAutoImportSuggestions"] = "25";
|
|
130952
130989
|
})(SortText = Completions.SortText || (Completions.SortText = {}));
|
|
130953
130990
|
var SortTextId;
|
|
130954
130991
|
(function (SortTextId) {
|
|
@@ -130960,10 +130997,10 @@ var ts;
|
|
|
130960
130997
|
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
130961
130998
|
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
130962
130999
|
// Don't use these directly.
|
|
130963
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] =
|
|
130964
|
-
SortTextId[SortTextId["_DeprecatedStart"] =
|
|
131000
|
+
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
131001
|
+
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
130965
131002
|
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
130966
|
-
SortTextId[SortTextId["DeprecatedOffset"] =
|
|
131003
|
+
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
130967
131004
|
})(SortTextId || (SortTextId = {}));
|
|
130968
131005
|
/**
|
|
130969
131006
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
@@ -131444,6 +131481,7 @@ var ts;
|
|
|
131444
131481
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
131445
131482
|
var importAdder = void 0;
|
|
131446
131483
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
131484
|
+
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131447
131485
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
131448
131486
|
hasAction = true;
|
|
131449
131487
|
source = CompletionSource.ClassMemberSnippet;
|
|
@@ -131807,7 +131845,7 @@ var ts;
|
|
|
131807
131845
|
}
|
|
131808
131846
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131809
131847
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
131810
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
131848
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
131811
131849
|
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
131812
131850
|
if (!entry) {
|
|
131813
131851
|
continue;
|
|
@@ -148824,7 +148862,7 @@ var ts;
|
|
|
148824
148862
|
errorCodes: errorCodes,
|
|
148825
148863
|
getCodeActions: function getCodeActionsToAddMissingAsync(context) {
|
|
148826
148864
|
var sourceFile = context.sourceFile, errorCode = context.errorCode, cancellationToken = context.cancellationToken, program = context.program, span = context.span;
|
|
148827
|
-
var diagnostic = ts.find(program.
|
|
148865
|
+
var diagnostic = ts.find(program.getTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
|
|
148828
148866
|
var directSpan = diagnostic && diagnostic.relatedInformation && ts.find(diagnostic.relatedInformation, function (r) { return r.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; });
|
|
148829
148867
|
var decl = getFixableErrorSpanDeclaration(sourceFile, directSpan);
|
|
148830
148868
|
if (!decl) {
|
|
@@ -148978,7 +149016,7 @@ var ts;
|
|
|
148978
149016
|
return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await);
|
|
148979
149017
|
}
|
|
148980
149018
|
function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) {
|
|
148981
|
-
var checker = program.
|
|
149019
|
+
var checker = program.getTypeChecker();
|
|
148982
149020
|
var diagnostics = checker.getDiagnostics(sourceFile, cancellationToken);
|
|
148983
149021
|
return ts.some(diagnostics, function (_a) {
|
|
148984
149022
|
var start = _a.start, length = _a.length, relatedInformation = _a.relatedInformation, code = _a.code;
|
|
@@ -149645,20 +149683,6 @@ var ts;
|
|
|
149645
149683
|
}
|
|
149646
149684
|
function createClassElementsFromSymbol(symbol) {
|
|
149647
149685
|
var memberElements = [];
|
|
149648
|
-
// all instance members are stored in the "member" array of symbol
|
|
149649
|
-
if (symbol.members) {
|
|
149650
|
-
symbol.members.forEach(function (member, key) {
|
|
149651
|
-
if (key === "constructor" && member.valueDeclaration) {
|
|
149652
|
-
// fn.prototype.constructor = fn
|
|
149653
|
-
changes.delete(sourceFile, member.valueDeclaration.parent);
|
|
149654
|
-
return;
|
|
149655
|
-
}
|
|
149656
|
-
var memberElement = createClassElement(member, /*modifiers*/ undefined);
|
|
149657
|
-
if (memberElement) {
|
|
149658
|
-
memberElements.push.apply(memberElements, memberElement);
|
|
149659
|
-
}
|
|
149660
|
-
});
|
|
149661
|
-
}
|
|
149662
149686
|
// all static members are stored in the "exports" array of symbol
|
|
149663
149687
|
if (symbol.exports) {
|
|
149664
149688
|
symbol.exports.forEach(function (member) {
|
|
@@ -149671,18 +149695,31 @@ var ts;
|
|
|
149671
149695
|
firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ &&
|
|
149672
149696
|
ts.isObjectLiteralExpression(firstDeclaration.parent.right)) {
|
|
149673
149697
|
var prototypes = firstDeclaration.parent.right;
|
|
149674
|
-
|
|
149675
|
-
if (memberElement) {
|
|
149676
|
-
memberElements.push.apply(memberElements, memberElement);
|
|
149677
|
-
}
|
|
149698
|
+
createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements);
|
|
149678
149699
|
}
|
|
149679
149700
|
}
|
|
149680
149701
|
else {
|
|
149681
|
-
|
|
149682
|
-
|
|
149683
|
-
|
|
149702
|
+
createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements);
|
|
149703
|
+
}
|
|
149704
|
+
});
|
|
149705
|
+
}
|
|
149706
|
+
// all instance members are stored in the "member" array of symbol (done last so instance members pulled from prototype assignments have priority)
|
|
149707
|
+
if (symbol.members) {
|
|
149708
|
+
symbol.members.forEach(function (member, key) {
|
|
149709
|
+
var _a, _b, _c, _d;
|
|
149710
|
+
if (key === "constructor" && member.valueDeclaration) {
|
|
149711
|
+
var prototypeAssignment = (_d = (_c = (_b = (_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.get("prototype")) === null || _b === void 0 ? void 0 : _b.declarations) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.parent;
|
|
149712
|
+
if (prototypeAssignment && ts.isBinaryExpression(prototypeAssignment) && ts.isObjectLiteralExpression(prototypeAssignment.right) && ts.some(prototypeAssignment.right.properties, isConstructorAssignment)) {
|
|
149713
|
+
// fn.prototype = { constructor: fn }
|
|
149714
|
+
// Already deleted in `createClassElement` in first pass
|
|
149715
|
+
}
|
|
149716
|
+
else {
|
|
149717
|
+
// fn.prototype.constructor = fn
|
|
149718
|
+
changes.delete(sourceFile, member.valueDeclaration.parent);
|
|
149684
149719
|
}
|
|
149720
|
+
return;
|
|
149685
149721
|
}
|
|
149722
|
+
createClassElement(member, /*modifiers*/ undefined, memberElements);
|
|
149686
149723
|
});
|
|
149687
149724
|
}
|
|
149688
149725
|
return memberElements;
|
|
@@ -149710,18 +149747,26 @@ var ts;
|
|
|
149710
149747
|
});
|
|
149711
149748
|
}
|
|
149712
149749
|
}
|
|
149713
|
-
function createClassElement(symbol, modifiers) {
|
|
149750
|
+
function createClassElement(symbol, modifiers, members) {
|
|
149714
149751
|
// Right now the only thing we can convert are function expressions, which are marked as methods
|
|
149715
149752
|
// or { x: y } type prototype assignments, which are marked as ObjectLiteral
|
|
149716
|
-
var members = [];
|
|
149717
149753
|
if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) {
|
|
149718
|
-
return
|
|
149754
|
+
return;
|
|
149719
149755
|
}
|
|
149720
149756
|
var memberDeclaration = symbol.valueDeclaration;
|
|
149721
149757
|
var assignmentBinaryExpression = memberDeclaration.parent;
|
|
149722
149758
|
var assignmentExpr = assignmentBinaryExpression.right;
|
|
149723
149759
|
if (!shouldConvertDeclaration(memberDeclaration, assignmentExpr)) {
|
|
149724
|
-
return
|
|
149760
|
+
return;
|
|
149761
|
+
}
|
|
149762
|
+
if (ts.some(members, function (m) {
|
|
149763
|
+
var name = ts.getNameOfDeclaration(m);
|
|
149764
|
+
if (name && ts.isIdentifier(name) && ts.idText(name) === ts.symbolName(symbol)) {
|
|
149765
|
+
return true; // class member already made for this name
|
|
149766
|
+
}
|
|
149767
|
+
return false;
|
|
149768
|
+
})) {
|
|
149769
|
+
return;
|
|
149725
149770
|
}
|
|
149726
149771
|
// delete the entire statement if this expression is the sole expression to take care of the semicolon at the end
|
|
149727
149772
|
var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 237 /* ExpressionStatement */
|
|
@@ -149730,43 +149775,44 @@ var ts;
|
|
|
149730
149775
|
if (!assignmentExpr) {
|
|
149731
149776
|
members.push(ts.factory.createPropertyDeclaration([], modifiers, symbol.name, /*questionToken*/ undefined,
|
|
149732
149777
|
/*type*/ undefined, /*initializer*/ undefined));
|
|
149733
|
-
return
|
|
149778
|
+
return;
|
|
149734
149779
|
}
|
|
149735
149780
|
// f.x = expr
|
|
149736
149781
|
if (ts.isAccessExpression(memberDeclaration) && (ts.isFunctionExpression(assignmentExpr) || ts.isArrowFunction(assignmentExpr))) {
|
|
149737
149782
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
149738
149783
|
var name = tryGetPropertyName(memberDeclaration, compilerOptions, quotePreference);
|
|
149739
149784
|
if (name) {
|
|
149740
|
-
|
|
149785
|
+
createFunctionLikeExpressionMember(members, assignmentExpr, name);
|
|
149741
149786
|
}
|
|
149742
|
-
return
|
|
149787
|
+
return;
|
|
149743
149788
|
}
|
|
149744
149789
|
// f.prototype = { ... }
|
|
149745
149790
|
else if (ts.isObjectLiteralExpression(assignmentExpr)) {
|
|
149746
|
-
|
|
149791
|
+
ts.forEach(assignmentExpr.properties, function (property) {
|
|
149747
149792
|
if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) {
|
|
149748
149793
|
// MethodDeclaration and AccessorDeclaration can appear in a class directly
|
|
149749
|
-
|
|
149794
|
+
members.push(property);
|
|
149750
149795
|
}
|
|
149751
149796
|
if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer)) {
|
|
149752
|
-
|
|
149797
|
+
createFunctionLikeExpressionMember(members, property.initializer, property.name);
|
|
149753
149798
|
}
|
|
149754
149799
|
// Drop constructor assignments
|
|
149755
149800
|
if (isConstructorAssignment(property))
|
|
149756
|
-
return
|
|
149757
|
-
return
|
|
149801
|
+
return;
|
|
149802
|
+
return;
|
|
149758
149803
|
});
|
|
149804
|
+
return;
|
|
149759
149805
|
}
|
|
149760
149806
|
else {
|
|
149761
149807
|
// Don't try to declare members in JavaScript files
|
|
149762
149808
|
if (ts.isSourceFileJS(sourceFile))
|
|
149763
|
-
return
|
|
149809
|
+
return;
|
|
149764
149810
|
if (!ts.isPropertyAccessExpression(memberDeclaration))
|
|
149765
|
-
return
|
|
149811
|
+
return;
|
|
149766
149812
|
var prop = ts.factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr);
|
|
149767
149813
|
ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile);
|
|
149768
149814
|
members.push(prop);
|
|
149769
|
-
return
|
|
149815
|
+
return;
|
|
149770
149816
|
}
|
|
149771
149817
|
function createFunctionLikeExpressionMember(members, expression, name) {
|
|
149772
149818
|
if (ts.isFunctionExpression(expression))
|
|
@@ -149779,7 +149825,8 @@ var ts;
|
|
|
149779
149825
|
var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
|
|
149780
149826
|
/*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body);
|
|
149781
149827
|
ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
|
|
149782
|
-
|
|
149828
|
+
members.push(method);
|
|
149829
|
+
return;
|
|
149783
149830
|
}
|
|
149784
149831
|
function createArrowFunctionExpressionMember(members, arrowFunction, name) {
|
|
149785
149832
|
var arrowFunctionBody = arrowFunction.body;
|
|
@@ -149796,7 +149843,7 @@ var ts;
|
|
|
149796
149843
|
var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined,
|
|
149797
149844
|
/*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock);
|
|
149798
149845
|
ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile);
|
|
149799
|
-
|
|
149846
|
+
members.push(method);
|
|
149800
149847
|
}
|
|
149801
149848
|
}
|
|
149802
149849
|
}
|
|
@@ -154226,6 +154273,74 @@ var ts;
|
|
|
154226
154273
|
})(ts || (ts = {}));
|
|
154227
154274
|
/* @internal */
|
|
154228
154275
|
var ts;
|
|
154276
|
+
(function (ts) {
|
|
154277
|
+
var codefix;
|
|
154278
|
+
(function (codefix) {
|
|
154279
|
+
var fixId = "fixUnreferenceableDecoratorMetadata";
|
|
154280
|
+
var errorCodes = [ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled.code];
|
|
154281
|
+
codefix.registerCodeFix({
|
|
154282
|
+
errorCodes: errorCodes,
|
|
154283
|
+
getCodeActions: function (context) {
|
|
154284
|
+
var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
154285
|
+
if (!importDeclaration)
|
|
154286
|
+
return;
|
|
154287
|
+
var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 269 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); });
|
|
154288
|
+
var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); });
|
|
154289
|
+
var actions;
|
|
154290
|
+
if (namespaceChanges.length) {
|
|
154291
|
+
actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, namespaceChanges, ts.Diagnostics.Convert_named_imports_to_namespace_import));
|
|
154292
|
+
}
|
|
154293
|
+
if (typeOnlyChanges.length) {
|
|
154294
|
+
actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, typeOnlyChanges, ts.Diagnostics.Convert_to_type_only_import));
|
|
154295
|
+
}
|
|
154296
|
+
return actions;
|
|
154297
|
+
},
|
|
154298
|
+
fixIds: [fixId],
|
|
154299
|
+
});
|
|
154300
|
+
function getImportDeclaration(sourceFile, program, start) {
|
|
154301
|
+
var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier);
|
|
154302
|
+
if (!identifier || identifier.parent.kind !== 177 /* TypeReference */)
|
|
154303
|
+
return;
|
|
154304
|
+
var checker = program.getTypeChecker();
|
|
154305
|
+
var symbol = checker.getSymbolAtLocation(identifier);
|
|
154306
|
+
return ts.find((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, ts.or(ts.isImportClause, ts.isImportSpecifier, ts.isImportEqualsDeclaration));
|
|
154307
|
+
}
|
|
154308
|
+
// Converts the import declaration of the offending import to a type-only import,
|
|
154309
|
+
// only if it can be done without affecting other imported names. If the conversion
|
|
154310
|
+
// cannot be done cleanly, we could offer to *extract* the offending import to a
|
|
154311
|
+
// new type-only import declaration, but honestly I doubt anyone will ever use this
|
|
154312
|
+
// codefix at all, so it's probably not worth the lines of code.
|
|
154313
|
+
function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) {
|
|
154314
|
+
if (importDeclaration.kind === 264 /* ImportEqualsDeclaration */) {
|
|
154315
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importDeclaration.name);
|
|
154316
|
+
return;
|
|
154317
|
+
}
|
|
154318
|
+
var importClause = importDeclaration.kind === 266 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent;
|
|
154319
|
+
if (importClause.name && importClause.namedBindings) {
|
|
154320
|
+
// Cannot convert an import with a default import and named bindings to type-only
|
|
154321
|
+
// (it's a grammar error).
|
|
154322
|
+
return;
|
|
154323
|
+
}
|
|
154324
|
+
var checker = program.getTypeChecker();
|
|
154325
|
+
var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) {
|
|
154326
|
+
if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */)
|
|
154327
|
+
return true;
|
|
154328
|
+
});
|
|
154329
|
+
if (importsValue) {
|
|
154330
|
+
// Assume that if someone wrote a non-type-only import that includes some values,
|
|
154331
|
+
// they intend to use those values in value positions, even if they haven't yet.
|
|
154332
|
+
// Don't convert it to type-only.
|
|
154333
|
+
return;
|
|
154334
|
+
}
|
|
154335
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importClause);
|
|
154336
|
+
}
|
|
154337
|
+
function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
|
|
154338
|
+
ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
|
|
154339
|
+
}
|
|
154340
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
154341
|
+
})(ts || (ts = {}));
|
|
154342
|
+
/* @internal */
|
|
154343
|
+
var ts;
|
|
154229
154344
|
(function (ts) {
|
|
154230
154345
|
var codefix;
|
|
154231
154346
|
(function (codefix) {
|
|
@@ -156793,6 +156908,7 @@ var ts;
|
|
|
156793
156908
|
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
|
|
156794
156909
|
}
|
|
156795
156910
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
156911
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156796
156912
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
156797
156913
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156798
156914
|
}
|
|
@@ -156822,6 +156938,7 @@ var ts;
|
|
|
156822
156938
|
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
|
|
156823
156939
|
}
|
|
156824
156940
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
156941
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156825
156942
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
156826
156943
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156827
156944
|
}
|
|
@@ -157745,20 +157862,22 @@ var ts;
|
|
|
157745
157862
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
157746
157863
|
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
157747
157864
|
}
|
|
157748
|
-
var
|
|
157749
|
-
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
157750
|
-
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
157865
|
+
var shouldUseDefault = getShouldUseDefault(context.program, importClause);
|
|
157751
157866
|
return shouldUseDefault
|
|
157752
157867
|
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
157753
157868
|
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
157754
157869
|
}
|
|
157870
|
+
function getShouldUseDefault(program, importClause) {
|
|
157871
|
+
return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
|
|
157872
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157873
|
+
}
|
|
157755
157874
|
function doChange(sourceFile, program, changes, info) {
|
|
157756
157875
|
var checker = program.getTypeChecker();
|
|
157757
157876
|
if (info.convertTo === 0 /* Named */) {
|
|
157758
157877
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
157759
157878
|
}
|
|
157760
157879
|
else {
|
|
157761
|
-
doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157880
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */);
|
|
157762
157881
|
}
|
|
157763
157882
|
}
|
|
157764
157883
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -157808,7 +157927,9 @@ var ts;
|
|
|
157808
157927
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
157809
157928
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
157810
157929
|
}
|
|
157811
|
-
function doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157930
|
+
function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConvert, shouldUseDefault) {
|
|
157931
|
+
if (shouldUseDefault === void 0) { shouldUseDefault = getShouldUseDefault(program, toConvert.parent); }
|
|
157932
|
+
var checker = program.getTypeChecker();
|
|
157812
157933
|
var importDecl = toConvert.parent.parent;
|
|
157813
157934
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
157814
157935
|
var toConvertSymbols = new ts.Set();
|
|
@@ -157869,6 +157990,7 @@ var ts;
|
|
|
157869
157990
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
157870
157991
|
}
|
|
157871
157992
|
}
|
|
157993
|
+
refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
|
|
157872
157994
|
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
157873
157995
|
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
157874
157996
|
if (!externalModule)
|
|
@@ -159269,7 +159391,9 @@ var ts;
|
|
|
159269
159391
|
var checker = context.program.getTypeChecker();
|
|
159270
159392
|
// Make a unique name for the extracted variable
|
|
159271
159393
|
var file = scope.getSourceFile();
|
|
159272
|
-
var localNameText = ts.
|
|
159394
|
+
var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind)
|
|
159395
|
+
? node.name.text
|
|
159396
|
+
: ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file);
|
|
159273
159397
|
var isJS = ts.isInJSFile(scope);
|
|
159274
159398
|
var variableType = isJS || !checker.isContextSensitive(node)
|
|
159275
159399
|
? undefined
|
|
@@ -163036,10 +163160,12 @@ var ts;
|
|
|
163036
163160
|
this.fileNameToEntry = new ts.Map();
|
|
163037
163161
|
// Initialize the list with the root file names
|
|
163038
163162
|
var rootFileNames = host.getScriptFileNames();
|
|
163163
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
|
|
163039
163164
|
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
|
|
163040
163165
|
var fileName = rootFileNames_1[_i];
|
|
163041
163166
|
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
|
163042
163167
|
}
|
|
163168
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
163043
163169
|
}
|
|
163044
163170
|
HostCache.prototype.createEntry = function (fileName, path) {
|
|
163045
163171
|
var entry;
|
|
@@ -168110,6 +168236,7 @@ var ts;
|
|
|
168110
168236
|
*/
|
|
168111
168237
|
Project.prototype.updateGraph = function () {
|
|
168112
168238
|
var _a;
|
|
168239
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] });
|
|
168113
168240
|
ts.perfLogger.logStartUpdateGraph();
|
|
168114
168241
|
this.resolutionCache.startRecordingFilesWithChangedResolutions();
|
|
168115
168242
|
var hasNewProgram = this.updateGraphWorker();
|
|
@@ -168153,6 +168280,7 @@ var ts;
|
|
|
168153
168280
|
this.getPackageJsonAutoImportProvider();
|
|
168154
168281
|
}
|
|
168155
168282
|
ts.perfLogger.logStopUpdateGraph();
|
|
168283
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168156
168284
|
return !hasNewProgram;
|
|
168157
168285
|
};
|
|
168158
168286
|
/*@internal*/
|
|
@@ -168185,7 +168313,9 @@ var ts;
|
|
|
168185
168313
|
this.resolutionCache.startCachingPerDirectoryResolution();
|
|
168186
168314
|
this.program = this.languageService.getProgram(); // TODO: GH#18217
|
|
168187
168315
|
this.dirty = false;
|
|
168316
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
|
|
168188
168317
|
this.resolutionCache.finishCachingPerDirectoryResolution();
|
|
168318
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168189
168319
|
ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
|
|
168190
168320
|
// bump up the version if
|
|
168191
168321
|
// - oldProgram is not set - this is a first time updateGraph is called
|
|
@@ -168733,13 +168863,16 @@ var ts;
|
|
|
168733
168863
|
}
|
|
168734
168864
|
var dependencySelection = this.includePackageJsonAutoImports();
|
|
168735
168865
|
if (dependencySelection) {
|
|
168866
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider");
|
|
168736
168867
|
var start = ts.timestamp();
|
|
168737
168868
|
this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry);
|
|
168738
168869
|
if (this.autoImportProviderHost) {
|
|
168739
168870
|
server.updateProjectIfDirty(this.autoImportProviderHost);
|
|
168740
168871
|
this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", ts.timestamp() - start);
|
|
168872
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168741
168873
|
return this.autoImportProviderHost.getCurrentProgram();
|
|
168742
168874
|
}
|
|
168875
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168743
168876
|
}
|
|
168744
168877
|
};
|
|
168745
168878
|
/*@internal*/
|
|
@@ -168759,10 +168892,14 @@ var ts;
|
|
|
168759
168892
|
}());
|
|
168760
168893
|
server.Project = Project;
|
|
168761
168894
|
function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) {
|
|
168895
|
+
var sourceFiles = program.getSourceFiles();
|
|
168896
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length });
|
|
168762
168897
|
var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); });
|
|
168763
|
-
|
|
168898
|
+
var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) {
|
|
168764
168899
|
return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile);
|
|
168765
168900
|
}));
|
|
168901
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168902
|
+
return result;
|
|
168766
168903
|
}
|
|
168767
168904
|
function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) {
|
|
168768
168905
|
return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () {
|
|
@@ -170836,6 +170973,7 @@ var ts;
|
|
|
170836
170973
|
};
|
|
170837
170974
|
/* @internal */
|
|
170838
170975
|
ProjectService.prototype.createConfiguredProject = function (configFileName) {
|
|
170976
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName });
|
|
170839
170977
|
this.logger.info("Creating configuration project " + configFileName);
|
|
170840
170978
|
var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName));
|
|
170841
170979
|
var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
|
|
@@ -170884,6 +171022,7 @@ var ts;
|
|
|
170884
171022
|
/* @internal */
|
|
170885
171023
|
ProjectService.prototype.loadConfiguredProject = function (project, reason) {
|
|
170886
171024
|
var _this = this;
|
|
171025
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath });
|
|
170887
171026
|
this.sendProjectLoadingStartEvent(project, reason);
|
|
170888
171027
|
// Read updated contents from disk
|
|
170889
171028
|
var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath()));
|
|
@@ -170919,6 +171058,7 @@ var ts;
|
|
|
170919
171058
|
project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides);
|
|
170920
171059
|
var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles());
|
|
170921
171060
|
this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions);
|
|
171061
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
170922
171062
|
};
|
|
170923
171063
|
/*@internal*/
|
|
170924
171064
|
ProjectService.prototype.ensureParsedConfigUptoDate = function (configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) {
|
|
@@ -173967,7 +174107,6 @@ var ts;
|
|
|
173967
174107
|
this.host.write(msgText);
|
|
173968
174108
|
};
|
|
173969
174109
|
Session.prototype.event = function (body, eventName) {
|
|
173970
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
|
|
173971
174110
|
this.send(toEvent(eventName, body));
|
|
173972
174111
|
};
|
|
173973
174112
|
// For backwards-compatibility only.
|
|
@@ -174016,16 +174155,22 @@ var ts;
|
|
|
174016
174155
|
this.send(res);
|
|
174017
174156
|
};
|
|
174018
174157
|
Session.prototype.semanticCheck = function (file, project) {
|
|
174158
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
|
|
174019
174159
|
var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file)
|
|
174020
174160
|
? server.emptyArray
|
|
174021
174161
|
: project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; });
|
|
174022
174162
|
this.sendDiagnosticsEvent(file, project, diags, "semanticDiag");
|
|
174163
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
174023
174164
|
};
|
|
174024
174165
|
Session.prototype.syntacticCheck = function (file, project) {
|
|
174166
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
|
|
174025
174167
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag");
|
|
174168
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
174026
174169
|
};
|
|
174027
174170
|
Session.prototype.suggestionCheck = function (file, project) {
|
|
174171
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
|
|
174028
174172
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag");
|
|
174173
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
174029
174174
|
};
|
|
174030
174175
|
Session.prototype.sendDiagnosticsEvent = function (file, project, diagnostics, kind) {
|
|
174031
174176
|
try {
|