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/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
92
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220920");
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -2673,7 +2673,7 @@ var ts;
|
|
|
2673
2673
|
if (typeof func !== "function") {
|
|
2674
2674
|
return "";
|
|
2675
2675
|
}
|
|
2676
|
-
else if (
|
|
2676
|
+
else if (ts.hasProperty(func, "name")) {
|
|
2677
2677
|
return func.name;
|
|
2678
2678
|
}
|
|
2679
2679
|
else {
|
|
@@ -2998,7 +2998,7 @@ var ts;
|
|
|
2998
2998
|
];
|
|
2999
2999
|
for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
|
|
3000
3000
|
var ctor = nodeConstructors_1[_i];
|
|
3001
|
-
if (!
|
|
3001
|
+
if (!ts.hasProperty(ctor, "__debugKind")) {
|
|
3002
3002
|
Object.defineProperties(ctor.prototype, {
|
|
3003
3003
|
// for use with vscode-js-debug's new customDescriptionGenerator in launch.json
|
|
3004
3004
|
__tsDebuggerDisplay: {
|
|
@@ -3853,7 +3853,6 @@ var ts;
|
|
|
3853
3853
|
var typeCatalog = []; // NB: id is index + 1
|
|
3854
3854
|
var legendPath;
|
|
3855
3855
|
var legend = [];
|
|
3856
|
-
;
|
|
3857
3856
|
/** Starts tracing for the given project. */
|
|
3858
3857
|
function startTracing(tracingMode, traceDir, configFilePath) {
|
|
3859
3858
|
ts.Debug.assert(!ts.tracing, "Tracing already started");
|
|
@@ -8685,8 +8684,6 @@ var ts;
|
|
|
8685
8684
|
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."),
|
|
8686
8685
|
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."),
|
|
8687
8686
|
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."),
|
|
8688
|
-
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'."),
|
|
8689
|
-
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."),
|
|
8690
8687
|
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."),
|
|
8691
8688
|
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."),
|
|
8692
8689
|
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."),
|
|
@@ -8935,6 +8932,7 @@ var ts;
|
|
|
8935
8932
|
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."),
|
|
8936
8933
|
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."),
|
|
8937
8934
|
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."),
|
|
8935
|
+
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."),
|
|
8938
8936
|
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."),
|
|
8939
8937
|
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."),
|
|
8940
8938
|
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."),
|
|
@@ -10318,7 +10316,7 @@ var ts;
|
|
|
10318
10316
|
ts.stringToToken = stringToToken;
|
|
10319
10317
|
/* @internal */
|
|
10320
10318
|
function computeLineStarts(text) {
|
|
10321
|
-
var result =
|
|
10319
|
+
var result = [];
|
|
10322
10320
|
var pos = 0;
|
|
10323
10321
|
var lineStart = 0;
|
|
10324
10322
|
while (pos < text.length) {
|
|
@@ -13451,7 +13449,7 @@ var ts;
|
|
|
13451
13449
|
// Node Arrays
|
|
13452
13450
|
/* @internal */
|
|
13453
13451
|
function isNodeArray(array) {
|
|
13454
|
-
return
|
|
13452
|
+
return ts.hasProperty(array, "pos") && ts.hasProperty(array, "end");
|
|
13455
13453
|
}
|
|
13456
13454
|
ts.isNodeArray = isNodeArray;
|
|
13457
13455
|
// Literals
|
|
@@ -14923,7 +14921,6 @@ var ts;
|
|
|
14923
14921
|
return emitNode && emitNode.flags || 0;
|
|
14924
14922
|
}
|
|
14925
14923
|
ts.getEmitFlags = getEmitFlags;
|
|
14926
|
-
;
|
|
14927
14924
|
function getScriptTargetFeatures() {
|
|
14928
14925
|
return {
|
|
14929
14926
|
es2015: {
|
|
@@ -19649,7 +19646,7 @@ var ts;
|
|
|
19649
19646
|
}
|
|
19650
19647
|
function isWatchSet(options) {
|
|
19651
19648
|
// Firefox has Object.prototype.watch
|
|
19652
|
-
return options.watch &&
|
|
19649
|
+
return options.watch && ts.hasProperty(options, "watch");
|
|
19653
19650
|
}
|
|
19654
19651
|
ts.isWatchSet = isWatchSet;
|
|
19655
19652
|
function closeFileWatcher(watcher) {
|
|
@@ -26934,7 +26931,7 @@ var ts;
|
|
|
26934
26931
|
clone.transformFlags = node.transformFlags;
|
|
26935
26932
|
setOriginalNode(clone, node);
|
|
26936
26933
|
for (var key in node) {
|
|
26937
|
-
if (
|
|
26934
|
+
if (ts.hasProperty(clone, key) || !ts.hasProperty(node, key)) {
|
|
26938
26935
|
continue;
|
|
26939
26936
|
}
|
|
26940
26937
|
clone[key] = node[key];
|
|
@@ -31822,7 +31819,6 @@ var ts;
|
|
|
31822
31819
|
visitNodes(cbNode, cbNodes, node.parameters) ||
|
|
31823
31820
|
visitNode(cbNode, node.type);
|
|
31824
31821
|
}
|
|
31825
|
-
;
|
|
31826
31822
|
function forEachChildInUnionOrIntersectionType(node, cbNode, cbNodes) {
|
|
31827
31823
|
return visitNodes(cbNode, cbNodes, node.types);
|
|
31828
31824
|
}
|
|
@@ -43138,7 +43134,7 @@ var ts;
|
|
|
43138
43134
|
function convertCompilerOptionsForTelemetry(opts) {
|
|
43139
43135
|
var out = {};
|
|
43140
43136
|
for (var key in opts) {
|
|
43141
|
-
if (
|
|
43137
|
+
if (ts.hasProperty(opts, key)) {
|
|
43142
43138
|
var type = getOptionFromName(key);
|
|
43143
43139
|
if (type !== undefined) { // Ignore unknown options
|
|
43144
43140
|
out[key] = getOptionValueWithEmptyStrings(opts[key], type);
|
|
@@ -49522,6 +49518,7 @@ var ts;
|
|
|
49522
49518
|
isPropertyAccessible: isPropertyAccessible,
|
|
49523
49519
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
49524
49520
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
49521
|
+
isTypeParameterPossiblyReferenced: isTypeParameterPossiblyReferenced,
|
|
49525
49522
|
};
|
|
49526
49523
|
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
49527
49524
|
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
@@ -49641,7 +49638,8 @@ var ts;
|
|
|
49641
49638
|
var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */);
|
|
49642
49639
|
emptyTypeLiteralSymbol.members = ts.createSymbolTable();
|
|
49643
49640
|
var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49644
|
-
var
|
|
49641
|
+
var unknownEmptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49642
|
+
var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, unknownEmptyObjectType]) : unknownType;
|
|
49645
49643
|
var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
49646
49644
|
emptyGenericType.instantiations = new ts.Map();
|
|
49647
49645
|
var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
@@ -49755,6 +49753,7 @@ var ts;
|
|
|
49755
49753
|
var deferredGlobalOmitSymbol;
|
|
49756
49754
|
var deferredGlobalAwaitedSymbol;
|
|
49757
49755
|
var deferredGlobalBigIntType;
|
|
49756
|
+
var deferredGlobalRecordSymbol;
|
|
49758
49757
|
var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name
|
|
49759
49758
|
var flowLoopStart = 0;
|
|
49760
49759
|
var flowLoopCount = 0;
|
|
@@ -50550,12 +50549,13 @@ var ts;
|
|
|
50550
50549
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
50551
50550
|
* the given name can be found.
|
|
50552
50551
|
*
|
|
50552
|
+
* @param nameNotFoundMessage If defined, we will report errors found during resolve.
|
|
50553
50553
|
* @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
|
|
50554
50554
|
*/
|
|
50555
|
-
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals,
|
|
50555
|
+
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions) {
|
|
50556
50556
|
if (excludeGlobals === void 0) { excludeGlobals = false; }
|
|
50557
|
-
if (
|
|
50558
|
-
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals,
|
|
50557
|
+
if (getSpellingSuggestions === void 0) { getSpellingSuggestions = true; }
|
|
50558
|
+
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, getSymbol);
|
|
50559
50559
|
}
|
|
50560
50560
|
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggestions, lookup) {
|
|
50561
50561
|
var _a, _b, _c;
|
|
@@ -50713,7 +50713,9 @@ var ts;
|
|
|
50713
50713
|
// TypeScript 1.0 spec (April 2014): 3.4.1
|
|
50714
50714
|
// The scope of a type parameter extends over the entire declaration with which the type
|
|
50715
50715
|
// parameter list is associated, with the exception of static member declarations in classes.
|
|
50716
|
-
|
|
50716
|
+
if (nameNotFoundMessage) {
|
|
50717
|
+
error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
|
|
50718
|
+
}
|
|
50717
50719
|
return undefined;
|
|
50718
50720
|
}
|
|
50719
50721
|
break loop;
|
|
@@ -50751,7 +50753,9 @@ var ts;
|
|
|
50751
50753
|
if (ts.isClassLike(grandparent) || grandparent.kind === 261 /* SyntaxKind.InterfaceDeclaration */) {
|
|
50752
50754
|
// A reference to this grandparent's type parameters would be an error
|
|
50753
50755
|
if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) {
|
|
50754
|
-
|
|
50756
|
+
if (nameNotFoundMessage) {
|
|
50757
|
+
error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
|
|
50758
|
+
}
|
|
50755
50759
|
return undefined;
|
|
50756
50760
|
}
|
|
50757
50761
|
}
|
|
@@ -50947,7 +50951,7 @@ var ts;
|
|
|
50947
50951
|
}
|
|
50948
50952
|
return undefined;
|
|
50949
50953
|
}
|
|
50950
|
-
else if (checkAndReportErrorForInvalidInitializer()) {
|
|
50954
|
+
else if (nameNotFoundMessage && checkAndReportErrorForInvalidInitializer()) {
|
|
50951
50955
|
return undefined;
|
|
50952
50956
|
}
|
|
50953
50957
|
// Perform extra checks only if error reporting was requested
|
|
@@ -57108,7 +57112,6 @@ var ts;
|
|
|
57108
57112
|
return container;
|
|
57109
57113
|
}
|
|
57110
57114
|
}
|
|
57111
|
-
;
|
|
57112
57115
|
}
|
|
57113
57116
|
/** Create a synthetic property access flow node after the last statement of the file */
|
|
57114
57117
|
function getFlowTypeFromCommonJSExport(symbol) {
|
|
@@ -61854,6 +61857,10 @@ var ts;
|
|
|
61854
61857
|
function getGlobalBigIntType() {
|
|
61855
61858
|
return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, /*reportErrors*/ false))) || emptyObjectType;
|
|
61856
61859
|
}
|
|
61860
|
+
function getGlobalRecordSymbol() {
|
|
61861
|
+
deferredGlobalRecordSymbol || (deferredGlobalRecordSymbol = getGlobalTypeAliasSymbol("Record", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol);
|
|
61862
|
+
return deferredGlobalRecordSymbol === unknownSymbol ? undefined : deferredGlobalRecordSymbol;
|
|
61863
|
+
}
|
|
61857
61864
|
/**
|
|
61858
61865
|
* Instantiates a global type that is generic with some element type, and returns that instantiation.
|
|
61859
61866
|
*/
|
|
@@ -64579,9 +64586,10 @@ var ts;
|
|
|
64579
64586
|
node.parent.kind === 202 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier);
|
|
64580
64587
|
}
|
|
64581
64588
|
function isTypeParameterPossiblyReferenced(tp, node) {
|
|
64582
|
-
// If the type parameter doesn't have exactly one declaration, if there are
|
|
64589
|
+
// If the type parameter doesn't have exactly one declaration, if there are intervening statement blocks
|
|
64583
64590
|
// between the node and the type parameter declaration, if the node contains actual references to the
|
|
64584
|
-
// type parameter, or if the node contains type queries
|
|
64591
|
+
// type parameter, or if the node contains type queries that we can't prove couldn't contain references to the type parameter,
|
|
64592
|
+
// we consider the type parameter possibly referenced.
|
|
64585
64593
|
if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
|
|
64586
64594
|
var container = tp.symbol.declarations[0].parent;
|
|
64587
64595
|
for (var n = node; n !== container; n = n.parent) {
|
|
@@ -64600,6 +64608,27 @@ var ts;
|
|
|
64600
64608
|
return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
|
|
64601
64609
|
getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality
|
|
64602
64610
|
case 183 /* SyntaxKind.TypeQuery */:
|
|
64611
|
+
var entityName = node.exprName;
|
|
64612
|
+
var firstIdentifier = ts.getFirstIdentifier(entityName);
|
|
64613
|
+
var firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
|
|
64614
|
+
var tpDeclaration = tp.symbol.declarations[0]; // There is exactly one declaration, otherwise `containsReference` is not called
|
|
64615
|
+
var tpScope_1;
|
|
64616
|
+
if (tpDeclaration.kind === 165 /* SyntaxKind.TypeParameter */) { // Type parameter is a regular type parameter, e.g. foo<T>
|
|
64617
|
+
tpScope_1 = tpDeclaration.parent;
|
|
64618
|
+
}
|
|
64619
|
+
else if (tp.isThisType) {
|
|
64620
|
+
// Type parameter is the this type, and its declaration is the class declaration.
|
|
64621
|
+
tpScope_1 = tpDeclaration;
|
|
64622
|
+
}
|
|
64623
|
+
else {
|
|
64624
|
+
// Type parameter's declaration was unrecognized.
|
|
64625
|
+
// This could happen if the type parameter comes from e.g. a JSDoc annotation, so we default to returning true.
|
|
64626
|
+
return true;
|
|
64627
|
+
}
|
|
64628
|
+
if (firstIdentifierSymbol.declarations) {
|
|
64629
|
+
return ts.some(firstIdentifierSymbol.declarations, function (idDecl) { return ts.isNodeDescendantOf(idDecl, tpScope_1); }) ||
|
|
64630
|
+
ts.some(node.typeArguments, containsReference);
|
|
64631
|
+
}
|
|
64603
64632
|
return true;
|
|
64604
64633
|
case 171 /* SyntaxKind.MethodDeclaration */:
|
|
64605
64634
|
case 170 /* SyntaxKind.MethodSignature */:
|
|
@@ -72148,18 +72177,26 @@ var ts;
|
|
|
72148
72177
|
}
|
|
72149
72178
|
function isTypePresencePossible(type, propName, assumeTrue) {
|
|
72150
72179
|
var prop = getPropertyOfType(type, propName);
|
|
72151
|
-
|
|
72152
|
-
|
|
72153
|
-
|
|
72154
|
-
|
|
72155
|
-
|
|
72156
|
-
|
|
72157
|
-
|
|
72158
|
-
|
|
72159
|
-
|
|
72160
|
-
|
|
72180
|
+
return prop ?
|
|
72181
|
+
!!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
|
|
72182
|
+
!!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
|
|
72183
|
+
}
|
|
72184
|
+
function narrowByInKeyword(type, nameType, assumeTrue) {
|
|
72185
|
+
var name = getPropertyNameFromType(nameType);
|
|
72186
|
+
var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
|
|
72187
|
+
if (isKnownProperty) {
|
|
72188
|
+
// If the check is for a known property (i.e. a property declared in some constituent of
|
|
72189
|
+
// the target type), we filter the target type by presence of absence of the property.
|
|
72161
72190
|
return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); });
|
|
72162
72191
|
}
|
|
72192
|
+
if (assumeTrue) {
|
|
72193
|
+
// If the check is for an unknown property, we intersect the target type with `Record<X, unknown>`,
|
|
72194
|
+
// where X is the name of the property.
|
|
72195
|
+
var recordSymbol = getGlobalRecordSymbol();
|
|
72196
|
+
if (recordSymbol) {
|
|
72197
|
+
return getIntersectionType([type, getTypeAliasInstantiation(recordSymbol, [nameType, unknownType])]);
|
|
72198
|
+
}
|
|
72199
|
+
}
|
|
72163
72200
|
return type;
|
|
72164
72201
|
}
|
|
72165
72202
|
function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
|
|
@@ -72218,15 +72255,14 @@ var ts;
|
|
|
72218
72255
|
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
72219
72256
|
}
|
|
72220
72257
|
var target = getReferenceCandidate(expr.right);
|
|
72221
|
-
var leftType =
|
|
72222
|
-
if (leftType.flags &
|
|
72223
|
-
var name = ts.escapeLeadingUnderscores(leftType.value);
|
|
72258
|
+
var leftType = getTypeOfExpression(expr.left);
|
|
72259
|
+
if (leftType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */) {
|
|
72224
72260
|
if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) &&
|
|
72225
|
-
getAccessedPropertyName(reference) ===
|
|
72261
|
+
getAccessedPropertyName(reference) === getPropertyNameFromType(leftType)) {
|
|
72226
72262
|
return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
|
|
72227
72263
|
}
|
|
72228
72264
|
if (isMatchingReference(reference, target)) {
|
|
72229
|
-
return narrowByInKeyword(type,
|
|
72265
|
+
return narrowByInKeyword(type, leftType, assumeTrue);
|
|
72230
72266
|
}
|
|
72231
72267
|
}
|
|
72232
72268
|
break;
|
|
@@ -76396,7 +76432,6 @@ var ts;
|
|
|
76396
76432
|
}
|
|
76397
76433
|
return false;
|
|
76398
76434
|
}
|
|
76399
|
-
;
|
|
76400
76435
|
var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
|
|
76401
76436
|
if (!hasProp(suggestedMethod)) {
|
|
76402
76437
|
return undefined;
|
|
@@ -79967,6 +80002,9 @@ var ts;
|
|
|
79967
80002
|
}
|
|
79968
80003
|
return booleanType;
|
|
79969
80004
|
}
|
|
80005
|
+
function hasEmptyObjectIntersection(type) {
|
|
80006
|
+
return someType(type, function (t) { return t === unknownEmptyObjectType || !!(t.flags & 2097152 /* TypeFlags.Intersection */) && ts.some(t.types, isEmptyAnonymousObjectType); });
|
|
80007
|
+
}
|
|
79970
80008
|
function checkInExpression(left, right, leftType, rightType) {
|
|
79971
80009
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
79972
80010
|
return silentNeverType;
|
|
@@ -79983,40 +80021,20 @@ var ts;
|
|
|
79983
80021
|
}
|
|
79984
80022
|
}
|
|
79985
80023
|
else {
|
|
79986
|
-
|
|
79987
|
-
|
|
79988
|
-
|
|
79989
|
-
|
|
79990
|
-
|
|
79991
|
-
|
|
80024
|
+
// The type of the lef operand must be assignable to string, number, or symbol.
|
|
80025
|
+
checkTypeAssignableTo(checkNonNullType(leftType, left), stringNumberSymbolType, left);
|
|
80026
|
+
}
|
|
80027
|
+
// The type of the right operand must be assignable to 'object'.
|
|
80028
|
+
if (checkTypeAssignableTo(checkNonNullType(rightType, right), nonPrimitiveType, right)) {
|
|
80029
|
+
// The {} type is assignable to the object type, yet {} might represent a primitive type. Here we
|
|
80030
|
+
// detect and error on {} that results from narrowing the unknown type, as well as intersections
|
|
80031
|
+
// that include {} (we know that the other types in such intersections are assignable to object
|
|
80032
|
+
// since we already checked for that).
|
|
80033
|
+
if (hasEmptyObjectIntersection(rightType)) {
|
|
80034
|
+
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));
|
|
79992
80035
|
}
|
|
79993
80036
|
}
|
|
79994
|
-
rightType = checkNonNullType(rightType, right);
|
|
79995
|
-
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
79996
|
-
// The in operator requires the right operand to be
|
|
79997
|
-
//
|
|
79998
|
-
// 1. assignable to the non-primitive type,
|
|
79999
|
-
// 2. an unconstrained type parameter,
|
|
80000
|
-
// 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the
|
|
80001
|
-
// the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the
|
|
80002
|
-
// non-primitive type, or
|
|
80003
|
-
// 4. a type parameter whose constraint is
|
|
80004
|
-
// i. an object type,
|
|
80005
|
-
// ii. the non-primitive type, or
|
|
80006
|
-
// iii. a union or intersection with at least one constituent assignable to an object or non-primitive type.
|
|
80007
|
-
//
|
|
80008
|
-
// The divergent behavior for type parameters and unions containing type parameters is a workaround for type
|
|
80009
|
-
// parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance
|
|
80010
|
-
// it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error
|
|
80011
|
-
// unless *all* instantiations would result in an error.
|
|
80012
|
-
//
|
|
80013
80037
|
// The result is always of the Boolean primitive type.
|
|
80014
|
-
var rightTypeConstraint = getConstraintOfType(rightType);
|
|
80015
|
-
if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
|
|
80016
|
-
rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ||
|
|
80017
|
-
!maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) {
|
|
80018
|
-
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive);
|
|
80019
|
-
}
|
|
80020
80038
|
return booleanType;
|
|
80021
80039
|
}
|
|
80022
80040
|
function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
|
|
@@ -88458,7 +88476,7 @@ var ts;
|
|
|
88458
88476
|
}
|
|
88459
88477
|
var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
|
|
88460
88478
|
if (node) {
|
|
88461
|
-
var symbol =
|
|
88479
|
+
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88462
88480
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88463
88481
|
// declaration for the symbol
|
|
88464
88482
|
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
@@ -88825,6 +88843,25 @@ var ts;
|
|
|
88825
88843
|
}
|
|
88826
88844
|
return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
|
88827
88845
|
}
|
|
88846
|
+
/**
|
|
88847
|
+
* Get either a value-meaning symbol or an alias symbol.
|
|
88848
|
+
* Unlike `getReferencedValueSymbol`, if the cached resolved symbol is the unknown symbol,
|
|
88849
|
+
* we call `resolveName` to find a symbol.
|
|
88850
|
+
* This is because when caching the resolved symbol, we only consider value symbols, but here
|
|
88851
|
+
* we want to also get an alias symbol if one exists.
|
|
88852
|
+
*/
|
|
88853
|
+
function getReferencedValueOrAliasSymbol(reference) {
|
|
88854
|
+
var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
|
|
88855
|
+
if (resolvedSymbol && resolvedSymbol !== unknownSymbol) {
|
|
88856
|
+
return resolvedSymbol;
|
|
88857
|
+
}
|
|
88858
|
+
return resolveName(reference, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */,
|
|
88859
|
+
/*nodeNotFoundMessage*/ undefined,
|
|
88860
|
+
/*nameArg*/ undefined,
|
|
88861
|
+
/*isUse*/ true,
|
|
88862
|
+
/*excludeGlobals*/ undefined,
|
|
88863
|
+
/*getSpellingSuggestions*/ undefined);
|
|
88864
|
+
}
|
|
88828
88865
|
function getReferencedValueDeclaration(referenceIn) {
|
|
88829
88866
|
if (!ts.isGeneratedIdentifier(referenceIn)) {
|
|
88830
88867
|
var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
|
|
@@ -95274,9 +95311,10 @@ var ts;
|
|
|
95274
95311
|
return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
|
|
95275
95312
|
}
|
|
95276
95313
|
function shouldEmitAliasDeclaration(node) {
|
|
95277
|
-
return
|
|
95278
|
-
|
|
95279
|
-
|
|
95314
|
+
return ts.isInJSFile(node) ||
|
|
95315
|
+
(compilerOptions.preserveValueImports
|
|
95316
|
+
? resolver.isValueAliasDeclaration(node)
|
|
95317
|
+
: resolver.isReferencedAliasDeclaration(node));
|
|
95280
95318
|
}
|
|
95281
95319
|
}
|
|
95282
95320
|
ts.transformTypeScript = transformTypeScript;
|
|
@@ -110448,7 +110486,7 @@ var ts;
|
|
|
110448
110486
|
var _a;
|
|
110449
110487
|
var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
|
|
110450
110488
|
var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
|
|
110451
|
-
if (augmentingDeclarations) {
|
|
110489
|
+
if (primaryDeclaration && augmentingDeclarations) {
|
|
110452
110490
|
for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
|
|
110453
110491
|
var augmentations = augmentingDeclarations_1[_i];
|
|
110454
110492
|
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)));
|
|
@@ -118497,7 +118535,6 @@ var ts;
|
|
|
118497
118535
|
return resolutions;
|
|
118498
118536
|
}
|
|
118499
118537
|
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
118500
|
-
;
|
|
118501
118538
|
/**
|
|
118502
118539
|
* Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
|
|
118503
118540
|
* provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
|
|
@@ -1469,6 +1469,7 @@
|
|
|
1469
1469
|
"The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property_2490": "迭代器的 \"{0}()\" 方法返回的类型必须具有 \"value\" 属性。",
|
|
1470
1470
|
"The_types_of_0_are_incompatible_between_these_types_2200": "在这些类型中,\"{0}\" 的类型不兼容。",
|
|
1471
1471
|
"The_types_returned_by_0_are_incompatible_between_these_types_2201": "在这些类型中,\"{0}\" 返回的类型不兼容。",
|
|
1472
|
+
"The_value_0_cannot_be_used_here_18050": "此处不能使用值“{0}”。",
|
|
1472
1473
|
"The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189": "\"for...in\" 语句的变量声明不能有初始化表达式。",
|
|
1473
1474
|
"The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190": "\"for...of\" 语句的变量声明不能有初始化表达式。",
|
|
1474
1475
|
"The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410": "不支持 \"with\" 语句。\"with\" 程序块中的所有符号都将具有类型 \"any\"。",
|
|
@@ -1728,6 +1729,10 @@
|
|
|
1728
1729
|
"_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012": "“{0}”不是关键字“{1}”的有效元属性。是否是指“{2}”?",
|
|
1729
1730
|
"_0_is_not_allowed_as_a_parameter_name_1390": "不允许将 '{0}' 作为参数名。",
|
|
1730
1731
|
"_0_is_not_allowed_as_a_variable_declaration_name_1389": "“{0}”不得用作变量声明名称。",
|
|
1732
|
+
"_0_is_of_type_unknown_18046": "“{0}”的类型为“未知”。",
|
|
1733
|
+
"_0_is_possibly_null_18047": "“{0}”可能为 “null”。",
|
|
1734
|
+
"_0_is_possibly_null_or_undefined_18049": "{0}可能为 “null” 或“未定义”。",
|
|
1735
|
+
"_0_is_possibly_undefined_18048": "“{0}”可能为“未定义”。",
|
|
1731
1736
|
"_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506": "“{0}”在其自身的基表达式中得到直接或间接引用。",
|
|
1732
1737
|
"_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502": "“{0}”在其自身的类型批注中得到直接或间接引用。",
|
|
1733
1738
|
"_0_is_specified_more_than_once_so_this_usage_will_be_overwritten_2783": "多次指定了 \"{0}\",因此将重写此用法。",
|
|
@@ -1469,6 +1469,7 @@
|
|
|
1469
1469
|
"The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property_2490": "迭代器 '{0}()' 方法所傳回的類型必須具有 'value' 屬性。",
|
|
1470
1470
|
"The_types_of_0_are_incompatible_between_these_types_2200": "'{0}' 的類型在這些類型之間不相容。",
|
|
1471
1471
|
"The_types_returned_by_0_are_incompatible_between_these_types_2201": "'{0}' 所傳回的類型在這些類型之間不相容。",
|
|
1472
|
+
"The_value_0_cannot_be_used_here_18050": "此處無法使用值 '{0}'。",
|
|
1472
1473
|
"The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189": "'for...in' 陳述式的變數宣告不得有初始設定式。",
|
|
1473
1474
|
"The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190": "'for...of' 陳述式的變數宣告不得有初始設定式。",
|
|
1474
1475
|
"The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410": "不支援 'with' 陳述式。'with' 區塊中的所有符號都會有類型 'any'。",
|
|
@@ -1728,6 +1729,10 @@
|
|
|
1728
1729
|
"_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012": "'{0}' 對關鍵字 '{1}' 而言不是有效的中繼屬性。您是指 '{2}' 嗎?",
|
|
1729
1730
|
"_0_is_not_allowed_as_a_parameter_name_1390": "不允許 '{0}' 做為參數名稱。",
|
|
1730
1731
|
"_0_is_not_allowed_as_a_variable_declaration_name_1389": "'{0}' 不能是變數宣告名稱。",
|
|
1732
|
+
"_0_is_of_type_unknown_18046": "'{0}' 的類型為 'unknown'。",
|
|
1733
|
+
"_0_is_possibly_null_18047": "'{0}' 可能是 'null'。",
|
|
1734
|
+
"_0_is_possibly_null_or_undefined_18049": "'{0}' 可能為「null」或「未定義」。",
|
|
1735
|
+
"_0_is_possibly_undefined_18048": "'{0}' 可能為「未定義」。",
|
|
1731
1736
|
"_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506": "'{0}' 在其本身的基底運算式中直接或間接受到參考。",
|
|
1732
1737
|
"_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502": "'{0}' 在其本身的類型註釋中直接或間接受到參考。",
|
|
1733
1738
|
"_0_is_specified_more_than_once_so_this_usage_will_be_overwritten_2783": "多次指定 '{0}',因此將會覆寫此使用方式。",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.9.0-dev.
|
|
5
|
+
"version": "4.9.0-dev.20220920",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|