@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/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220321";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8239,6 +8239,7 @@ var ts;
|
|
|
8239
8239
|
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."),
|
|
8240
8240
|
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}'."),
|
|
8241
8241
|
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'."),
|
|
8242
|
+
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."),
|
|
8242
8243
|
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."),
|
|
8243
8244
|
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."),
|
|
8244
8245
|
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."),
|
|
@@ -40884,7 +40885,10 @@ var ts;
|
|
|
40884
40885
|
* file to. e.g. outDir
|
|
40885
40886
|
*/
|
|
40886
40887
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
40887
|
-
|
|
40888
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName });
|
|
40889
|
+
var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
|
|
40890
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
40891
|
+
return result;
|
|
40888
40892
|
}
|
|
40889
40893
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
40890
40894
|
/*@internal*/
|
|
@@ -47458,7 +47462,7 @@ var ts;
|
|
|
47458
47462
|
(preserveConstEnums && moduleState === 2 /* ConstEnumOnly */);
|
|
47459
47463
|
}
|
|
47460
47464
|
ts.isInstantiatedModule = isInstantiatedModule;
|
|
47461
|
-
function createTypeChecker(host
|
|
47465
|
+
function createTypeChecker(host) {
|
|
47462
47466
|
var getPackagesMap = ts.memoize(function () {
|
|
47463
47467
|
// A package name maps to true when we detect it has .d.ts files.
|
|
47464
47468
|
// This is useful as an approximation of whether a package bundles its own types.
|
|
@@ -47475,6 +47479,10 @@ var ts;
|
|
|
47475
47479
|
});
|
|
47476
47480
|
return map;
|
|
47477
47481
|
});
|
|
47482
|
+
var deferredDiagnosticsCallbacks = [];
|
|
47483
|
+
var addLazyDiagnostic = function (arg) {
|
|
47484
|
+
deferredDiagnosticsCallbacks.push(arg);
|
|
47485
|
+
};
|
|
47478
47486
|
// Cancellation that controls whether or not we can cancel in the middle of type checking.
|
|
47479
47487
|
// In general cancelling is *not* safe for the type checker. We might be in the middle of
|
|
47480
47488
|
// computing something, and we will leave our internals in an inconsistent state. Callers
|
|
@@ -47837,8 +47845,8 @@ var ts;
|
|
|
47837
47845
|
// Do this in a finally block so we can ensure that it gets reset back to nothing after
|
|
47838
47846
|
// this call is done.
|
|
47839
47847
|
cancellationToken = ct;
|
|
47840
|
-
// Ensure file is type checked
|
|
47841
|
-
|
|
47848
|
+
// Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused
|
|
47849
|
+
checkSourceFileWithEagerDiagnostics(file);
|
|
47842
47850
|
ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
47843
47851
|
diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
47844
47852
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
|
|
@@ -49173,110 +49181,114 @@ var ts;
|
|
|
49173
49181
|
}
|
|
49174
49182
|
}
|
|
49175
49183
|
if (!result) {
|
|
49176
|
-
if (nameNotFoundMessage
|
|
49177
|
-
|
|
49178
|
-
!
|
|
49179
|
-
!
|
|
49180
|
-
|
|
49181
|
-
|
|
49182
|
-
|
|
49183
|
-
|
|
49184
|
-
|
|
49185
|
-
|
|
49186
|
-
|
|
49187
|
-
|
|
49188
|
-
|
|
49189
|
-
|
|
49190
|
-
|
|
49191
|
-
|
|
49192
|
-
if (suggestion) {
|
|
49193
|
-
var suggestionName = symbolToString(suggestion);
|
|
49194
|
-
var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
|
|
49195
|
-
var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
|
|
49196
|
-
: isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
|
|
49197
|
-
: ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
|
|
49198
|
-
var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
|
|
49199
|
-
addErrorOrSuggestion(!isUncheckedJS, diagnostic);
|
|
49200
|
-
if (suggestion.valueDeclaration) {
|
|
49201
|
-
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
|
|
49184
|
+
if (nameNotFoundMessage) {
|
|
49185
|
+
addLazyDiagnostic(function () {
|
|
49186
|
+
if (!errorLocation ||
|
|
49187
|
+
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
|
|
49188
|
+
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
49189
|
+
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
49190
|
+
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
49191
|
+
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
49192
|
+
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
49193
|
+
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
49194
|
+
var suggestion = void 0;
|
|
49195
|
+
if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
|
|
49196
|
+
suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
|
|
49197
|
+
var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
|
|
49198
|
+
if (isGlobalScopeAugmentationDeclaration) {
|
|
49199
|
+
suggestion = undefined;
|
|
49202
49200
|
}
|
|
49203
|
-
|
|
49204
|
-
|
|
49205
|
-
|
|
49206
|
-
|
|
49207
|
-
|
|
49208
|
-
|
|
49209
|
-
|
|
49201
|
+
if (suggestion) {
|
|
49202
|
+
var suggestionName = symbolToString(suggestion);
|
|
49203
|
+
var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
|
|
49204
|
+
var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1
|
|
49205
|
+
: isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1
|
|
49206
|
+
: ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1;
|
|
49207
|
+
var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName);
|
|
49208
|
+
addErrorOrSuggestion(!isUncheckedJS, diagnostic);
|
|
49209
|
+
if (suggestion.valueDeclaration) {
|
|
49210
|
+
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
|
|
49211
|
+
}
|
|
49210
49212
|
}
|
|
49211
|
-
|
|
49212
|
-
|
|
49213
|
+
}
|
|
49214
|
+
if (!suggestion) {
|
|
49215
|
+
if (nameArg) {
|
|
49216
|
+
var lib = getSuggestedLibForNonExistentName(nameArg);
|
|
49217
|
+
if (lib) {
|
|
49218
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
|
|
49219
|
+
}
|
|
49220
|
+
else {
|
|
49221
|
+
error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
|
|
49222
|
+
}
|
|
49213
49223
|
}
|
|
49214
49224
|
}
|
|
49225
|
+
suggestionCount++;
|
|
49215
49226
|
}
|
|
49216
|
-
|
|
49217
|
-
}
|
|
49227
|
+
});
|
|
49218
49228
|
}
|
|
49219
49229
|
return undefined;
|
|
49220
49230
|
}
|
|
49231
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
49232
|
+
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
49233
|
+
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
49234
|
+
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
49235
|
+
var propertyName = propertyWithInvalidInitializer.name;
|
|
49236
|
+
error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
|
|
49237
|
+
return undefined;
|
|
49238
|
+
}
|
|
49221
49239
|
// Perform extra checks only if error reporting was requested
|
|
49222
|
-
if (nameNotFoundMessage
|
|
49223
|
-
|
|
49224
|
-
//
|
|
49225
|
-
//
|
|
49226
|
-
//
|
|
49227
|
-
|
|
49228
|
-
|
|
49229
|
-
|
|
49230
|
-
|
|
49231
|
-
|
|
49232
|
-
|
|
49233
|
-
|
|
49234
|
-
|
|
49235
|
-
|
|
49236
|
-
|
|
49237
|
-
|
|
49238
|
-
|
|
49239
|
-
|
|
49240
|
-
|
|
49241
|
-
|
|
49242
|
-
|
|
49243
|
-
|
|
49244
|
-
|
|
49245
|
-
|
|
49246
|
-
|
|
49247
|
-
|
|
49248
|
-
|
|
49249
|
-
|
|
49250
|
-
|
|
49251
|
-
|
|
49252
|
-
|
|
49253
|
-
|
|
49254
|
-
|
|
49255
|
-
|
|
49256
|
-
|
|
49257
|
-
|
|
49258
|
-
|
|
49259
|
-
|
|
49260
|
-
|
|
49261
|
-
|
|
49262
|
-
|
|
49263
|
-
|
|
49264
|
-
|
|
49265
|
-
|
|
49266
|
-
|
|
49267
|
-
|
|
49268
|
-
|
|
49269
|
-
|
|
49270
|
-
|
|
49271
|
-
|
|
49272
|
-
if (typeOnlyDeclaration) {
|
|
49273
|
-
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
49274
|
-
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
49275
|
-
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
49276
|
-
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
49277
|
-
addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
49240
|
+
if (nameNotFoundMessage) {
|
|
49241
|
+
addLazyDiagnostic(function () {
|
|
49242
|
+
// Only check for block-scoped variable if we have an error location and are looking for the
|
|
49243
|
+
// name with variable meaning
|
|
49244
|
+
// For example,
|
|
49245
|
+
// declare module foo {
|
|
49246
|
+
// interface bar {}
|
|
49247
|
+
// }
|
|
49248
|
+
// const foo/*1*/: foo/*2*/.bar;
|
|
49249
|
+
// The foo at /*1*/ and /*2*/ will share same symbol with two meanings:
|
|
49250
|
+
// block-scoped variable and namespace module. However, only when we
|
|
49251
|
+
// try to resolve name in /*1*/ which is used in variable position,
|
|
49252
|
+
// we want to check for block-scoped
|
|
49253
|
+
if (errorLocation &&
|
|
49254
|
+
(meaning & 2 /* BlockScopedVariable */ ||
|
|
49255
|
+
((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) {
|
|
49256
|
+
var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
|
|
49257
|
+
if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) {
|
|
49258
|
+
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
|
49259
|
+
}
|
|
49260
|
+
}
|
|
49261
|
+
// If we're in an external module, we can't reference value symbols created from UMD export declarations
|
|
49262
|
+
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) {
|
|
49263
|
+
var merged = getMergedSymbol(result);
|
|
49264
|
+
if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
|
|
49265
|
+
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));
|
|
49266
|
+
}
|
|
49267
|
+
}
|
|
49268
|
+
// 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
|
|
49269
|
+
if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) {
|
|
49270
|
+
var candidate = getMergedSymbol(getLateBoundSymbol(result));
|
|
49271
|
+
var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
|
|
49272
|
+
// A parameter initializer or binding pattern initializer within a parameter cannot refer to itself
|
|
49273
|
+
if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
|
|
49274
|
+
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
|
|
49275
|
+
}
|
|
49276
|
+
// And it cannot refer to any declarations which come after it
|
|
49277
|
+
else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
|
|
49278
|
+
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
|
|
49279
|
+
}
|
|
49280
|
+
}
|
|
49281
|
+
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
49282
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
49283
|
+
if (typeOnlyDeclaration) {
|
|
49284
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
49285
|
+
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
49286
|
+
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
49287
|
+
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
49288
|
+
addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
49289
|
+
}
|
|
49278
49290
|
}
|
|
49279
|
-
}
|
|
49291
|
+
});
|
|
49280
49292
|
}
|
|
49281
49293
|
return result;
|
|
49282
49294
|
}
|
|
@@ -50922,9 +50934,7 @@ var ts;
|
|
|
50922
50934
|
var result = new Type(checker, flags);
|
|
50923
50935
|
typeCount++;
|
|
50924
50936
|
result.id = typeCount;
|
|
50925
|
-
|
|
50926
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
|
|
50927
|
-
}
|
|
50937
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result);
|
|
50928
50938
|
return result;
|
|
50929
50939
|
}
|
|
50930
50940
|
function createOriginType(flags) {
|
|
@@ -54907,7 +54917,7 @@ var ts;
|
|
|
54907
54917
|
if (!omitTypeAlias) {
|
|
54908
54918
|
return errorType;
|
|
54909
54919
|
}
|
|
54910
|
-
return
|
|
54920
|
+
return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
|
|
54911
54921
|
}
|
|
54912
54922
|
var members = ts.createSymbolTable();
|
|
54913
54923
|
for (var _b = 0, spreadableProperties_1 = spreadableProperties; _b < spreadableProperties_1.length; _b++) {
|
|
@@ -56674,7 +56684,7 @@ var ts;
|
|
|
56674
56684
|
}
|
|
56675
56685
|
}
|
|
56676
56686
|
if (memberTypeList.length) {
|
|
56677
|
-
var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined
|
|
56687
|
+
var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined);
|
|
56678
56688
|
if (enumType_1.flags & 1048576 /* Union */) {
|
|
56679
56689
|
enumType_1.flags |= 1024 /* EnumLiteral */;
|
|
56680
56690
|
enumType_1.symbol = symbol;
|
|
@@ -59397,7 +59407,7 @@ var ts;
|
|
|
59397
59407
|
type.resolvedTypeArguments = source.resolvedTypeArguments;
|
|
59398
59408
|
return type;
|
|
59399
59409
|
}
|
|
59400
|
-
function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments
|
|
59410
|
+
function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) {
|
|
59401
59411
|
if (!aliasSymbol) {
|
|
59402
59412
|
aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
59403
59413
|
var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
|
|
@@ -59409,7 +59419,6 @@ var ts;
|
|
|
59409
59419
|
type.mapper = mapper;
|
|
59410
59420
|
type.aliasSymbol = aliasSymbol;
|
|
59411
59421
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
59412
|
-
type.aliasMapper = aliasMapper;
|
|
59413
59422
|
return type;
|
|
59414
59423
|
}
|
|
59415
59424
|
function getTypeArguments(type) {
|
|
@@ -59474,7 +59483,7 @@ var ts;
|
|
|
59474
59483
|
}
|
|
59475
59484
|
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
|
59476
59485
|
}
|
|
59477
|
-
function
|
|
59486
|
+
function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
|
|
59478
59487
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
59479
59488
|
if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
|
|
59480
59489
|
return getStringMappingType(symbol, typeArguments[0]);
|
|
@@ -59488,33 +59497,6 @@ var ts;
|
|
|
59488
59497
|
}
|
|
59489
59498
|
return instantiation;
|
|
59490
59499
|
}
|
|
59491
|
-
function getLocalTypeAliasInstantiation(symbol, typeArguments, outerTypeParameterMapper, aliasSymbol, aliasTypeArguments) {
|
|
59492
|
-
var type = getDeclaredTypeOfSymbol(symbol);
|
|
59493
|
-
if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
|
|
59494
|
-
return getStringMappingType(symbol, typeArguments[0]);
|
|
59495
|
-
}
|
|
59496
|
-
var links = getSymbolLinks(symbol);
|
|
59497
|
-
var outerTypeParameters = getOuterTypeParametersOfAlias(symbol);
|
|
59498
|
-
var mappedOuterParams = outerTypeParameterMapper && outerTypeParameters && instantiateTypes(outerTypeParameters, outerTypeParameterMapper);
|
|
59499
|
-
var typeParameters = links.typeParameters;
|
|
59500
|
-
var id = getTypeListId(ts.concatenate(mappedOuterParams, typeArguments)) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
59501
|
-
var instantiation = links.instantiations.get(id);
|
|
59502
|
-
if (!instantiation) {
|
|
59503
|
-
var outerTypeArgumentMapper = outerTypeParameters && mappedOuterParams && createTypeMapper(outerTypeParameters, mappedOuterParams);
|
|
59504
|
-
var argumentMapper = createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)));
|
|
59505
|
-
var combinedMapper = outerTypeArgumentMapper ? combineTypeMappers(argumentMapper, outerTypeArgumentMapper) : argumentMapper;
|
|
59506
|
-
links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, combinedMapper, aliasSymbol, aliasTypeArguments));
|
|
59507
|
-
}
|
|
59508
|
-
return instantiation;
|
|
59509
|
-
}
|
|
59510
|
-
function getOuterTypeParametersOfAlias(symbol) {
|
|
59511
|
-
var _a;
|
|
59512
|
-
var links = getSymbolLinks(symbol);
|
|
59513
|
-
if (!links.outerTypeParameters) {
|
|
59514
|
-
links.outerTypeParameters = ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) && getOuterTypeParameters(symbol.declarations[0], /*includeThisTypes*/ true);
|
|
59515
|
-
}
|
|
59516
|
-
return links.outerTypeParameters;
|
|
59517
|
-
}
|
|
59518
59500
|
/**
|
|
59519
59501
|
* Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
|
|
59520
59502
|
* references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
|
|
@@ -59550,7 +59532,7 @@ var ts;
|
|
|
59550
59532
|
// a .d.ts file. See #43622 for an example.
|
|
59551
59533
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
59552
59534
|
var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined;
|
|
59553
|
-
return
|
|
59535
|
+
return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol));
|
|
59554
59536
|
}
|
|
59555
59537
|
return checkNoTypeArguments(node, symbol) ? type : errorType;
|
|
59556
59538
|
}
|
|
@@ -60465,7 +60447,14 @@ var ts;
|
|
|
60465
60447
|
result.types = types;
|
|
60466
60448
|
return result;
|
|
60467
60449
|
}
|
|
60468
|
-
|
|
60450
|
+
// We sort and deduplicate the constituent types based on object identity. If the subtypeReduction
|
|
60451
|
+
// flag is specified we also reduce the constituent type set to only include types that aren't subtypes
|
|
60452
|
+
// of other types. Subtype reduction is expensive for large union types and is possible only when union
|
|
60453
|
+
// types are known not to circularly reference themselves (as is the case with union types created by
|
|
60454
|
+
// expression constructs such as array literals and the || and ?: operators). Named types can
|
|
60455
|
+
// circularly reference themselves and therefore cannot be subtype reduced during their declaration.
|
|
60456
|
+
// For example, "type Item = string | (() => Item" is a named type that circularly references itself.
|
|
60457
|
+
function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
|
|
60469
60458
|
if (unionReduction === void 0) { unionReduction = 1 /* Literal */; }
|
|
60470
60459
|
if (types.length === 0) {
|
|
60471
60460
|
return neverType;
|
|
@@ -60534,7 +60523,7 @@ var ts;
|
|
|
60534
60523
|
}
|
|
60535
60524
|
var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
|
|
60536
60525
|
(includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
|
|
60537
|
-
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments,
|
|
60526
|
+
return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
|
|
60538
60527
|
}
|
|
60539
60528
|
function getUnionOrIntersectionTypePredicate(signatures, kind) {
|
|
60540
60529
|
var first;
|
|
@@ -60572,7 +60561,7 @@ var ts;
|
|
|
60572
60561
|
return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
|
|
60573
60562
|
}
|
|
60574
60563
|
// This function assumes the constituent type list is sorted and deduplicated.
|
|
60575
|
-
function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments,
|
|
60564
|
+
function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) {
|
|
60576
60565
|
if (types.length === 0) {
|
|
60577
60566
|
return neverType;
|
|
60578
60567
|
}
|
|
@@ -60592,7 +60581,6 @@ var ts;
|
|
|
60592
60581
|
type.origin = origin;
|
|
60593
60582
|
type.aliasSymbol = aliasSymbol;
|
|
60594
60583
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
60595
|
-
type.aliasMapper = aliasMapper;
|
|
60596
60584
|
if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) {
|
|
60597
60585
|
type.flags |= 16 /* Boolean */;
|
|
60598
60586
|
type.intrinsicName = "boolean";
|
|
@@ -60605,7 +60593,7 @@ var ts;
|
|
|
60605
60593
|
var links = getNodeLinks(node);
|
|
60606
60594
|
if (!links.resolvedType) {
|
|
60607
60595
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
60608
|
-
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)
|
|
60596
|
+
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
60609
60597
|
}
|
|
60610
60598
|
return links.resolvedType;
|
|
60611
60599
|
}
|
|
@@ -60764,16 +60752,25 @@ var ts;
|
|
|
60764
60752
|
types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */);
|
|
60765
60753
|
return true;
|
|
60766
60754
|
}
|
|
60767
|
-
function createIntersectionType(types, aliasSymbol, aliasTypeArguments
|
|
60755
|
+
function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
60768
60756
|
var result = createType(2097152 /* Intersection */);
|
|
60769
60757
|
result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */);
|
|
60770
60758
|
result.types = types;
|
|
60771
60759
|
result.aliasSymbol = aliasSymbol;
|
|
60772
60760
|
result.aliasTypeArguments = aliasTypeArguments;
|
|
60773
|
-
result.aliasMapper = aliasMapper;
|
|
60774
60761
|
return result;
|
|
60775
60762
|
}
|
|
60776
|
-
|
|
60763
|
+
// We normalize combinations of intersection and union types based on the distributive property of the '&'
|
|
60764
|
+
// operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection
|
|
60765
|
+
// types with union type constituents into equivalent union types with intersection type constituents and
|
|
60766
|
+
// effectively ensure that union types are always at the top level in type representations.
|
|
60767
|
+
//
|
|
60768
|
+
// We do not perform structural deduplication on intersection types. Intersection types are created only by the &
|
|
60769
|
+
// type operator and we can't reduce those because we want to support recursive intersection types. For example,
|
|
60770
|
+
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
|
60771
|
+
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
|
60772
|
+
// for intersections of types with signatures can be deterministic.
|
|
60773
|
+
function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
|
|
60777
60774
|
var typeMembershipMap = new ts.Map();
|
|
60778
60775
|
var includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
60779
60776
|
var typeSet = ts.arrayFrom(typeMembershipMap.values());
|
|
@@ -60833,16 +60830,16 @@ var ts;
|
|
|
60833
60830
|
// When the intersection creates a reduced set (which might mean that *all* union types have
|
|
60834
60831
|
// disappeared), we restart the operation to get a new set of combined flags. Once we have
|
|
60835
60832
|
// reduced we'll never reduce again, so this occurs at most once.
|
|
60836
|
-
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments
|
|
60833
|
+
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
60837
60834
|
}
|
|
60838
60835
|
else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
|
|
60839
60836
|
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
|
|
60840
60837
|
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
60841
|
-
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
60838
|
+
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60842
60839
|
}
|
|
60843
60840
|
else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
|
|
60844
60841
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
60845
|
-
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
60842
|
+
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60846
60843
|
}
|
|
60847
60844
|
else {
|
|
60848
60845
|
// We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of
|
|
@@ -60855,7 +60852,7 @@ var ts;
|
|
|
60855
60852
|
// We attach a denormalized origin type when at least one constituent of the cross-product union is an
|
|
60856
60853
|
// intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions).
|
|
60857
60854
|
var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined;
|
|
60858
|
-
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments,
|
|
60855
|
+
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
60859
60856
|
}
|
|
60860
60857
|
}
|
|
60861
60858
|
else {
|
|
@@ -60901,7 +60898,7 @@ var ts;
|
|
|
60901
60898
|
var links = getNodeLinks(node);
|
|
60902
60899
|
if (!links.resolvedType) {
|
|
60903
60900
|
var aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
60904
|
-
links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)
|
|
60901
|
+
links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
|
|
60905
60902
|
}
|
|
60906
60903
|
return links.resolvedType;
|
|
60907
60904
|
}
|
|
@@ -61020,7 +61017,7 @@ var ts;
|
|
|
61020
61017
|
var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ?
|
|
61021
61018
|
info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; });
|
|
61022
61019
|
return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */,
|
|
61023
|
-
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined,
|
|
61020
|
+
/*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin);
|
|
61024
61021
|
}
|
|
61025
61022
|
/**
|
|
61026
61023
|
* A union type which is reducible upon instantiation (meaning some members are removed under certain instantiations)
|
|
@@ -61053,7 +61050,7 @@ var ts;
|
|
|
61053
61050
|
return type;
|
|
61054
61051
|
}
|
|
61055
61052
|
var extractTypeAlias = getGlobalExtractSymbol();
|
|
61056
|
-
return extractTypeAlias ?
|
|
61053
|
+
return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
|
|
61057
61054
|
}
|
|
61058
61055
|
function getIndexTypeOrString(type) {
|
|
61059
61056
|
var indexType = getExtractStringType(getIndexType(type));
|
|
@@ -61183,14 +61180,13 @@ var ts;
|
|
|
61183
61180
|
result.type = type;
|
|
61184
61181
|
return result;
|
|
61185
61182
|
}
|
|
61186
|
-
function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments
|
|
61183
|
+
function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) {
|
|
61187
61184
|
var type = createType(8388608 /* IndexedAccess */);
|
|
61188
61185
|
type.objectType = objectType;
|
|
61189
61186
|
type.indexType = indexType;
|
|
61190
61187
|
type.accessFlags = accessFlags;
|
|
61191
61188
|
type.aliasSymbol = aliasSymbol;
|
|
61192
61189
|
type.aliasTypeArguments = aliasTypeArguments;
|
|
61193
|
-
type.aliasMapper = aliasMapper;
|
|
61194
61190
|
return type;
|
|
61195
61191
|
}
|
|
61196
61192
|
/**
|
|
@@ -61548,9 +61544,9 @@ var ts;
|
|
|
61548
61544
|
var templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
61549
61545
|
return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
|
|
61550
61546
|
}
|
|
61551
|
-
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61547
|
+
function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61552
61548
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
61553
|
-
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61549
|
+
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
61554
61550
|
}
|
|
61555
61551
|
function indexTypeLessThan(indexType, limit) {
|
|
61556
61552
|
return everyType(indexType, function (t) {
|
|
@@ -61564,7 +61560,7 @@ var ts;
|
|
|
61564
61560
|
return false;
|
|
61565
61561
|
});
|
|
61566
61562
|
}
|
|
61567
|
-
function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments
|
|
61563
|
+
function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
61568
61564
|
if (accessFlags === void 0) { accessFlags = 0 /* None */; }
|
|
61569
61565
|
if (objectType === wildcardType || indexType === wildcardType) {
|
|
61570
61566
|
return wildcardType;
|
|
@@ -61595,7 +61591,7 @@ var ts;
|
|
|
61595
61591
|
var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
61596
61592
|
var type = indexedAccessTypes.get(id);
|
|
61597
61593
|
if (!type) {
|
|
61598
|
-
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments
|
|
61594
|
+
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments));
|
|
61599
61595
|
}
|
|
61600
61596
|
return type;
|
|
61601
61597
|
}
|
|
@@ -61625,8 +61621,8 @@ var ts;
|
|
|
61625
61621
|
return undefined;
|
|
61626
61622
|
}
|
|
61627
61623
|
return accessFlags & 4 /* Writing */
|
|
61628
|
-
? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments
|
|
61629
|
-
: getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
61624
|
+
? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
|
|
61625
|
+
: getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
61630
61626
|
}
|
|
61631
61627
|
return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */);
|
|
61632
61628
|
}
|
|
@@ -61636,7 +61632,7 @@ var ts;
|
|
|
61636
61632
|
var objectType = getTypeFromTypeNode(node.objectType);
|
|
61637
61633
|
var indexType = getTypeFromTypeNode(node.indexType);
|
|
61638
61634
|
var potentialAlias = getAliasSymbolForTypeNode(node);
|
|
61639
|
-
var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)
|
|
61635
|
+
var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
|
|
61640
61636
|
links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ &&
|
|
61641
61637
|
resolved.objectType === objectType &&
|
|
61642
61638
|
resolved.indexType === indexType ?
|
|
@@ -61803,7 +61799,6 @@ var ts;
|
|
|
61803
61799
|
result.combinedMapper = combinedMapper;
|
|
61804
61800
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
61805
61801
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
61806
|
-
result.aliasMapper = result.aliasSymbol ? mapper : undefined;
|
|
61807
61802
|
return "break";
|
|
61808
61803
|
};
|
|
61809
61804
|
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
@@ -62599,7 +62594,7 @@ var ts;
|
|
|
62599
62594
|
var result = target.instantiations.get(id);
|
|
62600
62595
|
if (!result) {
|
|
62601
62596
|
var newMapper = createTypeMapper(typeParameters, typeArguments);
|
|
62602
|
-
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments
|
|
62597
|
+
result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
|
|
62603
62598
|
target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
|
|
62604
62599
|
instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
|
|
62605
62600
|
target.instantiations.set(id, result);
|
|
@@ -62688,7 +62683,7 @@ var ts;
|
|
|
62688
62683
|
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
62689
62684
|
}
|
|
62690
62685
|
return t;
|
|
62691
|
-
}, aliasSymbol, aliasTypeArguments
|
|
62686
|
+
}, aliasSymbol, aliasTypeArguments);
|
|
62692
62687
|
}
|
|
62693
62688
|
}
|
|
62694
62689
|
// If the constraint type of the instantiation is the wildcard type, return the wildcard type.
|
|
@@ -62757,7 +62752,6 @@ var ts;
|
|
|
62757
62752
|
result.mapper = mapper;
|
|
62758
62753
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
62759
62754
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
62760
|
-
result.aliasMapper = mapper;
|
|
62761
62755
|
return result;
|
|
62762
62756
|
}
|
|
62763
62757
|
function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
@@ -62777,7 +62771,7 @@ var ts;
|
|
|
62777
62771
|
// distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the
|
|
62778
62772
|
// result is (A extends U ? X : Y) | (B extends U ? X : Y).
|
|
62779
62773
|
result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ?
|
|
62780
|
-
mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments
|
|
62774
|
+
mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) :
|
|
62781
62775
|
getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments);
|
|
62782
62776
|
root.instantiations.set(id, result);
|
|
62783
62777
|
}
|
|
@@ -62837,8 +62831,8 @@ var ts;
|
|
|
62837
62831
|
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
62838
62832
|
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
62839
62833
|
return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ?
|
|
62840
|
-
getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments
|
|
62841
|
-
getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments
|
|
62834
|
+
getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
|
|
62835
|
+
getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments);
|
|
62842
62836
|
}
|
|
62843
62837
|
if (flags & 4194304 /* Index */) {
|
|
62844
62838
|
return getIndexType(instantiateType(type.type, mapper));
|
|
@@ -62852,7 +62846,7 @@ var ts;
|
|
|
62852
62846
|
if (flags & 8388608 /* IndexedAccess */) {
|
|
62853
62847
|
var newAliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
62854
62848
|
var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
62855
|
-
return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments
|
|
62849
|
+
return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments);
|
|
62856
62850
|
}
|
|
62857
62851
|
if (flags & 16777216 /* Conditional */) {
|
|
62858
62852
|
return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
|
|
@@ -64846,10 +64840,7 @@ var ts;
|
|
|
64846
64840
|
if (variances === ts.emptyArray) {
|
|
64847
64841
|
return 1 /* Unknown */;
|
|
64848
64842
|
}
|
|
64849
|
-
var
|
|
64850
|
-
var sourceArgs = outerTypeParameters && source.aliasMapper ? ts.concatenate(source.aliasTypeArguments, instantiateTypes(outerTypeParameters, source.aliasMapper)) : source.aliasTypeArguments;
|
|
64851
|
-
var targetArgs = outerTypeParameters && target.aliasMapper ? ts.concatenate(target.aliasTypeArguments, instantiateTypes(outerTypeParameters, target.aliasMapper)) : target.aliasTypeArguments;
|
|
64852
|
-
var varianceResult = relateVariances(sourceArgs, targetArgs, variances, intersectionState);
|
|
64843
|
+
var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
|
|
64853
64844
|
if (varianceResult !== undefined) {
|
|
64854
64845
|
return varianceResult;
|
|
64855
64846
|
}
|
|
@@ -66138,11 +66129,8 @@ var ts;
|
|
|
66138
66129
|
}
|
|
66139
66130
|
function getAliasVariances(symbol) {
|
|
66140
66131
|
var links = getSymbolLinks(symbol);
|
|
66141
|
-
|
|
66142
|
-
|
|
66143
|
-
return getVariancesWorker(params, links, function (_links, param, marker) {
|
|
66144
|
-
var mapper = makeUnaryTypeMapper(param, marker);
|
|
66145
|
-
var type = getLocalTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, mapper), mapper);
|
|
66132
|
+
return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
|
|
66133
|
+
var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
|
|
66146
66134
|
type.aliasTypeArgumentsContainsMarker = true;
|
|
66147
66135
|
return type;
|
|
66148
66136
|
});
|
|
@@ -66799,7 +66787,7 @@ var ts;
|
|
|
66799
66787
|
}
|
|
66800
66788
|
// If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
|
|
66801
66789
|
return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
|
|
66802
|
-
|
|
66790
|
+
getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
|
|
66803
66791
|
reducedType;
|
|
66804
66792
|
}
|
|
66805
66793
|
function getNonNullableType(type) {
|
|
@@ -67142,12 +67130,14 @@ var ts;
|
|
|
67142
67130
|
errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
|
|
67143
67131
|
}
|
|
67144
67132
|
function reportErrorsFromWidening(declaration, type, wideningKind) {
|
|
67145
|
-
|
|
67146
|
-
|
|
67147
|
-
|
|
67148
|
-
|
|
67133
|
+
addLazyDiagnostic(function () {
|
|
67134
|
+
if (noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
|
|
67135
|
+
// Report implicit any error within type if possible, otherwise report error on declaration
|
|
67136
|
+
if (!reportWideningErrorsInType(type)) {
|
|
67137
|
+
reportImplicitAny(declaration, type, wideningKind);
|
|
67138
|
+
}
|
|
67149
67139
|
}
|
|
67150
|
-
}
|
|
67140
|
+
});
|
|
67151
67141
|
}
|
|
67152
67142
|
function applyToParameterTypes(source, target, callback) {
|
|
67153
67143
|
var sourceCount = getParameterCount(source);
|
|
@@ -69025,7 +69015,7 @@ var ts;
|
|
|
69025
69015
|
newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered);
|
|
69026
69016
|
}
|
|
69027
69017
|
}
|
|
69028
|
-
return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined,
|
|
69018
|
+
return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin);
|
|
69029
69019
|
}
|
|
69030
69020
|
return type.flags & 131072 /* Never */ || f(type) ? type : neverType;
|
|
69031
69021
|
}
|
|
@@ -69061,9 +69051,9 @@ var ts;
|
|
|
69061
69051
|
}
|
|
69062
69052
|
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
69063
69053
|
}
|
|
69064
|
-
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments
|
|
69054
|
+
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
69065
69055
|
return type.flags & 1048576 /* Union */ && aliasSymbol ?
|
|
69066
|
-
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments
|
|
69056
|
+
getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
|
|
69067
69057
|
mapType(type, mapper);
|
|
69068
69058
|
}
|
|
69069
69059
|
function extractTypesOfKind(type, kind) {
|
|
@@ -72248,7 +72238,7 @@ var ts;
|
|
|
72248
72238
|
var params = getSymbolLinks(managedSym).typeParameters;
|
|
72249
72239
|
if (ts.length(params) >= 2) {
|
|
72250
72240
|
var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
|
|
72251
|
-
return
|
|
72241
|
+
return getTypeAliasInstantiation(managedSym, args);
|
|
72252
72242
|
}
|
|
72253
72243
|
}
|
|
72254
72244
|
if (ts.length(declaredManagedType.typeParameters) >= 2) {
|
|
@@ -75139,7 +75129,7 @@ var ts;
|
|
|
75139
75129
|
var isTaggedTemplate = node.kind === 209 /* TaggedTemplateExpression */;
|
|
75140
75130
|
var isDecorator = node.kind === 164 /* Decorator */;
|
|
75141
75131
|
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
|
|
75142
|
-
var reportErrors = !candidatesOutArray
|
|
75132
|
+
var reportErrors = !candidatesOutArray;
|
|
75143
75133
|
var typeArguments;
|
|
75144
75134
|
if (!isDecorator) {
|
|
75145
75135
|
typeArguments = node.typeArguments;
|
|
@@ -76419,11 +76409,13 @@ var ts;
|
|
|
76419
76409
|
checkSourceElement(type);
|
|
76420
76410
|
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
|
|
76421
76411
|
var targetType = getTypeFromTypeNode(type);
|
|
76422
|
-
if (
|
|
76423
|
-
|
|
76424
|
-
|
|
76425
|
-
|
|
76426
|
-
|
|
76412
|
+
if (!isErrorType(targetType)) {
|
|
76413
|
+
addLazyDiagnostic(function () {
|
|
76414
|
+
var widenedType = getWidenedType(exprType);
|
|
76415
|
+
if (!isTypeComparableTo(targetType, widenedType)) {
|
|
76416
|
+
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);
|
|
76417
|
+
}
|
|
76418
|
+
});
|
|
76427
76419
|
}
|
|
76428
76420
|
return targetType;
|
|
76429
76421
|
}
|
|
@@ -77183,47 +77175,48 @@ var ts;
|
|
|
77183
77175
|
* @param returnType - return type of the function, can be undefined if return type is not explicitly specified
|
|
77184
77176
|
*/
|
|
77185
77177
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
77186
|
-
|
|
77187
|
-
|
|
77188
|
-
|
|
77189
|
-
|
|
77190
|
-
|
|
77191
|
-
|
|
77192
|
-
|
|
77193
|
-
|
|
77194
|
-
|
|
77195
|
-
|
|
77196
|
-
|
|
77197
|
-
|
|
77198
|
-
|
|
77199
|
-
|
|
77200
|
-
|
|
77201
|
-
|
|
77202
|
-
|
|
77203
|
-
|
|
77204
|
-
|
|
77205
|
-
|
|
77206
|
-
|
|
77207
|
-
|
|
77208
|
-
|
|
77209
|
-
|
|
77210
|
-
|
|
77211
|
-
|
|
77212
|
-
|
|
77213
|
-
|
|
77214
|
-
|
|
77215
|
-
|
|
77216
|
-
|
|
77217
|
-
|
|
77218
|
-
|
|
77219
|
-
|
|
77220
|
-
|
|
77221
|
-
|
|
77222
|
-
|
|
77223
|
-
|
|
77178
|
+
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
77179
|
+
return;
|
|
77180
|
+
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
77181
|
+
var functionFlags = ts.getFunctionFlags(func);
|
|
77182
|
+
var type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
77183
|
+
// Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions.
|
|
77184
|
+
if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) {
|
|
77185
|
+
return;
|
|
77186
|
+
}
|
|
77187
|
+
// If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
|
|
77188
|
+
// also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
|
|
77189
|
+
if (func.kind === 167 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 234 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
77190
|
+
return;
|
|
77191
|
+
}
|
|
77192
|
+
var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */;
|
|
77193
|
+
var errorNode = ts.getEffectiveReturnTypeNode(func) || func;
|
|
77194
|
+
if (type && type.flags & 131072 /* Never */) {
|
|
77195
|
+
error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
77196
|
+
}
|
|
77197
|
+
else if (type && !hasExplicitReturn) {
|
|
77198
|
+
// minimal check: function has syntactic return type annotation and no explicit return statements in the body
|
|
77199
|
+
// this function does not conform to the specification.
|
|
77200
|
+
error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
|
77201
|
+
}
|
|
77202
|
+
else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
|
|
77203
|
+
error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
77204
|
+
}
|
|
77205
|
+
else if (compilerOptions.noImplicitReturns) {
|
|
77206
|
+
if (!type) {
|
|
77207
|
+
// If return type annotation is omitted check if function has any explicit return statements.
|
|
77208
|
+
// If it does not have any - its inferred return type is void - don't do any checks.
|
|
77209
|
+
// Otherwise get inferred return type from function body and report error only if it is not void / anytype
|
|
77210
|
+
if (!hasExplicitReturn) {
|
|
77211
|
+
return;
|
|
77212
|
+
}
|
|
77213
|
+
var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
|
|
77214
|
+
if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
|
|
77215
|
+
return;
|
|
77216
|
+
}
|
|
77224
77217
|
}
|
|
77218
|
+
error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
|
|
77225
77219
|
}
|
|
77226
|
-
error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value);
|
|
77227
77220
|
}
|
|
77228
77221
|
}
|
|
77229
77222
|
function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
|
|
@@ -77483,49 +77476,50 @@ var ts;
|
|
|
77483
77476
|
checkExpression(node.expression);
|
|
77484
77477
|
return undefinedWideningType;
|
|
77485
77478
|
}
|
|
77486
|
-
function
|
|
77479
|
+
function checkAwaitExpressionGrammar(node) {
|
|
77487
77480
|
// Grammar checking
|
|
77488
|
-
|
|
77489
|
-
|
|
77490
|
-
|
|
77491
|
-
|
|
77492
|
-
|
|
77493
|
-
|
|
77494
|
-
|
|
77495
|
-
|
|
77496
|
-
|
|
77497
|
-
|
|
77498
|
-
if (!
|
|
77499
|
-
if (!span)
|
|
77500
|
-
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77501
|
-
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);
|
|
77502
|
-
diagnostics.add(diagnostic);
|
|
77503
|
-
}
|
|
77504
|
-
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 */) {
|
|
77481
|
+
var container = ts.getContainingFunctionOrClassStaticBlock(node);
|
|
77482
|
+
if (container && ts.isClassStaticBlockDeclaration(container)) {
|
|
77483
|
+
error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block);
|
|
77484
|
+
}
|
|
77485
|
+
else if (!(node.flags & 32768 /* AwaitContext */)) {
|
|
77486
|
+
if (ts.isInTopLevelContext(node)) {
|
|
77487
|
+
var sourceFile = ts.getSourceFileOfNode(node);
|
|
77488
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
77489
|
+
var span = void 0;
|
|
77490
|
+
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
77491
|
+
if (!span)
|
|
77505
77492
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77506
|
-
|
|
77507
|
-
|
|
77508
|
-
}
|
|
77493
|
+
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);
|
|
77494
|
+
diagnostics.add(diagnostic);
|
|
77509
77495
|
}
|
|
77510
|
-
|
|
77511
|
-
|
|
77512
|
-
|
|
77513
|
-
var sourceFile = ts.getSourceFileOfNode(node);
|
|
77514
|
-
if (!hasParseDiagnostics(sourceFile)) {
|
|
77515
|
-
var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77516
|
-
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);
|
|
77517
|
-
if (container && container.kind !== 170 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
|
|
77518
|
-
var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
|
|
77519
|
-
ts.addRelatedInfo(diagnostic, relatedInfo);
|
|
77520
|
-
}
|
|
77496
|
+
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 */) {
|
|
77497
|
+
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77498
|
+
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);
|
|
77521
77499
|
diagnostics.add(diagnostic);
|
|
77522
77500
|
}
|
|
77523
77501
|
}
|
|
77524
77502
|
}
|
|
77525
|
-
|
|
77526
|
-
|
|
77503
|
+
else {
|
|
77504
|
+
// use of 'await' in non-async function
|
|
77505
|
+
var sourceFile = ts.getSourceFileOfNode(node);
|
|
77506
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
77507
|
+
var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
77508
|
+
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);
|
|
77509
|
+
if (container && container.kind !== 170 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) {
|
|
77510
|
+
var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
|
|
77511
|
+
ts.addRelatedInfo(diagnostic, relatedInfo);
|
|
77512
|
+
}
|
|
77513
|
+
diagnostics.add(diagnostic);
|
|
77514
|
+
}
|
|
77527
77515
|
}
|
|
77528
77516
|
}
|
|
77517
|
+
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
77518
|
+
error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
77519
|
+
}
|
|
77520
|
+
}
|
|
77521
|
+
function checkAwaitExpression(node) {
|
|
77522
|
+
addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); });
|
|
77529
77523
|
var operandType = checkExpression(node.expression);
|
|
77530
77524
|
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);
|
|
77531
77525
|
if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
|
|
@@ -78349,7 +78343,10 @@ var ts;
|
|
|
78349
78343
|
}
|
|
78350
78344
|
}
|
|
78351
78345
|
function checkAssignmentOperator(valueType) {
|
|
78352
|
-
if (
|
|
78346
|
+
if (ts.isAssignmentOperator(operator)) {
|
|
78347
|
+
addLazyDiagnostic(checkAssignmentOperatorWorker);
|
|
78348
|
+
}
|
|
78349
|
+
function checkAssignmentOperatorWorker() {
|
|
78353
78350
|
// TypeScript 1.0 spec (April 2014): 4.17
|
|
78354
78351
|
// An assignment of the form
|
|
78355
78352
|
// VarExpr = ValueExpr
|
|
@@ -78448,15 +78445,7 @@ var ts;
|
|
|
78448
78445
|
return [effectiveLeft, effectiveRight];
|
|
78449
78446
|
}
|
|
78450
78447
|
function checkYieldExpression(node) {
|
|
78451
|
-
|
|
78452
|
-
if (produceDiagnostics) {
|
|
78453
|
-
if (!(node.flags & 8192 /* YieldContext */)) {
|
|
78454
|
-
grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
|
|
78455
|
-
}
|
|
78456
|
-
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
78457
|
-
error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
78458
|
-
}
|
|
78459
|
-
}
|
|
78448
|
+
addLazyDiagnostic(checkYieldExpressionGrammar);
|
|
78460
78449
|
var func = ts.getContainingFunction(node);
|
|
78461
78450
|
if (!func)
|
|
78462
78451
|
return anyType;
|
|
@@ -78502,14 +78491,24 @@ var ts;
|
|
|
78502
78491
|
var type = getContextualIterationType(2 /* Next */, func);
|
|
78503
78492
|
if (!type) {
|
|
78504
78493
|
type = anyType;
|
|
78505
|
-
|
|
78506
|
-
|
|
78507
|
-
|
|
78508
|
-
|
|
78494
|
+
addLazyDiagnostic(function () {
|
|
78495
|
+
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
78496
|
+
var contextualType = getContextualType(node);
|
|
78497
|
+
if (!contextualType || isTypeAny(contextualType)) {
|
|
78498
|
+
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
78499
|
+
}
|
|
78509
78500
|
}
|
|
78510
|
-
}
|
|
78501
|
+
});
|
|
78511
78502
|
}
|
|
78512
78503
|
return type;
|
|
78504
|
+
function checkYieldExpressionGrammar() {
|
|
78505
|
+
if (!(node.flags & 8192 /* YieldContext */)) {
|
|
78506
|
+
grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
|
|
78507
|
+
}
|
|
78508
|
+
if (isInParameterInitializerBeforeContainingFunction(node)) {
|
|
78509
|
+
error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
|
|
78510
|
+
}
|
|
78511
|
+
}
|
|
78513
78512
|
}
|
|
78514
78513
|
function checkConditionalExpression(node, checkMode) {
|
|
78515
78514
|
checkTruthinessExpression(node.condition);
|
|
@@ -79092,9 +79091,7 @@ var ts;
|
|
|
79092
79091
|
if (constraintType && defaultType) {
|
|
79093
79092
|
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
|
79094
79093
|
}
|
|
79095
|
-
|
|
79096
|
-
checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
|
|
79097
|
-
}
|
|
79094
|
+
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
79098
79095
|
}
|
|
79099
79096
|
function checkParameter(node) {
|
|
79100
79097
|
// Grammar checking
|
|
@@ -79248,7 +79245,8 @@ var ts;
|
|
|
79248
79245
|
if (node.type) {
|
|
79249
79246
|
checkSourceElement(node.type);
|
|
79250
79247
|
}
|
|
79251
|
-
|
|
79248
|
+
addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
|
|
79249
|
+
function checkSignatureDeclarationDiagnostics() {
|
|
79252
79250
|
checkCollisionWithArgumentsInGeneratedCode(node);
|
|
79253
79251
|
var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
|
|
79254
79252
|
if (noImplicitAny && !returnTypeNode) {
|
|
@@ -79538,9 +79536,8 @@ var ts;
|
|
|
79538
79536
|
if (ts.nodeIsMissing(node.body)) {
|
|
79539
79537
|
return;
|
|
79540
79538
|
}
|
|
79541
|
-
|
|
79542
|
-
|
|
79543
|
-
}
|
|
79539
|
+
addLazyDiagnostic(checkConstructorDeclarationDiagnostics);
|
|
79540
|
+
return;
|
|
79544
79541
|
function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
|
|
79545
79542
|
if (ts.isPrivateIdentifierClassElementDeclaration(n)) {
|
|
79546
79543
|
return true;
|
|
@@ -79549,54 +79546,56 @@ var ts;
|
|
|
79549
79546
|
!ts.isStatic(n) &&
|
|
79550
79547
|
!!n.initializer;
|
|
79551
79548
|
}
|
|
79552
|
-
|
|
79553
|
-
|
|
79554
|
-
|
|
79555
|
-
|
|
79556
|
-
|
|
79557
|
-
|
|
79558
|
-
|
|
79559
|
-
|
|
79560
|
-
|
|
79561
|
-
if (
|
|
79562
|
-
|
|
79563
|
-
|
|
79564
|
-
|
|
79565
|
-
|
|
79566
|
-
|
|
79567
|
-
|
|
79568
|
-
|
|
79569
|
-
(ts.
|
|
79570
|
-
ts.some(node.
|
|
79571
|
-
|
|
79572
|
-
|
|
79573
|
-
// See GH #8277
|
|
79574
|
-
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
79575
|
-
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);
|
|
79576
|
-
}
|
|
79577
|
-
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
79578
|
-
else {
|
|
79579
|
-
var superCallStatement = void 0;
|
|
79580
|
-
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
79581
|
-
var statement = _a[_i];
|
|
79582
|
-
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
79583
|
-
superCallStatement = statement;
|
|
79584
|
-
break;
|
|
79585
|
-
}
|
|
79586
|
-
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
79587
|
-
break;
|
|
79588
|
-
}
|
|
79589
|
-
}
|
|
79549
|
+
function checkConstructorDeclarationDiagnostics() {
|
|
79550
|
+
// TS 1.0 spec (April 2014): 8.3.2
|
|
79551
|
+
// Constructors of classes with no extends clause may not contain super calls, whereas
|
|
79552
|
+
// constructors of derived classes must contain at least one super call somewhere in their function body.
|
|
79553
|
+
var containingClassDecl = node.parent;
|
|
79554
|
+
if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
|
|
79555
|
+
captureLexicalThis(node.parent, containingClassDecl);
|
|
79556
|
+
var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
|
|
79557
|
+
var superCall = findFirstSuperCall(node.body);
|
|
79558
|
+
if (superCall) {
|
|
79559
|
+
if (classExtendsNull) {
|
|
79560
|
+
error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
79561
|
+
}
|
|
79562
|
+
// A super call must be root-level in a constructor if both of the following are true:
|
|
79563
|
+
// - The containing class is a derived class.
|
|
79564
|
+
// - The constructor declares parameter properties
|
|
79565
|
+
// or the containing class declares instance member variables with initializers.
|
|
79566
|
+
var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
79567
|
+
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
79568
|
+
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
79569
|
+
if (superCallShouldBeRootLevel) {
|
|
79590
79570
|
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
79591
79571
|
// See GH #8277
|
|
79592
|
-
if (
|
|
79593
|
-
error(
|
|
79572
|
+
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
79573
|
+
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);
|
|
79574
|
+
}
|
|
79575
|
+
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
79576
|
+
else {
|
|
79577
|
+
var superCallStatement = void 0;
|
|
79578
|
+
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
79579
|
+
var statement = _a[_i];
|
|
79580
|
+
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
79581
|
+
superCallStatement = statement;
|
|
79582
|
+
break;
|
|
79583
|
+
}
|
|
79584
|
+
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
79585
|
+
break;
|
|
79586
|
+
}
|
|
79587
|
+
}
|
|
79588
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
79589
|
+
// See GH #8277
|
|
79590
|
+
if (superCallStatement === undefined) {
|
|
79591
|
+
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);
|
|
79592
|
+
}
|
|
79594
79593
|
}
|
|
79595
79594
|
}
|
|
79596
79595
|
}
|
|
79597
|
-
|
|
79598
|
-
|
|
79599
|
-
|
|
79596
|
+
else if (!classExtendsNull) {
|
|
79597
|
+
error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
|
|
79598
|
+
}
|
|
79600
79599
|
}
|
|
79601
79600
|
}
|
|
79602
79601
|
}
|
|
@@ -79614,7 +79613,10 @@ var ts;
|
|
|
79614
79613
|
return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
|
|
79615
79614
|
}
|
|
79616
79615
|
function checkAccessorDeclaration(node) {
|
|
79617
|
-
|
|
79616
|
+
addLazyDiagnostic(checkAccessorDeclarationDiagnostics);
|
|
79617
|
+
checkSourceElement(node.body);
|
|
79618
|
+
setNodeLinksForPrivateIdentifierScope(node);
|
|
79619
|
+
function checkAccessorDeclarationDiagnostics() {
|
|
79618
79620
|
// Grammar checking accessors
|
|
79619
79621
|
if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
|
|
79620
79622
|
checkGrammarComputedPropertyName(node.name);
|
|
@@ -79664,8 +79666,6 @@ var ts;
|
|
|
79664
79666
|
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
|
|
79665
79667
|
}
|
|
79666
79668
|
}
|
|
79667
|
-
checkSourceElement(node.body);
|
|
79668
|
-
setNodeLinksForPrivateIdentifierScope(node);
|
|
79669
79669
|
}
|
|
79670
79670
|
function checkMissingDeclaration(node) {
|
|
79671
79671
|
checkDecorators(node);
|
|
@@ -79708,11 +79708,13 @@ var ts;
|
|
|
79708
79708
|
ts.forEach(node.typeArguments, checkSourceElement);
|
|
79709
79709
|
var type = getTypeFromTypeReference(node);
|
|
79710
79710
|
if (!isErrorType(type)) {
|
|
79711
|
-
if (node.typeArguments
|
|
79712
|
-
|
|
79713
|
-
|
|
79714
|
-
|
|
79715
|
-
|
|
79711
|
+
if (node.typeArguments) {
|
|
79712
|
+
addLazyDiagnostic(function () {
|
|
79713
|
+
var typeParameters = getTypeParametersForTypeReference(node);
|
|
79714
|
+
if (typeParameters) {
|
|
79715
|
+
checkTypeArgumentConstraints(node, typeParameters);
|
|
79716
|
+
}
|
|
79717
|
+
});
|
|
79716
79718
|
}
|
|
79717
79719
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
79718
79720
|
if (symbol) {
|
|
@@ -79740,7 +79742,8 @@ var ts;
|
|
|
79740
79742
|
}
|
|
79741
79743
|
function checkTypeLiteral(node) {
|
|
79742
79744
|
ts.forEach(node.members, checkSourceElement);
|
|
79743
|
-
|
|
79745
|
+
addLazyDiagnostic(checkTypeLiteralDiagnostics);
|
|
79746
|
+
function checkTypeLiteralDiagnostics() {
|
|
79744
79747
|
var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
|
|
79745
79748
|
checkIndexConstraints(type, type.symbol);
|
|
79746
79749
|
checkTypeForDuplicateIndexSignatures(node);
|
|
@@ -79931,9 +79934,9 @@ var ts;
|
|
|
79931
79934
|
return flags & flagsToCheck;
|
|
79932
79935
|
}
|
|
79933
79936
|
function checkFunctionOrConstructorSymbol(symbol) {
|
|
79934
|
-
|
|
79935
|
-
|
|
79936
|
-
|
|
79937
|
+
addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
|
|
79938
|
+
}
|
|
79939
|
+
function checkFunctionOrConstructorSymbolWorker(symbol) {
|
|
79937
79940
|
function getCanonicalOverload(overloads, implementation) {
|
|
79938
79941
|
// Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
|
|
79939
79942
|
// Error on all deviations from this canonical set of flags
|
|
@@ -80154,9 +80157,9 @@ var ts;
|
|
|
80154
80157
|
}
|
|
80155
80158
|
}
|
|
80156
80159
|
function checkExportsOnMergedDeclarations(node) {
|
|
80157
|
-
|
|
80158
|
-
|
|
80159
|
-
|
|
80160
|
+
addLazyDiagnostic(function () { return checkExportsOnMergedDeclarationsWorker(node); });
|
|
80161
|
+
}
|
|
80162
|
+
function checkExportsOnMergedDeclarationsWorker(node) {
|
|
80160
80163
|
// if localSymbol is defined on node then node itself is exported - check is required
|
|
80161
80164
|
var symbol = node.localSymbol;
|
|
80162
80165
|
if (!symbol) {
|
|
@@ -80392,7 +80395,7 @@ var ts;
|
|
|
80392
80395
|
if (awaitedSymbol) {
|
|
80393
80396
|
// Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
|
|
80394
80397
|
// an `Awaited<T | U>` would suffice.
|
|
80395
|
-
return
|
|
80398
|
+
return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
|
|
80396
80399
|
}
|
|
80397
80400
|
}
|
|
80398
80401
|
}
|
|
@@ -80643,20 +80646,31 @@ var ts;
|
|
|
80643
80646
|
* marked as referenced to prevent import elision.
|
|
80644
80647
|
*/
|
|
80645
80648
|
function markTypeNodeAsReferenced(node) {
|
|
80646
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
80649
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
|
|
80647
80650
|
}
|
|
80648
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
80651
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
80649
80652
|
if (!typeName)
|
|
80650
80653
|
return;
|
|
80651
80654
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
80652
80655
|
var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
|
|
80653
80656
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
|
80654
|
-
if (rootSymbol
|
|
80655
|
-
|
|
80656
|
-
|
|
80657
|
-
|
|
80658
|
-
|
|
80659
|
-
|
|
80657
|
+
if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) {
|
|
80658
|
+
if (symbolIsValue(rootSymbol)
|
|
80659
|
+
&& !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
|
|
80660
|
+
&& !getTypeOnlyAliasDeclaration(rootSymbol)) {
|
|
80661
|
+
markAliasSymbolAsReferenced(rootSymbol);
|
|
80662
|
+
}
|
|
80663
|
+
else if (forDecoratorMetadata
|
|
80664
|
+
&& compilerOptions.isolatedModules
|
|
80665
|
+
&& ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015
|
|
80666
|
+
&& !symbolIsValue(rootSymbol)
|
|
80667
|
+
&& !ts.some(rootSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration)) {
|
|
80668
|
+
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);
|
|
80669
|
+
var aliasDeclaration = ts.find(rootSymbol.declarations || ts.emptyArray, isAliasSymbolDeclaration);
|
|
80670
|
+
if (aliasDeclaration) {
|
|
80671
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(aliasDeclaration, ts.Diagnostics._0_was_imported_here, ts.idText(rootName)));
|
|
80672
|
+
}
|
|
80673
|
+
}
|
|
80660
80674
|
}
|
|
80661
80675
|
}
|
|
80662
80676
|
/**
|
|
@@ -80669,7 +80683,7 @@ var ts;
|
|
|
80669
80683
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
80670
80684
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
80671
80685
|
if (entityName && ts.isEntityName(entityName)) {
|
|
80672
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
80686
|
+
markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
|
|
80673
80687
|
}
|
|
80674
80688
|
}
|
|
80675
80689
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -80789,7 +80803,8 @@ var ts;
|
|
|
80789
80803
|
ts.forEach(node.decorators, checkDecorator);
|
|
80790
80804
|
}
|
|
80791
80805
|
function checkFunctionDeclaration(node) {
|
|
80792
|
-
|
|
80806
|
+
addLazyDiagnostic(checkFunctionDeclarationDiagnostics);
|
|
80807
|
+
function checkFunctionDeclarationDiagnostics() {
|
|
80793
80808
|
checkFunctionOrMethodDeclaration(node);
|
|
80794
80809
|
checkGrammarForGenerator(node);
|
|
80795
80810
|
checkCollisionsForDeclarationName(node, node.name);
|
|
@@ -80823,10 +80838,13 @@ var ts;
|
|
|
80823
80838
|
checkSourceElement(node.typeExpression);
|
|
80824
80839
|
}
|
|
80825
80840
|
function checkJSDocFunctionType(node) {
|
|
80826
|
-
|
|
80827
|
-
reportImplicitAny(node, anyType);
|
|
80828
|
-
}
|
|
80841
|
+
addLazyDiagnostic(checkJSDocFunctionTypeImplicitAny);
|
|
80829
80842
|
checkSignatureDeclaration(node);
|
|
80843
|
+
function checkJSDocFunctionTypeImplicitAny() {
|
|
80844
|
+
if (!node.type && !ts.isJSDocConstructSignature(node)) {
|
|
80845
|
+
reportImplicitAny(node, anyType);
|
|
80846
|
+
}
|
|
80847
|
+
}
|
|
80830
80848
|
}
|
|
80831
80849
|
function checkJSDocImplementsTag(node) {
|
|
80832
80850
|
var classLike = ts.getEffectiveJSDocHost(node);
|
|
@@ -80907,19 +80925,7 @@ var ts;
|
|
|
80907
80925
|
var body = node.kind === 167 /* MethodSignature */ ? undefined : node.body;
|
|
80908
80926
|
checkSourceElement(body);
|
|
80909
80927
|
checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
|
|
80910
|
-
|
|
80911
|
-
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
|
|
80912
|
-
// in an ambient context
|
|
80913
|
-
if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
|
|
80914
|
-
reportImplicitAny(node, anyType);
|
|
80915
|
-
}
|
|
80916
|
-
if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
|
|
80917
|
-
// A generator with a body and no type annotation can still cause errors. It can error if the
|
|
80918
|
-
// yielded values have no common supertype, or it can give an implicit any error if it has no
|
|
80919
|
-
// yielded values. The only way to trigger these errors is to try checking its return type.
|
|
80920
|
-
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
|
|
80921
|
-
}
|
|
80922
|
-
}
|
|
80928
|
+
addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics);
|
|
80923
80929
|
// A js function declaration can have a @type tag instead of a return type node, but that type must have a call signature
|
|
80924
80930
|
if (ts.isInJSFile(node)) {
|
|
80925
80931
|
var typeTag = ts.getJSDocTypeTag(node);
|
|
@@ -80927,10 +80933,26 @@ var ts;
|
|
|
80927
80933
|
error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
|
|
80928
80934
|
}
|
|
80929
80935
|
}
|
|
80936
|
+
function checkFunctionOrMethodDeclarationDiagnostics() {
|
|
80937
|
+
if (!ts.getEffectiveReturnTypeNode(node)) {
|
|
80938
|
+
// Report an implicit any error if there is no body, no explicit return type, and node is not a private method
|
|
80939
|
+
// in an ambient context
|
|
80940
|
+
if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
|
|
80941
|
+
reportImplicitAny(node, anyType);
|
|
80942
|
+
}
|
|
80943
|
+
if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) {
|
|
80944
|
+
// A generator with a body and no type annotation can still cause errors. It can error if the
|
|
80945
|
+
// yielded values have no common supertype, or it can give an implicit any error if it has no
|
|
80946
|
+
// yielded values. The only way to trigger these errors is to try checking its return type.
|
|
80947
|
+
getReturnTypeOfSignature(getSignatureFromDeclaration(node));
|
|
80948
|
+
}
|
|
80949
|
+
}
|
|
80950
|
+
}
|
|
80930
80951
|
}
|
|
80931
80952
|
function registerForUnusedIdentifiersCheck(node) {
|
|
80932
|
-
|
|
80933
|
-
|
|
80953
|
+
addLazyDiagnostic(registerForUnusedIdentifiersCheckDiagnostics);
|
|
80954
|
+
function registerForUnusedIdentifiersCheckDiagnostics() {
|
|
80955
|
+
// May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`.
|
|
80934
80956
|
var sourceFile = ts.getSourceFileOfNode(node);
|
|
80935
80957
|
var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
|
|
80936
80958
|
if (!potentiallyUnusedIdentifiers) {
|
|
@@ -82704,26 +82726,31 @@ var ts;
|
|
|
82704
82726
|
hasDuplicateDefaultClause = true;
|
|
82705
82727
|
}
|
|
82706
82728
|
}
|
|
82707
|
-
if (
|
|
82708
|
-
|
|
82709
|
-
// In a 'switch' statement, each 'case' expression must be of a type that is comparable
|
|
82710
|
-
// to or from the type of the 'switch' expression.
|
|
82711
|
-
var caseType = checkExpression(clause.expression);
|
|
82712
|
-
var caseIsLiteral = isLiteralType(caseType);
|
|
82713
|
-
var comparedExpressionType = expressionType;
|
|
82714
|
-
if (!caseIsLiteral || !expressionIsLiteral) {
|
|
82715
|
-
caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
|
|
82716
|
-
comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
|
|
82717
|
-
}
|
|
82718
|
-
if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
|
|
82719
|
-
// expressionType is not comparable to caseType, try the reversed check and report errors if it fails
|
|
82720
|
-
checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
|
|
82721
|
-
}
|
|
82729
|
+
if (clause.kind === 288 /* CaseClause */) {
|
|
82730
|
+
addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause));
|
|
82722
82731
|
}
|
|
82723
82732
|
ts.forEach(clause.statements, checkSourceElement);
|
|
82724
82733
|
if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
|
|
82725
82734
|
error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
|
|
82726
82735
|
}
|
|
82736
|
+
function createLazyCaseClauseDiagnostics(clause) {
|
|
82737
|
+
return function () {
|
|
82738
|
+
// TypeScript 1.0 spec (April 2014): 5.9
|
|
82739
|
+
// In a 'switch' statement, each 'case' expression must be of a type that is comparable
|
|
82740
|
+
// to or from the type of the 'switch' expression.
|
|
82741
|
+
var caseType = checkExpression(clause.expression);
|
|
82742
|
+
var caseIsLiteral = isLiteralType(caseType);
|
|
82743
|
+
var comparedExpressionType = expressionType;
|
|
82744
|
+
if (!caseIsLiteral || !expressionIsLiteral) {
|
|
82745
|
+
caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
|
|
82746
|
+
comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
|
|
82747
|
+
}
|
|
82748
|
+
if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
|
|
82749
|
+
// expressionType is not comparable to caseType, try the reversed check and report errors if it fails
|
|
82750
|
+
checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, /*headMessage*/ undefined);
|
|
82751
|
+
}
|
|
82752
|
+
};
|
|
82753
|
+
}
|
|
82727
82754
|
});
|
|
82728
82755
|
if (node.caseBlock.locals) {
|
|
82729
82756
|
registerForUnusedIdentifiersCheck(node.caseBlock);
|
|
@@ -82944,26 +82971,29 @@ var ts;
|
|
|
82944
82971
|
* Check each type parameter and check that type parameters have no duplicate type parameter declarations
|
|
82945
82972
|
*/
|
|
82946
82973
|
function checkTypeParameters(typeParameterDeclarations) {
|
|
82974
|
+
var seenDefault = false;
|
|
82947
82975
|
if (typeParameterDeclarations) {
|
|
82948
|
-
var seenDefault = false;
|
|
82949
82976
|
for (var i = 0; i < typeParameterDeclarations.length; i++) {
|
|
82950
82977
|
var node = typeParameterDeclarations[i];
|
|
82951
82978
|
checkTypeParameter(node);
|
|
82952
|
-
|
|
82953
|
-
|
|
82954
|
-
|
|
82955
|
-
|
|
82956
|
-
|
|
82957
|
-
|
|
82958
|
-
|
|
82959
|
-
|
|
82960
|
-
|
|
82961
|
-
|
|
82962
|
-
|
|
82963
|
-
|
|
82979
|
+
addLazyDiagnostic(createCheckTypeParameterDiagnostic(node, i));
|
|
82980
|
+
}
|
|
82981
|
+
}
|
|
82982
|
+
function createCheckTypeParameterDiagnostic(node, i) {
|
|
82983
|
+
return function () {
|
|
82984
|
+
if (node.default) {
|
|
82985
|
+
seenDefault = true;
|
|
82986
|
+
checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
|
|
82987
|
+
}
|
|
82988
|
+
else if (seenDefault) {
|
|
82989
|
+
error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
|
|
82990
|
+
}
|
|
82991
|
+
for (var j = 0; j < i; j++) {
|
|
82992
|
+
if (typeParameterDeclarations[j].symbol === node.symbol) {
|
|
82993
|
+
error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
|
|
82964
82994
|
}
|
|
82965
82995
|
}
|
|
82966
|
-
}
|
|
82996
|
+
};
|
|
82967
82997
|
}
|
|
82968
82998
|
}
|
|
82969
82999
|
/** Check that type parameter defaults only reference previously declared type parameters */
|
|
@@ -83095,85 +83125,90 @@ var ts;
|
|
|
83095
83125
|
if (extendsNode && extendsNode !== baseTypeNode) {
|
|
83096
83126
|
checkExpression(extendsNode.expression);
|
|
83097
83127
|
}
|
|
83098
|
-
var
|
|
83099
|
-
if (
|
|
83100
|
-
|
|
83101
|
-
|
|
83102
|
-
|
|
83103
|
-
|
|
83104
|
-
|
|
83105
|
-
|
|
83106
|
-
ts.
|
|
83107
|
-
|
|
83108
|
-
var
|
|
83109
|
-
|
|
83110
|
-
|
|
83128
|
+
var baseTypes_2 = getBaseTypes(type);
|
|
83129
|
+
if (baseTypes_2.length) {
|
|
83130
|
+
addLazyDiagnostic(function () {
|
|
83131
|
+
var baseType = baseTypes_2[0];
|
|
83132
|
+
var baseConstructorType = getBaseConstructorTypeOfClass(type);
|
|
83133
|
+
var staticBaseType = getApparentType(baseConstructorType);
|
|
83134
|
+
checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
|
|
83135
|
+
checkSourceElement(baseTypeNode.expression);
|
|
83136
|
+
if (ts.some(baseTypeNode.typeArguments)) {
|
|
83137
|
+
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
|
|
83138
|
+
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
|
|
83139
|
+
var constructor = _a[_i];
|
|
83140
|
+
if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
|
|
83141
|
+
break;
|
|
83142
|
+
}
|
|
83111
83143
|
}
|
|
83112
83144
|
}
|
|
83113
|
-
|
|
83114
|
-
|
|
83115
|
-
|
|
83116
|
-
issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
|
|
83117
|
-
}
|
|
83118
|
-
else {
|
|
83119
|
-
// Report static side error only when instance type is assignable
|
|
83120
|
-
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
|
|
83121
|
-
}
|
|
83122
|
-
if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
|
|
83123
|
-
if (!isMixinConstructorType(staticType)) {
|
|
83124
|
-
error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
|
|
83145
|
+
var baseWithThis = getTypeWithThisArgument(baseType, type.thisType);
|
|
83146
|
+
if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
|
|
83147
|
+
issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
|
|
83125
83148
|
}
|
|
83126
83149
|
else {
|
|
83127
|
-
|
|
83128
|
-
|
|
83129
|
-
|
|
83150
|
+
// Report static side error only when instance type is assignable
|
|
83151
|
+
checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
|
|
83152
|
+
}
|
|
83153
|
+
if (baseConstructorType.flags & 8650752 /* TypeVariable */) {
|
|
83154
|
+
if (!isMixinConstructorType(staticType)) {
|
|
83155
|
+
error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
|
|
83156
|
+
}
|
|
83157
|
+
else {
|
|
83158
|
+
var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */);
|
|
83159
|
+
if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
|
|
83160
|
+
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);
|
|
83161
|
+
}
|
|
83130
83162
|
}
|
|
83131
83163
|
}
|
|
83132
|
-
|
|
83133
|
-
|
|
83134
|
-
|
|
83135
|
-
|
|
83136
|
-
|
|
83137
|
-
|
|
83138
|
-
|
|
83164
|
+
if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) {
|
|
83165
|
+
// When the static base type is a "class-like" constructor function (but not actually a class), we verify
|
|
83166
|
+
// that all instantiated base constructor signatures return the same type.
|
|
83167
|
+
var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
|
|
83168
|
+
if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType); })) {
|
|
83169
|
+
error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
|
|
83170
|
+
}
|
|
83139
83171
|
}
|
|
83140
|
-
|
|
83141
|
-
|
|
83172
|
+
checkKindsOfPropertyMemberOverrides(type, baseType);
|
|
83173
|
+
});
|
|
83142
83174
|
}
|
|
83143
83175
|
}
|
|
83144
83176
|
checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
|
|
83145
83177
|
var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
|
|
83146
83178
|
if (implementedTypeNodes) {
|
|
83147
|
-
for (var
|
|
83148
|
-
var typeRefNode = implementedTypeNodes_1[
|
|
83179
|
+
for (var _i = 0, implementedTypeNodes_1 = implementedTypeNodes; _i < implementedTypeNodes_1.length; _i++) {
|
|
83180
|
+
var typeRefNode = implementedTypeNodes_1[_i];
|
|
83149
83181
|
if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
|
|
83150
83182
|
error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
|
|
83151
83183
|
}
|
|
83152
83184
|
checkTypeReferenceNode(typeRefNode);
|
|
83153
|
-
|
|
83154
|
-
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
83155
|
-
if (!isErrorType(t)) {
|
|
83156
|
-
if (isValidBaseType(t)) {
|
|
83157
|
-
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
83158
|
-
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
83159
|
-
ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
|
|
83160
|
-
var baseWithThis = getTypeWithThisArgument(t, type.thisType);
|
|
83161
|
-
if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
|
|
83162
|
-
issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
|
|
83163
|
-
}
|
|
83164
|
-
}
|
|
83165
|
-
else {
|
|
83166
|
-
error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
|
83167
|
-
}
|
|
83168
|
-
}
|
|
83169
|
-
}
|
|
83185
|
+
addLazyDiagnostic(createImplementsDiagnostics(typeRefNode));
|
|
83170
83186
|
}
|
|
83171
83187
|
}
|
|
83172
|
-
|
|
83188
|
+
addLazyDiagnostic(function () {
|
|
83173
83189
|
checkIndexConstraints(type, symbol);
|
|
83174
83190
|
checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
|
|
83175
83191
|
checkTypeForDuplicateIndexSignatures(node);
|
|
83176
83192
|
checkPropertyInitialization(node);
|
|
83193
|
+
});
|
|
83194
|
+
function createImplementsDiagnostics(typeRefNode) {
|
|
83195
|
+
return function () {
|
|
83196
|
+
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
83197
|
+
if (!isErrorType(t)) {
|
|
83198
|
+
if (isValidBaseType(t)) {
|
|
83199
|
+
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
83200
|
+
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
83201
|
+
ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
|
|
83202
|
+
var baseWithThis = getTypeWithThisArgument(t, type.thisType);
|
|
83203
|
+
if (!checkTypeAssignableTo(typeWithThis, baseWithThis, /*errorNode*/ undefined)) {
|
|
83204
|
+
issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
|
|
83205
|
+
}
|
|
83206
|
+
}
|
|
83207
|
+
else {
|
|
83208
|
+
error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
|
|
83209
|
+
}
|
|
83210
|
+
}
|
|
83211
|
+
};
|
|
83177
83212
|
}
|
|
83178
83213
|
}
|
|
83179
83214
|
function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
|
|
@@ -83497,8 +83532,8 @@ var ts;
|
|
|
83497
83532
|
ts.forEach(properties, function (p) {
|
|
83498
83533
|
seen.set(p.escapedName, p);
|
|
83499
83534
|
});
|
|
83500
|
-
for (var _i = 0,
|
|
83501
|
-
var base =
|
|
83535
|
+
for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
|
|
83536
|
+
var base = baseTypes_3[_i];
|
|
83502
83537
|
var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
|
|
83503
83538
|
for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
|
|
83504
83539
|
var prop = properties_4[_a];
|
|
@@ -83520,8 +83555,8 @@ var ts;
|
|
|
83520
83555
|
seen.set(p.escapedName, { prop: p, containingType: type });
|
|
83521
83556
|
});
|
|
83522
83557
|
var ok = true;
|
|
83523
|
-
for (var _i = 0,
|
|
83524
|
-
var base =
|
|
83558
|
+
for (var _i = 0, baseTypes_4 = baseTypes; _i < baseTypes_4.length; _i++) {
|
|
83559
|
+
var base = baseTypes_4[_i];
|
|
83525
83560
|
var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
|
|
83526
83561
|
for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
|
|
83527
83562
|
var prop = properties_6[_a];
|
|
@@ -83605,7 +83640,7 @@ var ts;
|
|
|
83605
83640
|
if (!checkGrammarDecoratorsAndModifiers(node))
|
|
83606
83641
|
checkGrammarInterfaceDeclaration(node);
|
|
83607
83642
|
checkTypeParameters(node.typeParameters);
|
|
83608
|
-
|
|
83643
|
+
addLazyDiagnostic(function () {
|
|
83609
83644
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
|
|
83610
83645
|
checkExportsOnMergedDeclarations(node);
|
|
83611
83646
|
var symbol = getSymbolOfNode(node);
|
|
@@ -83625,7 +83660,7 @@ var ts;
|
|
|
83625
83660
|
}
|
|
83626
83661
|
}
|
|
83627
83662
|
checkObjectTypeForDuplicateDeclarations(node);
|
|
83628
|
-
}
|
|
83663
|
+
});
|
|
83629
83664
|
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
|
|
83630
83665
|
if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
|
|
83631
83666
|
error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
|
|
@@ -83633,10 +83668,10 @@ var ts;
|
|
|
83633
83668
|
checkTypeReferenceNode(heritageElement);
|
|
83634
83669
|
});
|
|
83635
83670
|
ts.forEach(node.members, checkSourceElement);
|
|
83636
|
-
|
|
83671
|
+
addLazyDiagnostic(function () {
|
|
83637
83672
|
checkTypeForDuplicateIndexSignatures(node);
|
|
83638
83673
|
registerForUnusedIdentifiersCheck(node);
|
|
83639
|
-
}
|
|
83674
|
+
});
|
|
83640
83675
|
}
|
|
83641
83676
|
function checkTypeAliasDeclaration(node) {
|
|
83642
83677
|
// Grammar checking
|
|
@@ -83825,9 +83860,9 @@ var ts;
|
|
|
83825
83860
|
ts.isStringLiteralLike(node.argumentExpression);
|
|
83826
83861
|
}
|
|
83827
83862
|
function checkEnumDeclaration(node) {
|
|
83828
|
-
|
|
83829
|
-
|
|
83830
|
-
|
|
83863
|
+
addLazyDiagnostic(function () { return checkEnumDeclarationWorker(node); });
|
|
83864
|
+
}
|
|
83865
|
+
function checkEnumDeclarationWorker(node) {
|
|
83831
83866
|
// Grammar checking
|
|
83832
83867
|
checkGrammarDecoratorsAndModifiers(node);
|
|
83833
83868
|
checkCollisionsForDeclarationName(node, node.name);
|
|
@@ -83907,7 +83942,14 @@ var ts;
|
|
|
83907
83942
|
}
|
|
83908
83943
|
}
|
|
83909
83944
|
function checkModuleDeclaration(node) {
|
|
83910
|
-
if (
|
|
83945
|
+
if (node.body) {
|
|
83946
|
+
checkSourceElement(node.body);
|
|
83947
|
+
if (!ts.isGlobalScopeAugmentation(node)) {
|
|
83948
|
+
registerForUnusedIdentifiersCheck(node);
|
|
83949
|
+
}
|
|
83950
|
+
}
|
|
83951
|
+
addLazyDiagnostic(checkModuleDeclarationDiagnostics);
|
|
83952
|
+
function checkModuleDeclarationDiagnostics() {
|
|
83911
83953
|
// Grammar checking
|
|
83912
83954
|
var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
|
|
83913
83955
|
var inAmbientContext = node.flags & 8388608 /* Ambient */;
|
|
@@ -83990,12 +84032,6 @@ var ts;
|
|
|
83990
84032
|
}
|
|
83991
84033
|
}
|
|
83992
84034
|
}
|
|
83993
|
-
if (node.body) {
|
|
83994
|
-
checkSourceElement(node.body);
|
|
83995
|
-
if (!ts.isGlobalScopeAugmentation(node)) {
|
|
83996
|
-
registerForUnusedIdentifiersCheck(node);
|
|
83997
|
-
}
|
|
83998
|
-
}
|
|
83999
84035
|
}
|
|
84000
84036
|
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
|
|
84001
84037
|
var _a;
|
|
@@ -84321,7 +84357,7 @@ var ts;
|
|
|
84321
84357
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
84322
84358
|
return;
|
|
84323
84359
|
}
|
|
84324
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
84360
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
84325
84361
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
84326
84362
|
}
|
|
84327
84363
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
@@ -84932,13 +84968,16 @@ var ts;
|
|
|
84932
84968
|
if (ts.isExternalOrCommonJsModule(node)) {
|
|
84933
84969
|
registerForUnusedIdentifiersCheck(node);
|
|
84934
84970
|
}
|
|
84935
|
-
|
|
84936
|
-
|
|
84937
|
-
|
|
84938
|
-
|
|
84939
|
-
|
|
84940
|
-
|
|
84941
|
-
|
|
84971
|
+
addLazyDiagnostic(function () {
|
|
84972
|
+
// This relies on the results of other lazy diagnostics, so must be computed after them
|
|
84973
|
+
if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
|
|
84974
|
+
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
|
|
84975
|
+
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608 /* Ambient */))) {
|
|
84976
|
+
diagnostics.add(diag);
|
|
84977
|
+
}
|
|
84978
|
+
});
|
|
84979
|
+
}
|
|
84980
|
+
});
|
|
84942
84981
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
84943
84982
|
!node.isDeclarationFile &&
|
|
84944
84983
|
ts.isExternalModule(node)) {
|
|
@@ -84978,15 +85017,35 @@ var ts;
|
|
|
84978
85017
|
cancellationToken = undefined;
|
|
84979
85018
|
}
|
|
84980
85019
|
}
|
|
85020
|
+
function ensurePendingDiagnosticWorkComplete() {
|
|
85021
|
+
// Invoke any existing lazy diagnostics to add them, clear the backlog of diagnostics
|
|
85022
|
+
for (var _i = 0, deferredDiagnosticsCallbacks_1 = deferredDiagnosticsCallbacks; _i < deferredDiagnosticsCallbacks_1.length; _i++) {
|
|
85023
|
+
var cb = deferredDiagnosticsCallbacks_1[_i];
|
|
85024
|
+
cb();
|
|
85025
|
+
}
|
|
85026
|
+
deferredDiagnosticsCallbacks = [];
|
|
85027
|
+
}
|
|
85028
|
+
function checkSourceFileWithEagerDiagnostics(sourceFile) {
|
|
85029
|
+
ensurePendingDiagnosticWorkComplete();
|
|
85030
|
+
// then setup diagnostics for immediate invocation (as we are about to collect them, and
|
|
85031
|
+
// this avoids the overhead of longer-lived callbacks we don't need to allocate)
|
|
85032
|
+
// This also serves to make the shift to possibly lazy diagnostics transparent to serial command-line scenarios
|
|
85033
|
+
// (as in those cases, all the diagnostics will still be computed as the appropriate place in the tree,
|
|
85034
|
+
// thus much more likely retaining the same union ordering as before we had lazy diagnostics)
|
|
85035
|
+
var oldAddLazyDiagnostics = addLazyDiagnostic;
|
|
85036
|
+
addLazyDiagnostic = function (cb) { return cb(); };
|
|
85037
|
+
checkSourceFile(sourceFile);
|
|
85038
|
+
addLazyDiagnostic = oldAddLazyDiagnostics;
|
|
85039
|
+
}
|
|
84981
85040
|
function getDiagnosticsWorker(sourceFile) {
|
|
84982
|
-
throwIfNonDiagnosticsProducing();
|
|
84983
85041
|
if (sourceFile) {
|
|
85042
|
+
ensurePendingDiagnosticWorkComplete();
|
|
84984
85043
|
// Some global diagnostics are deferred until they are needed and
|
|
84985
85044
|
// may not be reported in the first call to getGlobalDiagnostics.
|
|
84986
85045
|
// We should catch these changes and report them.
|
|
84987
85046
|
var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
|
|
84988
85047
|
var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
|
|
84989
|
-
|
|
85048
|
+
checkSourceFileWithEagerDiagnostics(sourceFile);
|
|
84990
85049
|
var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
|
84991
85050
|
var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
|
|
84992
85051
|
if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
|
|
@@ -85004,18 +85063,13 @@ var ts;
|
|
|
85004
85063
|
}
|
|
85005
85064
|
// Global diagnostics are always added when a file is not provided to
|
|
85006
85065
|
// getDiagnostics
|
|
85007
|
-
ts.forEach(host.getSourceFiles(),
|
|
85066
|
+
ts.forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics);
|
|
85008
85067
|
return diagnostics.getDiagnostics();
|
|
85009
85068
|
}
|
|
85010
85069
|
function getGlobalDiagnostics() {
|
|
85011
|
-
|
|
85070
|
+
ensurePendingDiagnosticWorkComplete();
|
|
85012
85071
|
return diagnostics.getGlobalDiagnostics();
|
|
85013
85072
|
}
|
|
85014
|
-
function throwIfNonDiagnosticsProducing() {
|
|
85015
|
-
if (!produceDiagnostics) {
|
|
85016
|
-
throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
|
|
85017
|
-
}
|
|
85018
|
-
}
|
|
85019
85073
|
// Language service support
|
|
85020
85074
|
function getSymbolsInScope(location, meaning) {
|
|
85021
85075
|
if (location.flags & 16777216 /* InWithStatement */) {
|
|
@@ -87498,10 +87552,9 @@ var ts;
|
|
|
87498
87552
|
}
|
|
87499
87553
|
var parent = ts.walkUpParenthesizedTypes(node.parent);
|
|
87500
87554
|
if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
|
|
87501
|
-
|
|
87502
|
-
if (
|
|
87503
|
-
|
|
87504
|
-
parent = parent.parent.parent;
|
|
87555
|
+
var host_2 = ts.getJSDocHost(parent);
|
|
87556
|
+
if (host_2) {
|
|
87557
|
+
parent = ts.getSingleVariableOfVariableStatement(host_2) || host_2;
|
|
87505
87558
|
}
|
|
87506
87559
|
}
|
|
87507
87560
|
switch (parent.kind) {
|
|
@@ -115465,8 +115518,7 @@ var ts;
|
|
|
115465
115518
|
var files;
|
|
115466
115519
|
var symlinks;
|
|
115467
115520
|
var commonSourceDirectory;
|
|
115468
|
-
var
|
|
115469
|
-
var noDiagnosticsTypeChecker;
|
|
115521
|
+
var typeChecker;
|
|
115470
115522
|
var classifiableNames;
|
|
115471
115523
|
var ambientModuleNameToUnmodifiedFileName = new ts.Map();
|
|
115472
115524
|
var fileReasons = ts.createMultiMap();
|
|
@@ -115712,21 +115764,19 @@ var ts;
|
|
|
115712
115764
|
getProgramDiagnostics: getProgramDiagnostics,
|
|
115713
115765
|
getTypeChecker: getTypeChecker,
|
|
115714
115766
|
getClassifiableNames: getClassifiableNames,
|
|
115715
|
-
getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
|
|
115716
115767
|
getCommonSourceDirectory: getCommonSourceDirectory,
|
|
115717
115768
|
emit: emit,
|
|
115718
115769
|
getCurrentDirectory: function () { return currentDirectory; },
|
|
115719
|
-
getNodeCount: function () { return
|
|
115720
|
-
getIdentifierCount: function () { return
|
|
115721
|
-
getSymbolCount: function () { return
|
|
115722
|
-
getTypeCount: function () { return
|
|
115723
|
-
getInstantiationCount: function () { return
|
|
115724
|
-
getRelationCacheSizes: function () { return
|
|
115770
|
+
getNodeCount: function () { return getTypeChecker().getNodeCount(); },
|
|
115771
|
+
getIdentifierCount: function () { return getTypeChecker().getIdentifierCount(); },
|
|
115772
|
+
getSymbolCount: function () { return getTypeChecker().getSymbolCount(); },
|
|
115773
|
+
getTypeCount: function () { return getTypeChecker().getTypeCount(); },
|
|
115774
|
+
getInstantiationCount: function () { return getTypeChecker().getInstantiationCount(); },
|
|
115775
|
+
getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
|
|
115725
115776
|
getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
|
|
115726
115777
|
getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
|
|
115727
115778
|
isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
|
|
115728
115779
|
isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
|
|
115729
|
-
dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
|
|
115730
115780
|
getSourceFileFromReference: getSourceFileFromReference,
|
|
115731
115781
|
getLibFileFromReference: getLibFileFromReference,
|
|
115732
115782
|
sourceFileToPackageName: sourceFileToPackageName,
|
|
@@ -116315,14 +116365,8 @@ var ts;
|
|
|
116315
116365
|
return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); });
|
|
116316
116366
|
}
|
|
116317
116367
|
}
|
|
116318
|
-
function getDiagnosticsProducingTypeChecker() {
|
|
116319
|
-
return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true));
|
|
116320
|
-
}
|
|
116321
|
-
function dropDiagnosticsProducingTypeChecker() {
|
|
116322
|
-
diagnosticsProducingTypeChecker = undefined;
|
|
116323
|
-
}
|
|
116324
116368
|
function getTypeChecker() {
|
|
116325
|
-
return
|
|
116369
|
+
return typeChecker || (typeChecker = ts.createTypeChecker(program));
|
|
116326
116370
|
}
|
|
116327
116371
|
function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
|
|
116328
116372
|
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);
|
|
@@ -116347,7 +116391,7 @@ var ts;
|
|
|
116347
116391
|
// This is because in the -out scenario all files need to be emitted, and therefore all
|
|
116348
116392
|
// files need to be type checked. And the way to specify that all files need to be type
|
|
116349
116393
|
// checked is to not pass the file to getEmitResolver.
|
|
116350
|
-
var emitResolver =
|
|
116394
|
+
var emitResolver = getTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
|
|
116351
116395
|
ts.performance.mark("beforeEmit");
|
|
116352
116396
|
var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles,
|
|
116353
116397
|
/*onlyBuildInfo*/ false, forceDtsEmit);
|
|
@@ -116427,15 +116471,7 @@ var ts;
|
|
|
116427
116471
|
if (e instanceof ts.OperationCanceledException) {
|
|
116428
116472
|
// We were canceled while performing the operation. Because our type checker
|
|
116429
116473
|
// might be a bad state, we need to throw it away.
|
|
116430
|
-
|
|
116431
|
-
// Note: we are overly aggressive here. We do not actually *have* to throw away
|
|
116432
|
-
// the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
|
|
116433
|
-
// the lifetimes of these two TypeCheckers the same. Also, we generally only
|
|
116434
|
-
// cancel when the user has made a change anyways. And, in that case, we (the
|
|
116435
|
-
// program instance) will get thrown away anyways. So trying to keep one of
|
|
116436
|
-
// these type checkers alive doesn't serve much purpose.
|
|
116437
|
-
noDiagnosticsTypeChecker = undefined;
|
|
116438
|
-
diagnosticsProducingTypeChecker = undefined;
|
|
116474
|
+
typeChecker = undefined;
|
|
116439
116475
|
}
|
|
116440
116476
|
throw e;
|
|
116441
116477
|
}
|
|
@@ -116451,7 +116487,7 @@ var ts;
|
|
|
116451
116487
|
if (ts.skipTypeChecking(sourceFile, options, program)) {
|
|
116452
116488
|
return ts.emptyArray;
|
|
116453
116489
|
}
|
|
116454
|
-
var typeChecker =
|
|
116490
|
+
var typeChecker = getTypeChecker();
|
|
116455
116491
|
ts.Debug.assert(!!sourceFile.bindDiagnostics);
|
|
116456
116492
|
var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
|
|
116457
116493
|
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
|
|
@@ -116503,7 +116539,7 @@ var ts;
|
|
|
116503
116539
|
}
|
|
116504
116540
|
function getSuggestionDiagnostics(sourceFile, cancellationToken) {
|
|
116505
116541
|
return runWithCancellationToken(function () {
|
|
116506
|
-
return
|
|
116542
|
+
return getTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
|
|
116507
116543
|
});
|
|
116508
116544
|
}
|
|
116509
116545
|
/**
|
|
@@ -116721,7 +116757,7 @@ var ts;
|
|
|
116721
116757
|
}
|
|
116722
116758
|
function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
|
|
116723
116759
|
return runWithCancellationToken(function () {
|
|
116724
|
-
var resolver =
|
|
116760
|
+
var resolver = getTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
|
116725
116761
|
// Don't actually write any files since we're just getting diagnostics.
|
|
116726
116762
|
return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
|
|
116727
116763
|
});
|
|
@@ -116759,7 +116795,7 @@ var ts;
|
|
|
116759
116795
|
return diagnostics;
|
|
116760
116796
|
}
|
|
116761
116797
|
function getGlobalDiagnostics() {
|
|
116762
|
-
return rootNames.length ? ts.sortAndDeduplicateDiagnostics(
|
|
116798
|
+
return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
|
|
116763
116799
|
}
|
|
116764
116800
|
function getConfigFileParsingDiagnostics() {
|
|
116765
116801
|
return configFileParsingDiagnostics || ts.emptyArray;
|