typescript 4.6.0-dev.20220209 → 4.6.0-dev.20220210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +79 -52
- package/lib/tsserver.js +87 -54
- package/lib/tsserverlibrary.js +87 -54
- package/lib/typescript.js +87 -54
- package/lib/typescriptServices.js +87 -54
- package/lib/typingsInstaller.js +87 -54
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220210";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8045,10 +8045,10 @@ var ts;
|
|
|
8045
8045
|
A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."),
|
|
8046
8046
|
A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."),
|
|
8047
8047
|
An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."),
|
|
8048
|
-
|
|
8049
|
-
|
|
8048
|
+
An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1232", "An import declaration can only be used at the top level of a namespace or module."),
|
|
8049
|
+
An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1233", "An export declaration can only be used at the top level of a namespace or module."),
|
|
8050
8050
|
An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."),
|
|
8051
|
-
|
|
8051
|
+
A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module_1235", "A namespace declaration is only allowed at the top level of a namespace or module."),
|
|
8052
8052
|
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."),
|
|
8053
8053
|
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."),
|
|
8054
8054
|
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."),
|
|
@@ -8216,6 +8216,8 @@ var ts;
|
|
|
8216
8216
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8217
8217
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8218
8218
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
8219
|
+
An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."),
|
|
8220
|
+
An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."),
|
|
8219
8221
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8220
8222
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8221
8223
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
@@ -14136,6 +14138,10 @@ var ts;
|
|
|
14136
14138
|
return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
|
|
14137
14139
|
}
|
|
14138
14140
|
ts.getSourceFileOfModule = getSourceFileOfModule;
|
|
14141
|
+
function isPlainJsFile(file, checkJs) {
|
|
14142
|
+
return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined;
|
|
14143
|
+
}
|
|
14144
|
+
ts.isPlainJsFile = isPlainJsFile;
|
|
14139
14145
|
function isStatementWithLocals(node) {
|
|
14140
14146
|
switch (node.kind) {
|
|
14141
14147
|
case 234 /* Block */:
|
|
@@ -46913,6 +46919,9 @@ var ts;
|
|
|
46913
46919
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
46914
46920
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
46915
46921
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
46922
|
+
CheckMode[CheckMode["RestBindingElement"] = 32] = "RestBindingElement";
|
|
46923
|
+
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
46924
|
+
// we need to preserve generic types instead of substituting them for constraints
|
|
46916
46925
|
})(CheckMode || (CheckMode = {}));
|
|
46917
46926
|
var SignatureCheckMode;
|
|
46918
46927
|
(function (SignatureCheckMode) {
|
|
@@ -47965,13 +47974,13 @@ var ts;
|
|
|
47965
47974
|
else { // error
|
|
47966
47975
|
var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */);
|
|
47967
47976
|
var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */);
|
|
47968
|
-
var message = isEitherEnum
|
|
47969
|
-
? ts.Diagnostics.
|
|
47970
|
-
: isEitherBlockScoped_1
|
|
47971
|
-
? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
47977
|
+
var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
|
|
47978
|
+
: isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
|
47972
47979
|
: ts.Diagnostics.Duplicate_identifier_0;
|
|
47973
47980
|
var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
|
|
47974
47981
|
var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
|
|
47982
|
+
var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
|
|
47983
|
+
var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
|
|
47975
47984
|
var symbolName_1 = symbolToString(source);
|
|
47976
47985
|
// Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch
|
|
47977
47986
|
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
|
|
@@ -47983,12 +47992,16 @@ var ts;
|
|
|
47983
47992
|
var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
|
|
47984
47993
|
return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
|
|
47985
47994
|
});
|
|
47986
|
-
|
|
47987
|
-
|
|
47995
|
+
if (!isSourcePlainJs)
|
|
47996
|
+
addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
|
|
47997
|
+
if (!isTargetPlainJs)
|
|
47998
|
+
addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
|
|
47988
47999
|
}
|
|
47989
48000
|
else {
|
|
47990
|
-
|
|
47991
|
-
|
|
48001
|
+
if (!isSourcePlainJs)
|
|
48002
|
+
addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
|
|
48003
|
+
if (!isTargetPlainJs)
|
|
48004
|
+
addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
|
|
47992
48005
|
}
|
|
47993
48006
|
}
|
|
47994
48007
|
return target;
|
|
@@ -48445,6 +48458,8 @@ var ts;
|
|
|
48445
48458
|
// type parameters are visible in parameter list, return type and type parameter list
|
|
48446
48459
|
? lastLocation === location.type ||
|
|
48447
48460
|
lastLocation.kind === 163 /* Parameter */ ||
|
|
48461
|
+
lastLocation.kind === 338 /* JSDocParameterTag */ ||
|
|
48462
|
+
lastLocation.kind === 339 /* JSDocReturnTag */ ||
|
|
48448
48463
|
lastLocation.kind === 162 /* TypeParameter */
|
|
48449
48464
|
// local types not visible outside the function body
|
|
48450
48465
|
: false;
|
|
@@ -48704,9 +48719,9 @@ var ts;
|
|
|
48704
48719
|
lastSelfReferenceLocation = location;
|
|
48705
48720
|
}
|
|
48706
48721
|
lastLocation = location;
|
|
48707
|
-
location = ts.isJSDocTemplateTag(location) ?
|
|
48708
|
-
ts.
|
|
48709
|
-
|
|
48722
|
+
location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
|
|
48723
|
+
ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
|
|
48724
|
+
location.parent;
|
|
48710
48725
|
}
|
|
48711
48726
|
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
|
|
48712
48727
|
// If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself.
|
|
@@ -49840,16 +49855,20 @@ var ts;
|
|
|
49840
49855
|
return;
|
|
49841
49856
|
}
|
|
49842
49857
|
var host = ts.getJSDocHost(node);
|
|
49843
|
-
if (host &&
|
|
49844
|
-
|
|
49845
|
-
ts.isBinaryExpression(host.expression) &&
|
|
49846
|
-
ts.getAssignmentDeclarationKind(host.expression) === 3 /* PrototypeProperty */) {
|
|
49847
|
-
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49858
|
+
if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
|
|
49859
|
+
// /** @param {K} p */ X.prototype.m = function () { } <-- look for K on X's declaration
|
|
49848
49860
|
var symbol = getSymbolOfNode(host.expression.left);
|
|
49849
49861
|
if (symbol) {
|
|
49850
49862
|
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49851
49863
|
}
|
|
49852
49864
|
}
|
|
49865
|
+
if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
|
|
49866
|
+
// X.prototype.m = /** @param {K} p */ function () { } <-- look for K on X's declaration
|
|
49867
|
+
var symbol = getSymbolOfNode(host.parent.left);
|
|
49868
|
+
if (symbol) {
|
|
49869
|
+
return getDeclarationOfJSPrototypeContainer(symbol);
|
|
49870
|
+
}
|
|
49871
|
+
}
|
|
49853
49872
|
if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
|
|
49854
49873
|
ts.isBinaryExpression(host.parent.parent) &&
|
|
49855
49874
|
ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) {
|
|
@@ -54336,9 +54355,12 @@ var ts;
|
|
|
54336
54355
|
}
|
|
54337
54356
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
54338
54357
|
// assigned by contextual typing.
|
|
54339
|
-
function getTypeForBindingElementParent(node) {
|
|
54358
|
+
function getTypeForBindingElementParent(node, checkMode) {
|
|
54359
|
+
if (checkMode !== 0 /* Normal */) {
|
|
54360
|
+
return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54361
|
+
}
|
|
54340
54362
|
var symbol = getSymbolOfNode(node);
|
|
54341
|
-
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false);
|
|
54363
|
+
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode);
|
|
54342
54364
|
}
|
|
54343
54365
|
function getRestType(source, properties, symbol) {
|
|
54344
54366
|
source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
@@ -54456,7 +54478,8 @@ var ts;
|
|
|
54456
54478
|
}
|
|
54457
54479
|
/** Return the inferred type for a binding element */
|
|
54458
54480
|
function getTypeForBindingElement(declaration) {
|
|
54459
|
-
var
|
|
54481
|
+
var checkMode = declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
54482
|
+
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
54460
54483
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
54461
54484
|
}
|
|
54462
54485
|
function getBindingElementTypeFromParentType(declaration, parentType) {
|
|
@@ -54528,9 +54551,9 @@ var ts;
|
|
|
54528
54551
|
if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
|
|
54529
54552
|
// In strict null checking mode, if a default value of a non-undefined type is specified, remove
|
|
54530
54553
|
// undefined from the final type.
|
|
54531
|
-
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54554
|
+
return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type;
|
|
54532
54555
|
}
|
|
54533
|
-
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */));
|
|
54556
|
+
return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */));
|
|
54534
54557
|
}
|
|
54535
54558
|
function getTypeForDeclarationFromJSDocComment(declaration) {
|
|
54536
54559
|
var jsdocType = ts.getJSDocType(declaration);
|
|
@@ -54553,11 +54576,11 @@ var ts;
|
|
|
54553
54576
|
return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
|
|
54554
54577
|
}
|
|
54555
54578
|
// Return the inferred type for a variable, parameter, or property declaration
|
|
54556
|
-
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
|
54579
|
+
function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
|
|
54557
54580
|
// A variable declared in a for..in statement is of type string, or of type keyof T when the
|
|
54558
54581
|
// right hand expression is of a type parameter type.
|
|
54559
54582
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForInStatement */) {
|
|
54560
|
-
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
|
|
54583
|
+
var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode)));
|
|
54561
54584
|
return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType;
|
|
54562
54585
|
}
|
|
54563
54586
|
if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) {
|
|
@@ -54634,7 +54657,7 @@ var ts;
|
|
|
54634
54657
|
return containerObjectType;
|
|
54635
54658
|
}
|
|
54636
54659
|
}
|
|
54637
|
-
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
|
|
54660
|
+
var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
|
|
54638
54661
|
return addOptionality(type, isProperty, isOptional);
|
|
54639
54662
|
}
|
|
54640
54663
|
if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
|
|
@@ -55006,7 +55029,7 @@ var ts;
|
|
|
55006
55029
|
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
|
55007
55030
|
// pattern.
|
|
55008
55031
|
var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
|
55009
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
|
|
55032
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
55010
55033
|
}
|
|
55011
55034
|
if (ts.isBindingPattern(element.name)) {
|
|
55012
55035
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
|
@@ -55095,7 +55118,7 @@ var ts;
|
|
|
55095
55118
|
// binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the
|
|
55096
55119
|
// tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string.
|
|
55097
55120
|
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
|
55098
|
-
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors);
|
|
55121
|
+
return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors);
|
|
55099
55122
|
}
|
|
55100
55123
|
function isGlobalSymbolConstructor(node) {
|
|
55101
55124
|
var symbol = getSymbolOfNode(node);
|
|
@@ -55324,10 +55347,12 @@ var ts;
|
|
|
55324
55347
|
if (writing === void 0) { writing = false; }
|
|
55325
55348
|
var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */);
|
|
55326
55349
|
var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */);
|
|
55327
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55328
55350
|
// For write operations, prioritize type annotations on the setter
|
|
55329
|
-
if (writing
|
|
55330
|
-
|
|
55351
|
+
if (writing) {
|
|
55352
|
+
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55353
|
+
if (setterType_1) {
|
|
55354
|
+
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55355
|
+
}
|
|
55331
55356
|
}
|
|
55332
55357
|
// Else defer to the getter type
|
|
55333
55358
|
if (getter && ts.isInJSFile(getter)) {
|
|
@@ -55342,6 +55367,7 @@ var ts;
|
|
|
55342
55367
|
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55343
55368
|
}
|
|
55344
55369
|
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55370
|
+
var setterType = getAnnotatedAccessorType(setter);
|
|
55345
55371
|
if (setterType) {
|
|
55346
55372
|
return setterType;
|
|
55347
55373
|
}
|
|
@@ -69899,12 +69925,16 @@ var ts;
|
|
|
69899
69925
|
function isGenericTypeWithoutNullableConstraint(type) {
|
|
69900
69926
|
return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */));
|
|
69901
69927
|
}
|
|
69902
|
-
function
|
|
69928
|
+
function hasContextualTypeWithNoGenericTypes(node, checkMode) {
|
|
69903
69929
|
// Computing the contextual type for a child of a JSX element involves resolving the type of the
|
|
69904
69930
|
// element's tag name, so we exclude that here to avoid circularities.
|
|
69931
|
+
// If check mode has `CheckMode.RestBindingElement`, we skip binding pattern contextual types,
|
|
69932
|
+
// as we want the type of a rest element to be generic when possible.
|
|
69905
69933
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
69906
69934
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
69907
|
-
|
|
69935
|
+
(checkMode && checkMode & 32 /* RestBindingElement */ ?
|
|
69936
|
+
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
69937
|
+
: getContextualType(node));
|
|
69908
69938
|
return contextualType && !isGenericType(contextualType);
|
|
69909
69939
|
}
|
|
69910
69940
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -69917,7 +69947,7 @@ var ts;
|
|
|
69917
69947
|
// 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'.
|
|
69918
69948
|
var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
|
|
69919
69949
|
someType(type, isGenericTypeWithUnionConstraint) &&
|
|
69920
|
-
(isConstraintPosition(type, reference) ||
|
|
69950
|
+
(isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
69921
69951
|
return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
|
|
69922
69952
|
}
|
|
69923
69953
|
function isExportOrExportExpression(location) {
|
|
@@ -69985,7 +70015,7 @@ var ts;
|
|
|
69985
70015
|
var links = getNodeLinks(location);
|
|
69986
70016
|
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69987
70017
|
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69988
|
-
var parentType = getTypeForBindingElementParent(parent);
|
|
70018
|
+
var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
|
|
69989
70019
|
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69990
70020
|
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69991
70021
|
var pattern = declaration.parent;
|
|
@@ -70838,7 +70868,7 @@ var ts;
|
|
|
70838
70868
|
var parent = declaration.parent.parent;
|
|
70839
70869
|
var name = declaration.propertyName || declaration.name;
|
|
70840
70870
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
70841
|
-
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent);
|
|
70871
|
+
parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */);
|
|
70842
70872
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
70843
70873
|
return undefined;
|
|
70844
70874
|
if (parent.name.kind === 201 /* ArrayBindingPattern */) {
|
|
@@ -76004,7 +76034,7 @@ var ts;
|
|
|
76004
76034
|
var links = getSymbolLinks(parameter);
|
|
76005
76035
|
if (!links.type) {
|
|
76006
76036
|
var declaration = parameter.valueDeclaration;
|
|
76007
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*
|
|
76037
|
+
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
|
76008
76038
|
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
76009
76039
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
76010
76040
|
if (links.type === unknownType) {
|
|
@@ -77735,11 +77765,11 @@ var ts;
|
|
|
77735
77765
|
}
|
|
77736
77766
|
}
|
|
77737
77767
|
function checkExpressionCached(node, checkMode) {
|
|
77768
|
+
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77769
|
+
return checkExpression(node, checkMode);
|
|
77770
|
+
}
|
|
77738
77771
|
var links = getNodeLinks(node);
|
|
77739
77772
|
if (!links.resolvedType) {
|
|
77740
|
-
if (checkMode && checkMode !== 0 /* Normal */) {
|
|
77741
|
-
return checkExpression(node, checkMode);
|
|
77742
|
-
}
|
|
77743
77773
|
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
|
|
77744
77774
|
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
|
|
77745
77775
|
// to the top of the stack ensures all transient types are computed from a known point.
|
|
@@ -77759,10 +77789,12 @@ var ts;
|
|
|
77759
77789
|
node.kind === 228 /* AsExpression */ ||
|
|
77760
77790
|
ts.isJSDocTypeAssertion(node);
|
|
77761
77791
|
}
|
|
77762
|
-
function checkDeclarationInitializer(declaration, contextualType) {
|
|
77792
|
+
function checkDeclarationInitializer(declaration, checkMode, contextualType) {
|
|
77763
77793
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
77764
77794
|
var type = getQuickTypeOfExpression(initializer) ||
|
|
77765
|
-
(contextualType ?
|
|
77795
|
+
(contextualType ?
|
|
77796
|
+
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */)
|
|
77797
|
+
: checkExpressionCached(initializer, checkMode));
|
|
77766
77798
|
return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ &&
|
|
77767
77799
|
isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
|
77768
77800
|
padTupleType(type, declaration.name) : type;
|
|
@@ -80699,7 +80731,8 @@ var ts;
|
|
|
80699
80731
|
}
|
|
80700
80732
|
// check private/protected variable access
|
|
80701
80733
|
var parent = node.parent.parent;
|
|
80702
|
-
var
|
|
80734
|
+
var parentCheckMode = node.dotDotDotToken ? 32 /* RestBindingElement */ : 0 /* Normal */;
|
|
80735
|
+
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
80703
80736
|
var name = node.propertyName || node.name;
|
|
80704
80737
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
80705
80738
|
var exprType = getLiteralTypeFromPropertyName(name);
|
|
@@ -81938,7 +81971,7 @@ var ts;
|
|
|
81938
81971
|
var declaration = catchClause.variableDeclaration;
|
|
81939
81972
|
var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
|
|
81940
81973
|
if (typeNode) {
|
|
81941
|
-
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false);
|
|
81974
|
+
var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */);
|
|
81942
81975
|
if (type && !(type.flags & 3 /* AnyOrUnknown */)) {
|
|
81943
81976
|
grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
|
|
81944
81977
|
}
|
|
@@ -83044,7 +83077,7 @@ var ts;
|
|
|
83044
83077
|
var isAmbientExternalModule = ts.isAmbientModule(node);
|
|
83045
83078
|
var contextErrorMessage = isAmbientExternalModule
|
|
83046
83079
|
? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
|
|
83047
|
-
: ts.Diagnostics.
|
|
83080
|
+
: ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
|
|
83048
83081
|
if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
|
|
83049
83082
|
// If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83050
83083
|
return;
|
|
@@ -83360,7 +83393,7 @@ var ts;
|
|
|
83360
83393
|
}
|
|
83361
83394
|
}
|
|
83362
83395
|
function checkImportDeclaration(node) {
|
|
83363
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83396
|
+
if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83364
83397
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83365
83398
|
return;
|
|
83366
83399
|
}
|
|
@@ -83393,7 +83426,7 @@ var ts;
|
|
|
83393
83426
|
checkAssertClause(node);
|
|
83394
83427
|
}
|
|
83395
83428
|
function checkImportEqualsDeclaration(node) {
|
|
83396
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83429
|
+
if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83397
83430
|
// If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
|
|
83398
83431
|
return;
|
|
83399
83432
|
}
|
|
@@ -83430,7 +83463,7 @@ var ts;
|
|
|
83430
83463
|
}
|
|
83431
83464
|
}
|
|
83432
83465
|
function checkExportDeclaration(node) {
|
|
83433
|
-
if (checkGrammarModuleElementContext(node, ts.Diagnostics.
|
|
83466
|
+
if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83434
83467
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
83435
83468
|
return;
|
|
83436
83469
|
}
|
|
@@ -84664,7 +84697,7 @@ var ts;
|
|
|
84664
84697
|
return errorType;
|
|
84665
84698
|
}
|
|
84666
84699
|
if (ts.isBindingPattern(node)) {
|
|
84667
|
-
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true) || errorType;
|
|
84700
|
+
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType;
|
|
84668
84701
|
}
|
|
84669
84702
|
if (isInRightSideOfImportOrExportAssignment(node)) {
|
|
84670
84703
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -114411,9 +114444,9 @@ var ts;
|
|
|
114411
114444
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
114412
114445
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
114413
114446
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
114414
|
-
ts.Diagnostics.
|
|
114447
|
+
ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114415
114448
|
ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
|
|
114416
|
-
ts.Diagnostics.
|
|
114449
|
+
ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
|
|
114417
114450
|
ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
|
|
114418
114451
|
ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
|
|
114419
114452
|
ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
|
|
@@ -115481,7 +115514,7 @@ var ts;
|
|
|
115481
115514
|
ts.Debug.assert(!!sourceFile.bindDiagnostics);
|
|
115482
115515
|
var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */;
|
|
115483
115516
|
var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
|
|
115484
|
-
var isPlainJs =
|
|
115517
|
+
var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
|
|
115485
115518
|
var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
|
|
115486
115519
|
// By default, only type-check .ts, .tsx, Deferred, plain JS, checked JS and External
|
|
115487
115520
|
// - plain JS: .js files with no // ts-check and checkJs: undefined
|