typescript 4.9.0-dev.20220918 → 4.9.0-dev.20220920
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cs/diagnosticMessages.generated.json +5 -0
- package/lib/de/diagnosticMessages.generated.json +5 -0
- package/lib/es/diagnosticMessages.generated.json +5 -0
- package/lib/fr/diagnosticMessages.generated.json +5 -0
- package/lib/it/diagnosticMessages.generated.json +5 -0
- package/lib/ja/diagnosticMessages.generated.json +5 -0
- package/lib/ko/diagnosticMessages.generated.json +5 -0
- package/lib/pl/diagnosticMessages.generated.json +5 -0
- package/lib/pt-br/diagnosticMessages.generated.json +5 -0
- package/lib/ru/diagnosticMessages.generated.json +5 -0
- package/lib/tr/diagnosticMessages.generated.json +5 -0
- package/lib/tsc.js +84 -55
- package/lib/tsserver.js +120 -91
- package/lib/tsserverlibrary.js +120 -91
- package/lib/typescript.js +119 -89
- package/lib/typescriptServices.js +119 -89
- package/lib/typingsInstaller.js +113 -76
- package/lib/zh-cn/diagnosticMessages.generated.json +5 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +5 -0
- package/package.json +1 -1
|
@@ -99,7 +99,7 @@ var ts;
|
|
|
99
99
|
// The following is baselined as a literal template type without intervention
|
|
100
100
|
/** The version of the TypeScript compiler release */
|
|
101
101
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
102
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
102
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220920");
|
|
103
103
|
/* @internal */
|
|
104
104
|
var Comparison;
|
|
105
105
|
(function (Comparison) {
|
|
@@ -2683,7 +2683,7 @@ var ts;
|
|
|
2683
2683
|
if (typeof func !== "function") {
|
|
2684
2684
|
return "";
|
|
2685
2685
|
}
|
|
2686
|
-
else if (
|
|
2686
|
+
else if (ts.hasProperty(func, "name")) {
|
|
2687
2687
|
return func.name;
|
|
2688
2688
|
}
|
|
2689
2689
|
else {
|
|
@@ -3008,7 +3008,7 @@ var ts;
|
|
|
3008
3008
|
];
|
|
3009
3009
|
for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
|
|
3010
3010
|
var ctor = nodeConstructors_1[_i];
|
|
3011
|
-
if (!
|
|
3011
|
+
if (!ts.hasProperty(ctor, "__debugKind")) {
|
|
3012
3012
|
Object.defineProperties(ctor.prototype, {
|
|
3013
3013
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
3014
3014
|
__tsDebuggerDisplay: {
|
|
@@ -3863,7 +3863,6 @@ var ts;
|
|
|
3863
3863
|
var typeCatalog = []; // NB: id is index + 1
|
|
3864
3864
|
var legendPath;
|
|
3865
3865
|
var legend = [];
|
|
3866
|
-
;
|
|
3867
3866
|
/** Starts tracing for the given project. */
|
|
3868
3867
|
function startTracing(tracingMode, traceDir, configFilePath) {
|
|
3869
3868
|
ts.Debug.assert(!ts.tracing, "Tracing already started");
|
|
@@ -8695,8 +8694,6 @@ var ts;
|
|
|
8695
8694
|
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
|
|
8696
8695
|
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
|
|
8697
8696
|
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
|
|
8698
|
-
The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or__2360", "The left-hand side of an 'in' expression must be a private identifier or of type 'any', 'string', 'number', or 'symbol'."),
|
|
8699
|
-
The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."),
|
|
8700
8697
|
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
|
8701
8698
|
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
|
8702
8699
|
The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."),
|
|
@@ -8945,6 +8942,7 @@ var ts;
|
|
|
8945
8942
|
Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
|
|
8946
8943
|
Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation: diag(2636, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation_2636", "Type '{0}' is not assignable to type '{1}' as implied by variance annotation."),
|
|
8947
8944
|
Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types: diag(2637, ts.DiagnosticCategory.Error, "Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_t_2637", "Variance annotations are only supported in type aliases for object, function, constructor, and mapped types."),
|
|
8945
|
+
Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator: diag(2638, ts.DiagnosticCategory.Error, "Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operato_2638", "Type '{0}' may represent a primitive value, which is not permitted as the right operand of the 'in' operator."),
|
|
8948
8946
|
Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
|
|
8949
8947
|
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
|
|
8950
8948
|
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
|
|
@@ -10328,7 +10326,7 @@ var ts;
|
|
|
10328
10326
|
ts.stringToToken = stringToToken;
|
|
10329
10327
|
/* @internal */
|
|
10330
10328
|
function computeLineStarts(text) {
|
|
10331
|
-
var result =
|
|
10329
|
+
var result = [];
|
|
10332
10330
|
var pos = 0;
|
|
10333
10331
|
var lineStart = 0;
|
|
10334
10332
|
while (pos < text.length) {
|
|
@@ -13461,7 +13459,7 @@ var ts;
|
|
|
13461
13459
|
// Node Arrays
|
|
13462
13460
|
/* @internal */
|
|
13463
13461
|
function isNodeArray(array) {
|
|
13464
|
-
return
|
|
13462
|
+
return ts.hasProperty(array, "pos") && ts.hasProperty(array, "end");
|
|
13465
13463
|
}
|
|
13466
13464
|
ts.isNodeArray = isNodeArray;
|
|
13467
13465
|
// Literals
|
|
@@ -14933,7 +14931,6 @@ var ts;
|
|
|
14933
14931
|
return emitNode && emitNode.flags || 0;
|
|
14934
14932
|
}
|
|
14935
14933
|
ts.getEmitFlags = getEmitFlags;
|
|
14936
|
-
;
|
|
14937
14934
|
function getScriptTargetFeatures() {
|
|
14938
14935
|
return {
|
|
14939
14936
|
es2015: {
|
|
@@ -19659,7 +19656,7 @@ var ts;
|
|
|
19659
19656
|
}
|
|
19660
19657
|
function isWatchSet(options) {
|
|
19661
19658
|
// Firefox has Object.prototype.watch
|
|
19662
|
-
return options.watch &&
|
|
19659
|
+
return options.watch && ts.hasProperty(options, "watch");
|
|
19663
19660
|
}
|
|
19664
19661
|
ts.isWatchSet = isWatchSet;
|
|
19665
19662
|
function closeFileWatcher(watcher) {
|
|
@@ -26944,7 +26941,7 @@ var ts;
|
|
|
26944
26941
|
clone.transformFlags = node.transformFlags;
|
|
26945
26942
|
setOriginalNode(clone, node);
|
|
26946
26943
|
for (var key in node) {
|
|
26947
|
-
if (
|
|
26944
|
+
if (ts.hasProperty(clone, key) || !ts.hasProperty(node, key)) {
|
|
26948
26945
|
continue;
|
|
26949
26946
|
}
|
|
26950
26947
|
clone[key] = node[key];
|
|
@@ -31832,7 +31829,6 @@ var ts;
|
|
|
31832
31829
|
visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
31833
31830
|
visitNode(cbNode, node.type);
|
|
31834
31831
|
}
|
|
31835
|
-
;
|
|
31836
31832
|
function forEachChildInUnionOrIntersectionType(node, cbNode, cbNodes) {
|
|
31837
31833
|
return visitNodes(cbNode, cbNodes, node.types);
|
|
31838
31834
|
}
|
|
@@ -43148,7 +43144,7 @@ var ts;
|
|
|
43148
43144
|
function convertCompilerOptionsForTelemetry(opts) {
|
|
43149
43145
|
var out = {};
|
|
43150
43146
|
for (var key in opts) {
|
|
43151
|
-
if (
|
|
43147
|
+
if (ts.hasProperty(opts, key)) {
|
|
43152
43148
|
var type = getOptionFromName(key);
|
|
43153
43149
|
if (type !== undefined) { // Ignore unknown options
|
|
43154
43150
|
out[key] = getOptionValueWithEmptyStrings(opts[key], type);
|
|
@@ -49532,6 +49528,7 @@ var ts;
|
|
|
49532
49528
|
isPropertyAccessible: isPropertyAccessible,
|
|
49533
49529
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
49534
49530
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
49531
|
+
isTypeParameterPossiblyReferenced: isTypeParameterPossiblyReferenced,
|
|
49535
49532
|
};
|
|
49536
49533
|
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
49537
49534
|
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
@@ -49651,7 +49648,8 @@ var ts;
|
|
|
49651
49648
|
var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
|
|
49652
49649
|
emptyTypeLiteralSymbol.members = ts.createSymbolTable();
|
|
49653
49650
|
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49654
|
-
var
|
|
49651
|
+
var unknownEmptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49652
|
+
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
|
|
49655
49653
|
var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49656
49654
|
emptyGenericType.instantiations = new ts.Map();
|
|
49657
49655
|
var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
@@ -49765,6 +49763,7 @@ var ts;
|
|
|
49765
49763
|
var deferredGlobalOmitSymbol;
|
|
49766
49764
|
var deferredGlobalAwaitedSymbol;
|
|
49767
49765
|
var deferredGlobalBigIntType;
|
|
49766
|
+
var deferredGlobalRecordSymbol;
|
|
49768
49767
|
var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
|
|
49769
49768
|
var flowLoopStart = 0;
|
|
49770
49769
|
var flowLoopCount = 0;
|
|
@@ -50560,12 +50559,13 @@ var ts;
|
|
|
50560
50559
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
50561
50560
|
* the given name can be found.
|
|
50562
50561
|
*
|
|
50562
|
+
* @param nameNotFoundMessage If defined, we will report errors found during resolve.
|
|
50563
50563
|
* @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
|
|
50564
50564
|
*/
|
|
50565
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals,
|
|
50565
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions) {
|
|
50566
50566
|
if (excludeGlobals === void 0) { excludeGlobals = false; }
|
|
50567
|
-
if (
|
|
50568
|
-
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals,
|
|
50567
|
+
if (getSpellingSuggestions === void 0) { getSpellingSuggestions = true; }
|
|
50568
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol);
|
|
50569
50569
|
}
|
|
50570
50570
|
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
50571
50571
|
var _a, _b, _c;
|
|
@@ -50723,7 +50723,9 @@ var ts;
|
|
|
50723
50723
|
// TypeScript 1.0 spec (April 2014): 3.4.1
|
|
50724
50724
|
// The scope of a type parameter extends over the entire declaration with which the type
|
|
50725
50725
|
// parameter list is associated, with the exception of static member declarations in classes.
|
|
50726
|
-
|
|
50726
|
+
if (nameNotFoundMessage) {
|
|
50727
|
+
error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
|
|
50728
|
+
}
|
|
50727
50729
|
return undefined;
|
|
50728
50730
|
}
|
|
50729
50731
|
break loop;
|
|
@@ -50761,7 +50763,9 @@ var ts;
|
|
|
50761
50763
|
if (ts.isClassLike(grandparent) || grandparent.kind === 261 /* SyntaxKind.InterfaceDeclaration */) {
|
|
50762
50764
|
// A reference to this grandparent's type parameters would be an error
|
|
50763
50765
|
if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) {
|
|
50764
|
-
|
|
50766
|
+
if (nameNotFoundMessage) {
|
|
50767
|
+
error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
|
|
50768
|
+
}
|
|
50765
50769
|
return undefined;
|
|
50766
50770
|
}
|
|
50767
50771
|
}
|
|
@@ -50957,7 +50961,7 @@ var ts;
|
|
|
50957
50961
|
}
|
|
50958
50962
|
return undefined;
|
|
50959
50963
|
}
|
|
50960
|
-
else if (checkAndReportErrorForInvalidInitializer()) {
|
|
50964
|
+
else if (nameNotFoundMessage && checkAndReportErrorForInvalidInitializer()) {
|
|
50961
50965
|
return undefined;
|
|
50962
50966
|
}
|
|
50963
50967
|
// Perform extra checks only if error reporting was requested
|
|
@@ -57118,7 +57122,6 @@ var ts;
|
|
|
57118
57122
|
return container;
|
|
57119
57123
|
}
|
|
57120
57124
|
}
|
|
57121
|
-
;
|
|
57122
57125
|
}
|
|
57123
57126
|
/** Create a synthetic property access flow node after the last statement of the file */
|
|
57124
57127
|
function getFlowTypeFromCommonJSExport(symbol) {
|
|
@@ -61864,6 +61867,10 @@ var ts;
|
|
|
61864
61867
|
function getGlobalBigIntType() {
|
|
61865
61868
|
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
61866
61869
|
}
|
|
61870
|
+
function getGlobalRecordSymbol() {
|
|
61871
|
+
deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
|
|
61872
|
+
return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
|
|
61873
|
+
}
|
|
61867
61874
|
/**
|
|
61868
61875
|
* Instantiates a global type that is generic with some element type, and returns that instantiation.
|
|
61869
61876
|
*/
|
|
@@ -64589,9 +64596,10 @@ var ts;
|
|
|
64589
64596
|
node.parent.kind === 202 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier);
|
|
64590
64597
|
}
|
|
64591
64598
|
function isTypeParameterPossiblyReferenced(tp, node) {
|
|
64592
|
-
// If the type parameter doesn't have exactly one declaration, if there are
|
|
64599
|
+
// If the type parameter doesn't have exactly one declaration, if there are intervening statement blocks
|
|
64593
64600
|
// between the node and the type parameter declaration, if the node contains actual references to the
|
|
64594
|
-
// type parameter, or if the node contains type queries
|
|
64601
|
+
// type parameter, or if the node contains type queries that we can't prove couldn't contain references to the type parameter,
|
|
64602
|
+
// we consider the type parameter possibly referenced.
|
|
64595
64603
|
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
|
|
64596
64604
|
var container = tp.symbol.declarations[0].parent;
|
|
64597
64605
|
for (var n = node; n !== container; n = n.parent) {
|
|
@@ -64610,6 +64618,27 @@ var ts;
|
|
|
64610
64618
|
return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
|
|
64611
64619
|
getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality
|
|
64612
64620
|
case 183 /* SyntaxKind.TypeQuery */:
|
|
64621
|
+
var entityName = node.exprName;
|
|
64622
|
+
var firstIdentifier = ts.getFirstIdentifier(entityName);
|
|
64623
|
+
var firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
|
|
64624
|
+
var tpDeclaration = tp.symbol.declarations[0]; // There is exactly one declaration, otherwise `containsReference` is not called
|
|
64625
|
+
var tpScope_1;
|
|
64626
|
+
if (tpDeclaration.kind === 165 /* SyntaxKind.TypeParameter */) { // Type parameter is a regular type parameter, e.g. foo<T>
|
|
64627
|
+
tpScope_1 = tpDeclaration.parent;
|
|
64628
|
+
}
|
|
64629
|
+
else if (tp.isThisType) {
|
|
64630
|
+
// Type parameter is the this type, and its declaration is the class declaration.
|
|
64631
|
+
tpScope_1 = tpDeclaration;
|
|
64632
|
+
}
|
|
64633
|
+
else {
|
|
64634
|
+
// Type parameter's declaration was unrecognized.
|
|
64635
|
+
// This could happen if the type parameter comes from e.g. a JSDoc annotation, so we default to returning true.
|
|
64636
|
+
return true;
|
|
64637
|
+
}
|
|
64638
|
+
if (firstIdentifierSymbol.declarations) {
|
|
64639
|
+
return ts.some(firstIdentifierSymbol.declarations, function (idDecl) { return ts.isNodeDescendantOf(idDecl, tpScope_1); }) ||
|
|
64640
|
+
ts.some(node.typeArguments, containsReference);
|
|
64641
|
+
}
|
|
64613
64642
|
return true;
|
|
64614
64643
|
case 171 /* SyntaxKind.MethodDeclaration */:
|
|
64615
64644
|
case 170 /* SyntaxKind.MethodSignature */:
|
|
@@ -72158,18 +72187,26 @@ var ts;
|
|
|
72158
72187
|
}
|
|
72159
72188
|
function isTypePresencePossible(type, propName, assumeTrue) {
|
|
72160
72189
|
var prop = getPropertyOfType(type, propName);
|
|
72161
|
-
|
|
72162
|
-
|
|
72163
|
-
|
|
72164
|
-
|
|
72165
|
-
|
|
72166
|
-
|
|
72167
|
-
|
|
72168
|
-
|
|
72169
|
-
|
|
72170
|
-
|
|
72190
|
+
return prop ?
|
|
72191
|
+
!!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
|
|
72192
|
+
!!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
|
|
72193
|
+
}
|
|
72194
|
+
function narrowByInKeyword(type, nameType, assumeTrue) {
|
|
72195
|
+
var name = getPropertyNameFromType(nameType);
|
|
72196
|
+
var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
|
|
72197
|
+
if (isKnownProperty) {
|
|
72198
|
+
// If the check is for a known property (i.e. a property declared in some constituent of
|
|
72199
|
+
// the target type), we filter the target type by presence of absence of the property.
|
|
72171
72200
|
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
|
|
72172
72201
|
}
|
|
72202
|
+
if (assumeTrue) {
|
|
72203
|
+
// If the check is for an unknown property, we intersect the target type with `Record<X, unknown>`,
|
|
72204
|
+
// where X is the name of the property.
|
|
72205
|
+
var recordSymbol = getGlobalRecordSymbol();
|
|
72206
|
+
if (recordSymbol) {
|
|
72207
|
+
return getIntersectionType([type, getTypeAliasInstantiation(recordSymbol, [nameType, unknownType])]);
|
|
72208
|
+
}
|
|
72209
|
+
}
|
|
72173
72210
|
return type;
|
|
72174
72211
|
}
|
|
72175
72212
|
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
|
|
@@ -72228,15 +72265,14 @@ var ts;
|
|
|
72228
72265
|
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
72229
72266
|
}
|
|
72230
72267
|
var target = getReferenceCandidate(expr.right);
|
|
72231
|
-
var leftType =
|
|
72232
|
-
if (leftType.flags &
|
|
72233
|
-
var name = ts.escapeLeadingUnderscores(leftType.value);
|
|
72268
|
+
var leftType = getTypeOfExpression(expr.left);
|
|
72269
|
+
if (leftType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */) {
|
|
72234
72270
|
if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) &&
|
|
72235
|
-
getAccessedPropertyName(reference) ===
|
|
72271
|
+
getAccessedPropertyName(reference) === getPropertyNameFromType(leftType)) {
|
|
72236
72272
|
return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
|
|
72237
72273
|
}
|
|
72238
72274
|
if (isMatchingReference(reference, target)) {
|
|
72239
|
-
return narrowByInKeyword(type,
|
|
72275
|
+
return narrowByInKeyword(type, leftType, assumeTrue);
|
|
72240
72276
|
}
|
|
72241
72277
|
}
|
|
72242
72278
|
break;
|
|
@@ -76406,7 +76442,6 @@ var ts;
|
|
|
76406
76442
|
}
|
|
76407
76443
|
return false;
|
|
76408
76444
|
}
|
|
76409
|
-
;
|
|
76410
76445
|
var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
|
|
76411
76446
|
if (!hasProp(suggestedMethod)) {
|
|
76412
76447
|
return undefined;
|
|
@@ -79977,6 +80012,9 @@ var ts;
|
|
|
79977
80012
|
}
|
|
79978
80013
|
return booleanType;
|
|
79979
80014
|
}
|
|
80015
|
+
function hasEmptyObjectIntersection(type) {
|
|
80016
|
+
return someType(type, function (t) { return t === unknownEmptyObjectType || !!(t.flags & 2097152 /* TypeFlags.Intersection */) && ts.some(t.types, isEmptyAnonymousObjectType); });
|
|
80017
|
+
}
|
|
79980
80018
|
function checkInExpression(left, right, leftType, rightType) {
|
|
79981
80019
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
79982
80020
|
return silentNeverType;
|
|
@@ -79993,40 +80031,20 @@ var ts;
|
|
|
79993
80031
|
}
|
|
79994
80032
|
}
|
|
79995
80033
|
else {
|
|
79996
|
-
|
|
79997
|
-
|
|
79998
|
-
|
|
79999
|
-
|
|
80000
|
-
|
|
80001
|
-
|
|
80034
|
+
// The type of the lef operand must be assignable to string, number, or symbol.
|
|
80035
|
+
checkTypeAssignableTo(checkNonNullType(leftType, left), stringNumberSymbolType, left);
|
|
80036
|
+
}
|
|
80037
|
+
// The type of the right operand must be assignable to 'object'.
|
|
80038
|
+
if (checkTypeAssignableTo(checkNonNullType(rightType, right), nonPrimitiveType, right)) {
|
|
80039
|
+
// The {} type is assignable to the object type, yet {} might represent a primitive type. Here we
|
|
80040
|
+
// detect and error on {} that results from narrowing the unknown type, as well as intersections
|
|
80041
|
+
// that include {} (we know that the other types in such intersections are assignable to object
|
|
80042
|
+
// since we already checked for that).
|
|
80043
|
+
if (hasEmptyObjectIntersection(rightType)) {
|
|
80044
|
+
error(right, ts.Diagnostics.Type_0_may_represent_a_primitive_value_which_is_not_permitted_as_the_right_operand_of_the_in_operator, typeToString(rightType));
|
|
80002
80045
|
}
|
|
80003
80046
|
}
|
|
80004
|
-
rightType = checkNonNullType(rightType, right);
|
|
80005
|
-
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
80006
|
-
// The in operator requires the right operand to be
|
|
80007
|
-
//
|
|
80008
|
-
// 1. assignable to the non-primitive type,
|
|
80009
|
-
// 2. an unconstrained type parameter,
|
|
80010
|
-
// 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the
|
|
80011
|
-
// the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the
|
|
80012
|
-
// non-primitive type, or
|
|
80013
|
-
// 4. a type parameter whose constraint is
|
|
80014
|
-
// i. an object type,
|
|
80015
|
-
// ii. the non-primitive type, or
|
|
80016
|
-
// iii. a union or intersection with at least one constituent assignable to an object or non-primitive type.
|
|
80017
|
-
//
|
|
80018
|
-
// The divergent behavior for type parameters and unions containing type parameters is a workaround for type
|
|
80019
|
-
// parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance
|
|
80020
|
-
// it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error
|
|
80021
|
-
// unless *all* instantiations would result in an error.
|
|
80022
|
-
//
|
|
80023
80047
|
// The result is always of the Boolean primitive type.
|
|
80024
|
-
var rightTypeConstraint = getConstraintOfType(rightType);
|
|
80025
|
-
if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
|
|
80026
|
-
rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
|
|
80027
|
-
!maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) {
|
|
80028
|
-
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive);
|
|
80029
|
-
}
|
|
80030
80048
|
return booleanType;
|
|
80031
80049
|
}
|
|
80032
80050
|
function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
|
|
@@ -88468,7 +88486,7 @@ var ts;
|
|
|
88468
88486
|
}
|
|
88469
88487
|
var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
|
|
88470
88488
|
if (node) {
|
|
88471
|
-
var symbol =
|
|
88489
|
+
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88472
88490
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88473
88491
|
// declaration for the symbol
|
|
88474
88492
|
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
@@ -88835,6 +88853,25 @@ var ts;
|
|
|
88835
88853
|
}
|
|
88836
88854
|
return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
|
88837
88855
|
}
|
|
88856
|
+
/**
|
|
88857
|
+
* Get either a value-meaning symbol or an alias symbol.
|
|
88858
|
+
* Unlike `getReferencedValueSymbol`, if the cached resolved symbol is the unknown symbol,
|
|
88859
|
+
* we call `resolveName` to find a symbol.
|
|
88860
|
+
* This is because when caching the resolved symbol, we only consider value symbols, but here
|
|
88861
|
+
* we want to also get an alias symbol if one exists.
|
|
88862
|
+
*/
|
|
88863
|
+
function getReferencedValueOrAliasSymbol(reference) {
|
|
88864
|
+
var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
|
|
88865
|
+
if (resolvedSymbol && resolvedSymbol !== unknownSymbol) {
|
|
88866
|
+
return resolvedSymbol;
|
|
88867
|
+
}
|
|
88868
|
+
return resolveName(reference, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */,
|
|
88869
|
+
/*nodeNotFoundMessage*/ undefined,
|
|
88870
|
+
/*nameArg*/ undefined,
|
|
88871
|
+
/*isUse*/ true,
|
|
88872
|
+
/*excludeGlobals*/ undefined,
|
|
88873
|
+
/*getSpellingSuggestions*/ undefined);
|
|
88874
|
+
}
|
|
88838
88875
|
function getReferencedValueDeclaration(referenceIn) {
|
|
88839
88876
|
if (!ts.isGeneratedIdentifier(referenceIn)) {
|
|
88840
88877
|
var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
|
|
@@ -95284,9 +95321,10 @@ var ts;
|
|
|
95284
95321
|
return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
|
|
95285
95322
|
}
|
|
95286
95323
|
function shouldEmitAliasDeclaration(node) {
|
|
95287
|
-
return
|
|
95288
|
-
|
|
95289
|
-
|
|
95324
|
+
return ts.isInJSFile(node) ||
|
|
95325
|
+
(compilerOptions.preserveValueImports
|
|
95326
|
+
? resolver.isValueAliasDeclaration(node)
|
|
95327
|
+
: resolver.isReferencedAliasDeclaration(node));
|
|
95290
95328
|
}
|
|
95291
95329
|
}
|
|
95292
95330
|
ts.transformTypeScript = transformTypeScript;
|
|
@@ -110458,7 +110496,7 @@ var ts;
|
|
|
110458
110496
|
var _a;
|
|
110459
110497
|
var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
|
|
110460
110498
|
var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
|
|
110461
|
-
if (augmentingDeclarations) {
|
|
110499
|
+
if (primaryDeclaration && augmentingDeclarations) {
|
|
110462
110500
|
for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
|
|
110463
110501
|
var augmentations = augmentingDeclarations_1[_i];
|
|
110464
110502
|
context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file)));
|
|
@@ -118507,7 +118545,6 @@ var ts;
|
|
|
118507
118545
|
return resolutions;
|
|
118508
118546
|
}
|
|
118509
118547
|
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
118510
|
-
;
|
|
118511
118548
|
/**
|
|
118512
118549
|
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
|
118513
118550
|
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
|
@@ -135003,7 +135040,7 @@ var ts;
|
|
|
135003
135040
|
if (!dependencies)
|
|
135004
135041
|
continue;
|
|
135005
135042
|
for (var dep in dependencies) {
|
|
135006
|
-
if (
|
|
135043
|
+
if (ts.hasProperty(dependencies, dep) && !ts.startsWith(dep, "@types/")) {
|
|
135007
135044
|
result.push(dep);
|
|
135008
135045
|
}
|
|
135009
135046
|
}
|
|
@@ -135856,7 +135893,6 @@ var ts;
|
|
|
135856
135893
|
var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) };
|
|
135857
135894
|
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
|
|
135858
135895
|
}
|
|
135859
|
-
;
|
|
135860
135896
|
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
|
|
135861
135897
|
var declarations = symbol.getDeclarations();
|
|
135862
135898
|
if (!(declarations && declarations.length)) {
|
|
@@ -138560,7 +138596,6 @@ var ts;
|
|
|
138560
138596
|
function isArrowFunctionBody(node) {
|
|
138561
138597
|
return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node;
|
|
138562
138598
|
}
|
|
138563
|
-
;
|
|
138564
138599
|
/** True if symbol is a type or a module containing at least one type. */
|
|
138565
138600
|
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
|
|
138566
138601
|
if (seenModules === void 0) { seenModules = new ts.Map(); }
|
|
@@ -149641,19 +149676,19 @@ var ts;
|
|
|
149641
149676
|
return function (context) { return context.options && context.options[optionName] === optionValue; };
|
|
149642
149677
|
}
|
|
149643
149678
|
function isOptionEnabled(optionName) {
|
|
149644
|
-
return function (context) { return context.options && context.options
|
|
149679
|
+
return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !!context.options[optionName]; };
|
|
149645
149680
|
}
|
|
149646
149681
|
function isOptionDisabled(optionName) {
|
|
149647
|
-
return function (context) { return context.options && context.options
|
|
149682
|
+
return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !context.options[optionName]; };
|
|
149648
149683
|
}
|
|
149649
149684
|
function isOptionDisabledOrUndefined(optionName) {
|
|
149650
|
-
return function (context) { return !context.options || !context.options
|
|
149685
|
+
return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName]; };
|
|
149651
149686
|
}
|
|
149652
149687
|
function isOptionDisabledOrUndefinedOrTokensOnSameLine(optionName) {
|
|
149653
|
-
return function (context) { return !context.options || !context.options
|
|
149688
|
+
return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
|
|
149654
149689
|
}
|
|
149655
149690
|
function isOptionEnabledOrUndefined(optionName) {
|
|
149656
|
-
return function (context) { return !context.options || !context.options
|
|
149691
|
+
return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !!context.options[optionName]; };
|
|
149657
149692
|
}
|
|
149658
149693
|
function isForContext(context) {
|
|
149659
149694
|
return context.contextNode.kind === 245 /* SyntaxKind.ForStatement */;
|
|
@@ -162637,7 +162672,6 @@ var ts;
|
|
|
162637
162672
|
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
|
|
162638
162673
|
},
|
|
162639
162674
|
});
|
|
162640
|
-
;
|
|
162641
162675
|
function getInfo(context, considerPartialSpans) {
|
|
162642
162676
|
if (considerPartialSpans === void 0) { considerPartialSpans = true; }
|
|
162643
162677
|
var file = context.file, program = context.program;
|
|
@@ -163114,7 +163148,6 @@ var ts;
|
|
|
163114
163148
|
});
|
|
163115
163149
|
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
|
|
163116
163150
|
}
|
|
163117
|
-
;
|
|
163118
163151
|
function isValidExpression(node) {
|
|
163119
163152
|
return ts.isBinaryExpression(node) || ts.isConditionalExpression(node);
|
|
163120
163153
|
}
|
|
@@ -163162,7 +163195,6 @@ var ts;
|
|
|
163162
163195
|
if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) {
|
|
163163
163196
|
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) };
|
|
163164
163197
|
}
|
|
163165
|
-
;
|
|
163166
163198
|
var finalExpression = getFinalExpressionInChain(expression.right);
|
|
163167
163199
|
if (!finalExpression)
|
|
163168
163200
|
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_convertible_access_expression) };
|
|
@@ -165506,7 +165538,6 @@ var ts;
|
|
|
165506
165538
|
(function (ts) {
|
|
165507
165539
|
var refactor;
|
|
165508
165540
|
(function (refactor) {
|
|
165509
|
-
;
|
|
165510
165541
|
/**
|
|
165511
165542
|
* Checks if some refactor info has refactor error info.
|
|
165512
165543
|
*/
|
|
@@ -165611,7 +165642,6 @@ var ts;
|
|
|
165611
165642
|
// Imports will be copied to the new file anyway, and may still be needed in the old file.
|
|
165612
165643
|
// Prologue directives will be copied to the new file and should be left in the old file.
|
|
165613
165644
|
return !isPureImport(statement) && !ts.isPrologueDirective(statement);
|
|
165614
|
-
;
|
|
165615
165645
|
}
|
|
165616
165646
|
function isPureImport(node) {
|
|
165617
165647
|
switch (node.kind) {
|