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
package/lib/tsserver.js
CHANGED
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
112
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220920");
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -2693,7 +2693,7 @@ var ts;
|
|
|
2693
2693
|
if (typeof func !== "function") {
|
|
2694
2694
|
return "";
|
|
2695
2695
|
}
|
|
2696
|
-
else if (
|
|
2696
|
+
else if (ts.hasProperty(func, "name")) {
|
|
2697
2697
|
return func.name;
|
|
2698
2698
|
}
|
|
2699
2699
|
else {
|
|
@@ -3018,7 +3018,7 @@ var ts;
|
|
|
3018
3018
|
];
|
|
3019
3019
|
for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
|
|
3020
3020
|
var ctor = nodeConstructors_1[_i];
|
|
3021
|
-
if (!
|
|
3021
|
+
if (!ts.hasProperty(ctor, "__debugKind")) {
|
|
3022
3022
|
Object.defineProperties(ctor.prototype, {
|
|
3023
3023
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
3024
3024
|
__tsDebuggerDisplay: {
|
|
@@ -3873,7 +3873,6 @@ var ts;
|
|
|
3873
3873
|
var typeCatalog = []; // NB: id is index + 1
|
|
3874
3874
|
var legendPath;
|
|
3875
3875
|
var legend = [];
|
|
3876
|
-
;
|
|
3877
3876
|
/** Starts tracing for the given project. */
|
|
3878
3877
|
function startTracing(tracingMode, traceDir, configFilePath) {
|
|
3879
3878
|
ts.Debug.assert(!ts.tracing, "Tracing already started");
|
|
@@ -8705,8 +8704,6 @@ var ts;
|
|
|
8705
8704
|
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."),
|
|
8706
8705
|
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."),
|
|
8707
8706
|
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."),
|
|
8708
|
-
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'."),
|
|
8709
|
-
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."),
|
|
8710
8707
|
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."),
|
|
8711
8708
|
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."),
|
|
8712
8709
|
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."),
|
|
@@ -8955,6 +8952,7 @@ var ts;
|
|
|
8955
8952
|
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."),
|
|
8956
8953
|
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."),
|
|
8957
8954
|
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."),
|
|
8955
|
+
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."),
|
|
8958
8956
|
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."),
|
|
8959
8957
|
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."),
|
|
8960
8958
|
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."),
|
|
@@ -10338,7 +10336,7 @@ var ts;
|
|
|
10338
10336
|
ts.stringToToken = stringToToken;
|
|
10339
10337
|
/* @internal */
|
|
10340
10338
|
function computeLineStarts(text) {
|
|
10341
|
-
var result =
|
|
10339
|
+
var result = [];
|
|
10342
10340
|
var pos = 0;
|
|
10343
10341
|
var lineStart = 0;
|
|
10344
10342
|
while (pos < text.length) {
|
|
@@ -13471,7 +13469,7 @@ var ts;
|
|
|
13471
13469
|
// Node Arrays
|
|
13472
13470
|
/* @internal */
|
|
13473
13471
|
function isNodeArray(array) {
|
|
13474
|
-
return
|
|
13472
|
+
return ts.hasProperty(array, "pos") && ts.hasProperty(array, "end");
|
|
13475
13473
|
}
|
|
13476
13474
|
ts.isNodeArray = isNodeArray;
|
|
13477
13475
|
// Literals
|
|
@@ -14943,7 +14941,6 @@ var ts;
|
|
|
14943
14941
|
return emitNode && emitNode.flags || 0;
|
|
14944
14942
|
}
|
|
14945
14943
|
ts.getEmitFlags = getEmitFlags;
|
|
14946
|
-
;
|
|
14947
14944
|
function getScriptTargetFeatures() {
|
|
14948
14945
|
return {
|
|
14949
14946
|
es2015: {
|
|
@@ -19669,7 +19666,7 @@ var ts;
|
|
|
19669
19666
|
}
|
|
19670
19667
|
function isWatchSet(options) {
|
|
19671
19668
|
// Firefox has Object.prototype.watch
|
|
19672
|
-
return options.watch &&
|
|
19669
|
+
return options.watch && ts.hasProperty(options, "watch");
|
|
19673
19670
|
}
|
|
19674
19671
|
ts.isWatchSet = isWatchSet;
|
|
19675
19672
|
function closeFileWatcher(watcher) {
|
|
@@ -26954,7 +26951,7 @@ var ts;
|
|
|
26954
26951
|
clone.transformFlags = node.transformFlags;
|
|
26955
26952
|
setOriginalNode(clone, node);
|
|
26956
26953
|
for (var key in node) {
|
|
26957
|
-
if (
|
|
26954
|
+
if (ts.hasProperty(clone, key) || !ts.hasProperty(node, key)) {
|
|
26958
26955
|
continue;
|
|
26959
26956
|
}
|
|
26960
26957
|
clone[key] = node[key];
|
|
@@ -31842,7 +31839,6 @@ var ts;
|
|
|
31842
31839
|
visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
31843
31840
|
visitNode(cbNode, node.type);
|
|
31844
31841
|
}
|
|
31845
|
-
;
|
|
31846
31842
|
function forEachChildInUnionOrIntersectionType(node, cbNode, cbNodes) {
|
|
31847
31843
|
return visitNodes(cbNode, cbNodes, node.types);
|
|
31848
31844
|
}
|
|
@@ -43158,7 +43154,7 @@ var ts;
|
|
|
43158
43154
|
function convertCompilerOptionsForTelemetry(opts) {
|
|
43159
43155
|
var out = {};
|
|
43160
43156
|
for (var key in opts) {
|
|
43161
|
-
if (
|
|
43157
|
+
if (ts.hasProperty(opts, key)) {
|
|
43162
43158
|
var type = getOptionFromName(key);
|
|
43163
43159
|
if (type !== undefined) { // Ignore unknown options
|
|
43164
43160
|
out[key] = getOptionValueWithEmptyStrings(opts[key], type);
|
|
@@ -49542,6 +49538,7 @@ var ts;
|
|
|
49542
49538
|
isPropertyAccessible: isPropertyAccessible,
|
|
49543
49539
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
49544
49540
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
49541
|
+
isTypeParameterPossiblyReferenced: isTypeParameterPossiblyReferenced,
|
|
49545
49542
|
};
|
|
49546
49543
|
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
49547
49544
|
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
@@ -49661,7 +49658,8 @@ var ts;
|
|
|
49661
49658
|
var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
|
|
49662
49659
|
emptyTypeLiteralSymbol.members = ts.createSymbolTable();
|
|
49663
49660
|
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49664
|
-
var
|
|
49661
|
+
var unknownEmptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49662
|
+
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
|
|
49665
49663
|
var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49666
49664
|
emptyGenericType.instantiations = new ts.Map();
|
|
49667
49665
|
var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
@@ -49775,6 +49773,7 @@ var ts;
|
|
|
49775
49773
|
var deferredGlobalOmitSymbol;
|
|
49776
49774
|
var deferredGlobalAwaitedSymbol;
|
|
49777
49775
|
var deferredGlobalBigIntType;
|
|
49776
|
+
var deferredGlobalRecordSymbol;
|
|
49778
49777
|
var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
|
|
49779
49778
|
var flowLoopStart = 0;
|
|
49780
49779
|
var flowLoopCount = 0;
|
|
@@ -50570,12 +50569,13 @@ var ts;
|
|
|
50570
50569
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
50571
50570
|
* the given name can be found.
|
|
50572
50571
|
*
|
|
50572
|
+
* @param nameNotFoundMessage If defined, we will report errors found during resolve.
|
|
50573
50573
|
* @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
|
|
50574
50574
|
*/
|
|
50575
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals,
|
|
50575
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions) {
|
|
50576
50576
|
if (excludeGlobals === void 0) { excludeGlobals = false; }
|
|
50577
|
-
if (
|
|
50578
|
-
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals,
|
|
50577
|
+
if (getSpellingSuggestions === void 0) { getSpellingSuggestions = true; }
|
|
50578
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol);
|
|
50579
50579
|
}
|
|
50580
50580
|
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
50581
50581
|
var _a, _b, _c;
|
|
@@ -50733,7 +50733,9 @@ var ts;
|
|
|
50733
50733
|
// TypeScript 1.0 spec (April 2014): 3.4.1
|
|
50734
50734
|
// The scope of a type parameter extends over the entire declaration with which the type
|
|
50735
50735
|
// parameter list is associated, with the exception of static member declarations in classes.
|
|
50736
|
-
|
|
50736
|
+
if (nameNotFoundMessage) {
|
|
50737
|
+
error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
|
|
50738
|
+
}
|
|
50737
50739
|
return undefined;
|
|
50738
50740
|
}
|
|
50739
50741
|
break loop;
|
|
@@ -50771,7 +50773,9 @@ var ts;
|
|
|
50771
50773
|
if (ts.isClassLike(grandparent) || grandparent.kind === 261 /* SyntaxKind.InterfaceDeclaration */) {
|
|
50772
50774
|
// A reference to this grandparent's type parameters would be an error
|
|
50773
50775
|
if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) {
|
|
50774
|
-
|
|
50776
|
+
if (nameNotFoundMessage) {
|
|
50777
|
+
error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
|
|
50778
|
+
}
|
|
50775
50779
|
return undefined;
|
|
50776
50780
|
}
|
|
50777
50781
|
}
|
|
@@ -50967,7 +50971,7 @@ var ts;
|
|
|
50967
50971
|
}
|
|
50968
50972
|
return undefined;
|
|
50969
50973
|
}
|
|
50970
|
-
else if (checkAndReportErrorForInvalidInitializer()) {
|
|
50974
|
+
else if (nameNotFoundMessage && checkAndReportErrorForInvalidInitializer()) {
|
|
50971
50975
|
return undefined;
|
|
50972
50976
|
}
|
|
50973
50977
|
// Perform extra checks only if error reporting was requested
|
|
@@ -57128,7 +57132,6 @@ var ts;
|
|
|
57128
57132
|
return container;
|
|
57129
57133
|
}
|
|
57130
57134
|
}
|
|
57131
|
-
;
|
|
57132
57135
|
}
|
|
57133
57136
|
/** Create a synthetic property access flow node after the last statement of the file */
|
|
57134
57137
|
function getFlowTypeFromCommonJSExport(symbol) {
|
|
@@ -61874,6 +61877,10 @@ var ts;
|
|
|
61874
61877
|
function getGlobalBigIntType() {
|
|
61875
61878
|
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
61876
61879
|
}
|
|
61880
|
+
function getGlobalRecordSymbol() {
|
|
61881
|
+
deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
|
|
61882
|
+
return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
|
|
61883
|
+
}
|
|
61877
61884
|
/**
|
|
61878
61885
|
* Instantiates a global type that is generic with some element type, and returns that instantiation.
|
|
61879
61886
|
*/
|
|
@@ -64599,9 +64606,10 @@ var ts;
|
|
|
64599
64606
|
node.parent.kind === 202 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier);
|
|
64600
64607
|
}
|
|
64601
64608
|
function isTypeParameterPossiblyReferenced(tp, node) {
|
|
64602
|
-
// If the type parameter doesn't have exactly one declaration, if there are
|
|
64609
|
+
// If the type parameter doesn't have exactly one declaration, if there are intervening statement blocks
|
|
64603
64610
|
// between the node and the type parameter declaration, if the node contains actual references to the
|
|
64604
|
-
// type parameter, or if the node contains type queries
|
|
64611
|
+
// type parameter, or if the node contains type queries that we can't prove couldn't contain references to the type parameter,
|
|
64612
|
+
// we consider the type parameter possibly referenced.
|
|
64605
64613
|
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
|
|
64606
64614
|
var container = tp.symbol.declarations[0].parent;
|
|
64607
64615
|
for (var n = node; n !== container; n = n.parent) {
|
|
@@ -64620,6 +64628,27 @@ var ts;
|
|
|
64620
64628
|
return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
|
|
64621
64629
|
getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality
|
|
64622
64630
|
case 183 /* SyntaxKind.TypeQuery */:
|
|
64631
|
+
var entityName = node.exprName;
|
|
64632
|
+
var firstIdentifier = ts.getFirstIdentifier(entityName);
|
|
64633
|
+
var firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
|
|
64634
|
+
var tpDeclaration = tp.symbol.declarations[0]; // There is exactly one declaration, otherwise `containsReference` is not called
|
|
64635
|
+
var tpScope_1;
|
|
64636
|
+
if (tpDeclaration.kind === 165 /* SyntaxKind.TypeParameter */) { // Type parameter is a regular type parameter, e.g. foo<T>
|
|
64637
|
+
tpScope_1 = tpDeclaration.parent;
|
|
64638
|
+
}
|
|
64639
|
+
else if (tp.isThisType) {
|
|
64640
|
+
// Type parameter is the this type, and its declaration is the class declaration.
|
|
64641
|
+
tpScope_1 = tpDeclaration;
|
|
64642
|
+
}
|
|
64643
|
+
else {
|
|
64644
|
+
// Type parameter's declaration was unrecognized.
|
|
64645
|
+
// This could happen if the type parameter comes from e.g. a JSDoc annotation, so we default to returning true.
|
|
64646
|
+
return true;
|
|
64647
|
+
}
|
|
64648
|
+
if (firstIdentifierSymbol.declarations) {
|
|
64649
|
+
return ts.some(firstIdentifierSymbol.declarations, function (idDecl) { return ts.isNodeDescendantOf(idDecl, tpScope_1); }) ||
|
|
64650
|
+
ts.some(node.typeArguments, containsReference);
|
|
64651
|
+
}
|
|
64623
64652
|
return true;
|
|
64624
64653
|
case 171 /* SyntaxKind.MethodDeclaration */:
|
|
64625
64654
|
case 170 /* SyntaxKind.MethodSignature */:
|
|
@@ -72168,18 +72197,26 @@ var ts;
|
|
|
72168
72197
|
}
|
|
72169
72198
|
function isTypePresencePossible(type, propName, assumeTrue) {
|
|
72170
72199
|
var prop = getPropertyOfType(type, propName);
|
|
72171
|
-
|
|
72172
|
-
|
|
72173
|
-
|
|
72174
|
-
|
|
72175
|
-
|
|
72176
|
-
|
|
72177
|
-
|
|
72178
|
-
|
|
72179
|
-
|
|
72180
|
-
|
|
72200
|
+
return prop ?
|
|
72201
|
+
!!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
|
|
72202
|
+
!!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
|
|
72203
|
+
}
|
|
72204
|
+
function narrowByInKeyword(type, nameType, assumeTrue) {
|
|
72205
|
+
var name = getPropertyNameFromType(nameType);
|
|
72206
|
+
var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
|
|
72207
|
+
if (isKnownProperty) {
|
|
72208
|
+
// If the check is for a known property (i.e. a property declared in some constituent of
|
|
72209
|
+
// the target type), we filter the target type by presence of absence of the property.
|
|
72181
72210
|
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
|
|
72182
72211
|
}
|
|
72212
|
+
if (assumeTrue) {
|
|
72213
|
+
// If the check is for an unknown property, we intersect the target type with `Record<X, unknown>`,
|
|
72214
|
+
// where X is the name of the property.
|
|
72215
|
+
var recordSymbol = getGlobalRecordSymbol();
|
|
72216
|
+
if (recordSymbol) {
|
|
72217
|
+
return getIntersectionType([type, getTypeAliasInstantiation(recordSymbol, [nameType, unknownType])]);
|
|
72218
|
+
}
|
|
72219
|
+
}
|
|
72183
72220
|
return type;
|
|
72184
72221
|
}
|
|
72185
72222
|
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
|
|
@@ -72238,15 +72275,14 @@ var ts;
|
|
|
72238
72275
|
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
72239
72276
|
}
|
|
72240
72277
|
var target = getReferenceCandidate(expr.right);
|
|
72241
|
-
var leftType =
|
|
72242
|
-
if (leftType.flags &
|
|
72243
|
-
var name = ts.escapeLeadingUnderscores(leftType.value);
|
|
72278
|
+
var leftType = getTypeOfExpression(expr.left);
|
|
72279
|
+
if (leftType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */) {
|
|
72244
72280
|
if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) &&
|
|
72245
|
-
getAccessedPropertyName(reference) ===
|
|
72281
|
+
getAccessedPropertyName(reference) === getPropertyNameFromType(leftType)) {
|
|
72246
72282
|
return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
|
|
72247
72283
|
}
|
|
72248
72284
|
if (isMatchingReference(reference, target)) {
|
|
72249
|
-
return narrowByInKeyword(type,
|
|
72285
|
+
return narrowByInKeyword(type, leftType, assumeTrue);
|
|
72250
72286
|
}
|
|
72251
72287
|
}
|
|
72252
72288
|
break;
|
|
@@ -76416,7 +76452,6 @@ var ts;
|
|
|
76416
76452
|
}
|
|
76417
76453
|
return false;
|
|
76418
76454
|
}
|
|
76419
|
-
;
|
|
76420
76455
|
var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
|
|
76421
76456
|
if (!hasProp(suggestedMethod)) {
|
|
76422
76457
|
return undefined;
|
|
@@ -79987,6 +80022,9 @@ var ts;
|
|
|
79987
80022
|
}
|
|
79988
80023
|
return booleanType;
|
|
79989
80024
|
}
|
|
80025
|
+
function hasEmptyObjectIntersection(type) {
|
|
80026
|
+
return someType(type, function (t) { return t === unknownEmptyObjectType || !!(t.flags & 2097152 /* TypeFlags.Intersection */) && ts.some(t.types, isEmptyAnonymousObjectType); });
|
|
80027
|
+
}
|
|
79990
80028
|
function checkInExpression(left, right, leftType, rightType) {
|
|
79991
80029
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
79992
80030
|
return silentNeverType;
|
|
@@ -80003,40 +80041,20 @@ var ts;
|
|
|
80003
80041
|
}
|
|
80004
80042
|
}
|
|
80005
80043
|
else {
|
|
80006
|
-
|
|
80007
|
-
|
|
80008
|
-
|
|
80009
|
-
|
|
80010
|
-
|
|
80011
|
-
|
|
80044
|
+
// The type of the lef operand must be assignable to string, number, or symbol.
|
|
80045
|
+
checkTypeAssignableTo(checkNonNullType(leftType, left), stringNumberSymbolType, left);
|
|
80046
|
+
}
|
|
80047
|
+
// The type of the right operand must be assignable to 'object'.
|
|
80048
|
+
if (checkTypeAssignableTo(checkNonNullType(rightType, right), nonPrimitiveType, right)) {
|
|
80049
|
+
// The {} type is assignable to the object type, yet {} might represent a primitive type. Here we
|
|
80050
|
+
// detect and error on {} that results from narrowing the unknown type, as well as intersections
|
|
80051
|
+
// that include {} (we know that the other types in such intersections are assignable to object
|
|
80052
|
+
// since we already checked for that).
|
|
80053
|
+
if (hasEmptyObjectIntersection(rightType)) {
|
|
80054
|
+
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));
|
|
80012
80055
|
}
|
|
80013
80056
|
}
|
|
80014
|
-
rightType = checkNonNullType(rightType, right);
|
|
80015
|
-
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
80016
|
-
// The in operator requires the right operand to be
|
|
80017
|
-
//
|
|
80018
|
-
// 1. assignable to the non-primitive type,
|
|
80019
|
-
// 2. an unconstrained type parameter,
|
|
80020
|
-
// 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the
|
|
80021
|
-
// the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the
|
|
80022
|
-
// non-primitive type, or
|
|
80023
|
-
// 4. a type parameter whose constraint is
|
|
80024
|
-
// i. an object type,
|
|
80025
|
-
// ii. the non-primitive type, or
|
|
80026
|
-
// iii. a union or intersection with at least one constituent assignable to an object or non-primitive type.
|
|
80027
|
-
//
|
|
80028
|
-
// The divergent behavior for type parameters and unions containing type parameters is a workaround for type
|
|
80029
|
-
// parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance
|
|
80030
|
-
// it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error
|
|
80031
|
-
// unless *all* instantiations would result in an error.
|
|
80032
|
-
//
|
|
80033
80057
|
// The result is always of the Boolean primitive type.
|
|
80034
|
-
var rightTypeConstraint = getConstraintOfType(rightType);
|
|
80035
|
-
if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
|
|
80036
|
-
rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
|
|
80037
|
-
!maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) {
|
|
80038
|
-
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive);
|
|
80039
|
-
}
|
|
80040
80058
|
return booleanType;
|
|
80041
80059
|
}
|
|
80042
80060
|
function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
|
|
@@ -88478,7 +88496,7 @@ var ts;
|
|
|
88478
88496
|
}
|
|
88479
88497
|
var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
|
|
88480
88498
|
if (node) {
|
|
88481
|
-
var symbol =
|
|
88499
|
+
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88482
88500
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88483
88501
|
// declaration for the symbol
|
|
88484
88502
|
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
@@ -88845,6 +88863,25 @@ var ts;
|
|
|
88845
88863
|
}
|
|
88846
88864
|
return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
|
88847
88865
|
}
|
|
88866
|
+
/**
|
|
88867
|
+
* Get either a value-meaning symbol or an alias symbol.
|
|
88868
|
+
* Unlike `getReferencedValueSymbol`, if the cached resolved symbol is the unknown symbol,
|
|
88869
|
+
* we call `resolveName` to find a symbol.
|
|
88870
|
+
* This is because when caching the resolved symbol, we only consider value symbols, but here
|
|
88871
|
+
* we want to also get an alias symbol if one exists.
|
|
88872
|
+
*/
|
|
88873
|
+
function getReferencedValueOrAliasSymbol(reference) {
|
|
88874
|
+
var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
|
|
88875
|
+
if (resolvedSymbol && resolvedSymbol !== unknownSymbol) {
|
|
88876
|
+
return resolvedSymbol;
|
|
88877
|
+
}
|
|
88878
|
+
return resolveName(reference, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */,
|
|
88879
|
+
/*nodeNotFoundMessage*/ undefined,
|
|
88880
|
+
/*nameArg*/ undefined,
|
|
88881
|
+
/*isUse*/ true,
|
|
88882
|
+
/*excludeGlobals*/ undefined,
|
|
88883
|
+
/*getSpellingSuggestions*/ undefined);
|
|
88884
|
+
}
|
|
88848
88885
|
function getReferencedValueDeclaration(referenceIn) {
|
|
88849
88886
|
if (!ts.isGeneratedIdentifier(referenceIn)) {
|
|
88850
88887
|
var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
|
|
@@ -95294,9 +95331,10 @@ var ts;
|
|
|
95294
95331
|
return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
|
|
95295
95332
|
}
|
|
95296
95333
|
function shouldEmitAliasDeclaration(node) {
|
|
95297
|
-
return
|
|
95298
|
-
|
|
95299
|
-
|
|
95334
|
+
return ts.isInJSFile(node) ||
|
|
95335
|
+
(compilerOptions.preserveValueImports
|
|
95336
|
+
? resolver.isValueAliasDeclaration(node)
|
|
95337
|
+
: resolver.isReferencedAliasDeclaration(node));
|
|
95300
95338
|
}
|
|
95301
95339
|
}
|
|
95302
95340
|
ts.transformTypeScript = transformTypeScript;
|
|
@@ -110468,7 +110506,7 @@ var ts;
|
|
|
110468
110506
|
var _a;
|
|
110469
110507
|
var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
|
|
110470
110508
|
var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
|
|
110471
|
-
if (augmentingDeclarations) {
|
|
110509
|
+
if (primaryDeclaration && augmentingDeclarations) {
|
|
110472
110510
|
for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
|
|
110473
110511
|
var augmentations = augmentingDeclarations_1[_i];
|
|
110474
110512
|
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)));
|
|
@@ -118517,7 +118555,6 @@ var ts;
|
|
|
118517
118555
|
return resolutions;
|
|
118518
118556
|
}
|
|
118519
118557
|
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
118520
|
-
;
|
|
118521
118558
|
/**
|
|
118522
118559
|
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
|
118523
118560
|
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
|
@@ -134594,7 +134631,7 @@ var ts;
|
|
|
134594
134631
|
if (!dependencies)
|
|
134595
134632
|
continue;
|
|
134596
134633
|
for (var dep in dependencies) {
|
|
134597
|
-
if (
|
|
134634
|
+
if (ts.hasProperty(dependencies, dep) && !ts.startsWith(dep, "@types/")) {
|
|
134598
134635
|
result.push(dep);
|
|
134599
134636
|
}
|
|
134600
134637
|
}
|
|
@@ -135447,7 +135484,6 @@ var ts;
|
|
|
135447
135484
|
var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) };
|
|
135448
135485
|
return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails };
|
|
135449
135486
|
}
|
|
135450
|
-
;
|
|
135451
135487
|
function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences) {
|
|
135452
135488
|
var declarations = symbol.getDeclarations();
|
|
135453
135489
|
if (!(declarations && declarations.length)) {
|
|
@@ -138151,7 +138187,6 @@ var ts;
|
|
|
138151
138187
|
function isArrowFunctionBody(node) {
|
|
138152
138188
|
return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node;
|
|
138153
138189
|
}
|
|
138154
|
-
;
|
|
138155
138190
|
/** True if symbol is a type or a module containing at least one type. */
|
|
138156
138191
|
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
|
|
138157
138192
|
if (seenModules === void 0) { seenModules = new ts.Map(); }
|
|
@@ -149232,19 +149267,19 @@ var ts;
|
|
|
149232
149267
|
return function (context) { return context.options && context.options[optionName] === optionValue; };
|
|
149233
149268
|
}
|
|
149234
149269
|
function isOptionEnabled(optionName) {
|
|
149235
|
-
return function (context) { return context.options && context.options
|
|
149270
|
+
return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !!context.options[optionName]; };
|
|
149236
149271
|
}
|
|
149237
149272
|
function isOptionDisabled(optionName) {
|
|
149238
|
-
return function (context) { return context.options && context.options
|
|
149273
|
+
return function (context) { return context.options && ts.hasProperty(context.options, optionName) && !context.options[optionName]; };
|
|
149239
149274
|
}
|
|
149240
149275
|
function isOptionDisabledOrUndefined(optionName) {
|
|
149241
|
-
return function (context) { return !context.options || !context.options
|
|
149276
|
+
return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName]; };
|
|
149242
149277
|
}
|
|
149243
149278
|
function isOptionDisabledOrUndefinedOrTokensOnSameLine(optionName) {
|
|
149244
|
-
return function (context) { return !context.options || !context.options
|
|
149279
|
+
return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !context.options[optionName] || context.TokensAreOnSameLine(); };
|
|
149245
149280
|
}
|
|
149246
149281
|
function isOptionEnabledOrUndefined(optionName) {
|
|
149247
|
-
return function (context) { return !context.options || !context.options
|
|
149282
|
+
return function (context) { return !context.options || !ts.hasProperty(context.options, optionName) || !!context.options[optionName]; };
|
|
149248
149283
|
}
|
|
149249
149284
|
function isForContext(context) {
|
|
149250
149285
|
return context.contextNode.kind === 245 /* SyntaxKind.ForStatement */;
|
|
@@ -162228,7 +162263,6 @@ var ts;
|
|
|
162228
162263
|
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
|
|
162229
162264
|
},
|
|
162230
162265
|
});
|
|
162231
|
-
;
|
|
162232
162266
|
function getInfo(context, considerPartialSpans) {
|
|
162233
162267
|
if (considerPartialSpans === void 0) { considerPartialSpans = true; }
|
|
162234
162268
|
var file = context.file, program = context.program;
|
|
@@ -162705,7 +162739,6 @@ var ts;
|
|
|
162705
162739
|
});
|
|
162706
162740
|
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
|
|
162707
162741
|
}
|
|
162708
|
-
;
|
|
162709
162742
|
function isValidExpression(node) {
|
|
162710
162743
|
return ts.isBinaryExpression(node) || ts.isConditionalExpression(node);
|
|
162711
162744
|
}
|
|
@@ -162753,7 +162786,6 @@ var ts;
|
|
|
162753
162786
|
if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) {
|
|
162754
162787
|
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) };
|
|
162755
162788
|
}
|
|
162756
|
-
;
|
|
162757
162789
|
var finalExpression = getFinalExpressionInChain(expression.right);
|
|
162758
162790
|
if (!finalExpression)
|
|
162759
162791
|
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_convertible_access_expression) };
|
|
@@ -165097,7 +165129,6 @@ var ts;
|
|
|
165097
165129
|
(function (ts) {
|
|
165098
165130
|
var refactor;
|
|
165099
165131
|
(function (refactor) {
|
|
165100
|
-
;
|
|
165101
165132
|
/**
|
|
165102
165133
|
* Checks if some refactor info has refactor error info.
|
|
165103
165134
|
*/
|
|
@@ -165202,7 +165233,6 @@ var ts;
|
|
|
165202
165233
|
// Imports will be copied to the new file anyway, and may still be needed in the old file.
|
|
165203
165234
|
// Prologue directives will be copied to the new file and should be left in the old file.
|
|
165204
165235
|
return !isPureImport(statement) && !ts.isPrologueDirective(statement);
|
|
165205
|
-
;
|
|
165206
165236
|
}
|
|
165207
165237
|
function isPureImport(node) {
|
|
165208
165238
|
switch (node.kind) {
|
|
@@ -175257,7 +175287,7 @@ var ts;
|
|
|
175257
175287
|
// raw is now fixed and ready
|
|
175258
175288
|
this.safelist = raw.typesMap;
|
|
175259
175289
|
for (var key in raw.simpleMap) {
|
|
175260
|
-
if (raw.simpleMap
|
|
175290
|
+
if (ts.hasProperty(raw.simpleMap, key)) {
|
|
175261
175291
|
this.legacySafelist.set(key, raw.simpleMap[key].toLowerCase());
|
|
175262
175292
|
}
|
|
175263
175293
|
}
|
|
@@ -178671,7 +178701,6 @@ var ts;
|
|
|
178671
178701
|
}
|
|
178672
178702
|
return ts.deduplicate(outputs, ts.equateValues);
|
|
178673
178703
|
}
|
|
178674
|
-
;
|
|
178675
178704
|
function createDocumentSpanSet() {
|
|
178676
178705
|
return ts.createSet(function (_a) {
|
|
178677
178706
|
var textSpan = _a.textSpan;
|