typescript 4.7.0-dev.20220406 → 4.7.0-dev.20220408
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +46 -22
- package/lib/tsserver.js +91 -27
- package/lib/tsserverlibrary.js +91 -27
- package/lib/typescript.js +91 -27
- package/lib/typescriptServices.js +91 -27
- package/lib/typingsInstaller.js +56 -22
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.7";
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220408";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
@@ -5901,6 +5901,7 @@ var ts;
|
|
|
5901
5901
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
5902
5902
|
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."),
|
|
5903
5903
|
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."),
|
|
5904
|
+
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."),
|
|
5904
5905
|
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."),
|
|
5905
5906
|
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."),
|
|
5906
5907
|
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."),
|
|
@@ -37492,6 +37493,7 @@ var ts;
|
|
|
37492
37493
|
case 261:
|
|
37493
37494
|
case 259:
|
|
37494
37495
|
case 195:
|
|
37496
|
+
case 176:
|
|
37495
37497
|
return 1 | 32;
|
|
37496
37498
|
case 305:
|
|
37497
37499
|
return 1 | 4 | 32;
|
|
@@ -37509,7 +37511,6 @@ var ts;
|
|
|
37509
37511
|
case 317:
|
|
37510
37512
|
case 179:
|
|
37511
37513
|
case 175:
|
|
37512
|
-
case 176:
|
|
37513
37514
|
case 180:
|
|
37514
37515
|
case 170:
|
|
37515
37516
|
return 1 | 4 | 32 | 8;
|
|
@@ -41330,27 +41331,27 @@ var ts;
|
|
|
41330
41331
|
function resolveAlias(symbol) {
|
|
41331
41332
|
ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
|
|
41332
41333
|
var links = getSymbolLinks(symbol);
|
|
41333
|
-
if (!links.
|
|
41334
|
-
links.
|
|
41334
|
+
if (!links.aliasTarget) {
|
|
41335
|
+
links.aliasTarget = resolvingSymbol;
|
|
41335
41336
|
var node = getDeclarationOfAliasSymbol(symbol);
|
|
41336
41337
|
if (!node)
|
|
41337
41338
|
return ts.Debug.fail();
|
|
41338
41339
|
var target = getTargetOfAliasDeclaration(node);
|
|
41339
|
-
if (links.
|
|
41340
|
-
links.
|
|
41340
|
+
if (links.aliasTarget === resolvingSymbol) {
|
|
41341
|
+
links.aliasTarget = target || unknownSymbol;
|
|
41341
41342
|
}
|
|
41342
41343
|
else {
|
|
41343
41344
|
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
41344
41345
|
}
|
|
41345
41346
|
}
|
|
41346
|
-
else if (links.
|
|
41347
|
-
links.
|
|
41347
|
+
else if (links.aliasTarget === resolvingSymbol) {
|
|
41348
|
+
links.aliasTarget = unknownSymbol;
|
|
41348
41349
|
}
|
|
41349
|
-
return links.
|
|
41350
|
+
return links.aliasTarget;
|
|
41350
41351
|
}
|
|
41351
41352
|
function tryResolveAlias(symbol) {
|
|
41352
41353
|
var links = getSymbolLinks(symbol);
|
|
41353
|
-
if (links.
|
|
41354
|
+
if (links.aliasTarget !== resolvingSymbol) {
|
|
41354
41355
|
return resolveAlias(symbol);
|
|
41355
41356
|
}
|
|
41356
41357
|
return undefined;
|
|
@@ -42937,13 +42938,27 @@ var ts;
|
|
|
42937
42938
|
return ts.Debug.fail("Should be unreachable.");
|
|
42938
42939
|
function conditionalTypeToTypeNode(type) {
|
|
42939
42940
|
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
|
|
42941
|
+
context.approximateLength += 15;
|
|
42942
|
+
if (context.flags & 4 && type.root.isDistributive && !(type.checkType.flags & 262144)) {
|
|
42943
|
+
var newParam = createTypeParameter(createSymbol(262144, "T"));
|
|
42944
|
+
var name = typeParameterToName(newParam, context);
|
|
42945
|
+
var newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
42946
|
+
context.approximateLength += 37;
|
|
42947
|
+
var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
|
|
42948
|
+
var saveInferTypeParameters_1 = context.inferTypeParameters;
|
|
42949
|
+
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
42950
|
+
var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
|
|
42951
|
+
context.inferTypeParameters = saveInferTypeParameters_1;
|
|
42952
|
+
var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
|
|
42953
|
+
var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
|
|
42954
|
+
return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143)), ts.factory.createKeywordTypeNode(143));
|
|
42955
|
+
}
|
|
42940
42956
|
var saveInferTypeParameters = context.inferTypeParameters;
|
|
42941
42957
|
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
42942
42958
|
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
|
|
42943
42959
|
context.inferTypeParameters = saveInferTypeParameters;
|
|
42944
42960
|
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
|
|
42945
42961
|
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
|
|
42946
|
-
context.approximateLength += 15;
|
|
42947
42962
|
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
|
|
42948
42963
|
}
|
|
42949
42964
|
function typeToTypeNodeOrCircularityElision(type) {
|
|
@@ -64063,7 +64078,7 @@ var ts;
|
|
|
64063
64078
|
var newSymbol = createSymbol(2097152, "default");
|
|
64064
64079
|
newSymbol.parent = originalSymbol;
|
|
64065
64080
|
newSymbol.nameType = getStringLiteralType("default");
|
|
64066
|
-
newSymbol.
|
|
64081
|
+
newSymbol.aliasTarget = resolveSymbol(symbol);
|
|
64067
64082
|
memberTable.set("default", newSymbol);
|
|
64068
64083
|
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
64069
64084
|
}
|
|
@@ -66589,14 +66604,19 @@ var ts;
|
|
|
66589
66604
|
}
|
|
66590
66605
|
if (node.parent.kind === 258 || node.parent.kind === 257 || node.parent.kind === 259) {
|
|
66591
66606
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
66592
|
-
if (modifiers
|
|
66607
|
+
if (modifiers) {
|
|
66593
66608
|
var symbol = getSymbolOfNode(node.parent);
|
|
66594
|
-
|
|
66595
|
-
|
|
66596
|
-
|
|
66597
|
-
|
|
66598
|
-
|
|
66599
|
-
|
|
66609
|
+
if (node.parent.kind === 259 && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 | 32))) {
|
|
66610
|
+
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
66611
|
+
}
|
|
66612
|
+
else if (modifiers === 32768 || modifiers === 65536) {
|
|
66613
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSubType : markerSuperType);
|
|
66614
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSuperType : markerSubType);
|
|
66615
|
+
var saveVarianceTypeParameter = typeParameter;
|
|
66616
|
+
varianceTypeParameter = typeParameter;
|
|
66617
|
+
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
66618
|
+
varianceTypeParameter = saveVarianceTypeParameter;
|
|
66619
|
+
}
|
|
66600
66620
|
}
|
|
66601
66621
|
}
|
|
66602
66622
|
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
@@ -72274,11 +72294,11 @@ var ts;
|
|
|
72274
72294
|
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
|
|
72275
72295
|
return leftSpread ? [leftSpread, rightSpread]
|
|
72276
72296
|
: syntheticOrigin ? [syntheticOrigin]
|
|
72277
|
-
: ts.singleElementArray(
|
|
72297
|
+
: ts.singleElementArray(tryGetTarget(symbol));
|
|
72278
72298
|
}
|
|
72279
72299
|
return undefined;
|
|
72280
72300
|
}
|
|
72281
|
-
function
|
|
72301
|
+
function tryGetTarget(symbol) {
|
|
72282
72302
|
var target;
|
|
72283
72303
|
var next = symbol;
|
|
72284
72304
|
while (next = getSymbolLinks(next).target) {
|
|
@@ -72463,7 +72483,7 @@ var ts;
|
|
|
72463
72483
|
if (links === null || links === void 0 ? void 0 : links.referenced) {
|
|
72464
72484
|
return true;
|
|
72465
72485
|
}
|
|
72466
|
-
var target = getSymbolLinks(symbol).
|
|
72486
|
+
var target = getSymbolLinks(symbol).aliasTarget;
|
|
72467
72487
|
if (target && ts.getEffectiveModifierFlags(node) & 1 &&
|
|
72468
72488
|
target.flags & 111551 &&
|
|
72469
72489
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
@@ -88863,6 +88883,10 @@ var ts;
|
|
|
88863
88883
|
return factory.updateModifiers(statement, modifiers);
|
|
88864
88884
|
}
|
|
88865
88885
|
function transformTopLevelDeclaration(input) {
|
|
88886
|
+
if (lateMarkedStatements) {
|
|
88887
|
+
while (ts.orderedRemoveItem(lateMarkedStatements, input))
|
|
88888
|
+
;
|
|
88889
|
+
}
|
|
88866
88890
|
if (shouldStripInternal(input))
|
|
88867
88891
|
return;
|
|
88868
88892
|
switch (input.kind) {
|
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220408";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8717,6 +8717,7 @@ var ts;
|
|
|
8717
8717
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8718
8718
|
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."),
|
|
8719
8719
|
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."),
|
|
8720
|
+
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."),
|
|
8720
8721
|
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."),
|
|
8721
8722
|
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."),
|
|
8722
8723
|
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."),
|
|
@@ -45772,6 +45773,7 @@ var ts;
|
|
|
45772
45773
|
case 261 /* ModuleDeclaration */:
|
|
45773
45774
|
case 259 /* TypeAliasDeclaration */:
|
|
45774
45775
|
case 195 /* MappedType */:
|
|
45776
|
+
case 176 /* IndexSignature */:
|
|
45775
45777
|
return 1 /* IsContainer */ | 32 /* HasLocals */;
|
|
45776
45778
|
case 305 /* SourceFile */:
|
|
45777
45779
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
|
|
@@ -45790,7 +45792,6 @@ var ts;
|
|
|
45790
45792
|
case 317 /* JSDocFunctionType */:
|
|
45791
45793
|
case 179 /* FunctionType */:
|
|
45792
45794
|
case 175 /* ConstructSignature */:
|
|
45793
|
-
case 176 /* IndexSignature */:
|
|
45794
45795
|
case 180 /* ConstructorType */:
|
|
45795
45796
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
45796
45797
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
|
|
@@ -50368,27 +50369,27 @@ var ts;
|
|
|
50368
50369
|
function resolveAlias(symbol) {
|
|
50369
50370
|
ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
50370
50371
|
var links = getSymbolLinks(symbol);
|
|
50371
|
-
if (!links.
|
|
50372
|
-
links.
|
|
50372
|
+
if (!links.aliasTarget) {
|
|
50373
|
+
links.aliasTarget = resolvingSymbol;
|
|
50373
50374
|
var node = getDeclarationOfAliasSymbol(symbol);
|
|
50374
50375
|
if (!node)
|
|
50375
50376
|
return ts.Debug.fail();
|
|
50376
50377
|
var target = getTargetOfAliasDeclaration(node);
|
|
50377
|
-
if (links.
|
|
50378
|
-
links.
|
|
50378
|
+
if (links.aliasTarget === resolvingSymbol) {
|
|
50379
|
+
links.aliasTarget = target || unknownSymbol;
|
|
50379
50380
|
}
|
|
50380
50381
|
else {
|
|
50381
50382
|
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
50382
50383
|
}
|
|
50383
50384
|
}
|
|
50384
|
-
else if (links.
|
|
50385
|
-
links.
|
|
50385
|
+
else if (links.aliasTarget === resolvingSymbol) {
|
|
50386
|
+
links.aliasTarget = unknownSymbol;
|
|
50386
50387
|
}
|
|
50387
|
-
return links.
|
|
50388
|
+
return links.aliasTarget;
|
|
50388
50389
|
}
|
|
50389
50390
|
function tryResolveAlias(symbol) {
|
|
50390
50391
|
var links = getSymbolLinks(symbol);
|
|
50391
|
-
if (links.
|
|
50392
|
+
if (links.aliasTarget !== resolvingSymbol) {
|
|
50392
50393
|
return resolveAlias(symbol);
|
|
50393
50394
|
}
|
|
50394
50395
|
return undefined;
|
|
@@ -52185,13 +52186,37 @@ var ts;
|
|
|
52185
52186
|
return ts.Debug.fail("Should be unreachable.");
|
|
52186
52187
|
function conditionalTypeToTypeNode(type) {
|
|
52187
52188
|
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
|
|
52189
|
+
context.approximateLength += 15;
|
|
52190
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
52191
|
+
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52192
|
+
var name = typeParameterToName(newParam, context);
|
|
52193
|
+
var newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
52194
|
+
context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
|
|
52195
|
+
var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
|
|
52196
|
+
var saveInferTypeParameters_1 = context.inferTypeParameters;
|
|
52197
|
+
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52198
|
+
var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
|
|
52199
|
+
context.inferTypeParameters = saveInferTypeParameters_1;
|
|
52200
|
+
var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
|
|
52201
|
+
var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
|
|
52202
|
+
// outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
|
|
52203
|
+
// second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
|
|
52204
|
+
// inner conditional runs the check the user provided on the check type (distributively) and returns the result
|
|
52205
|
+
// checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
|
|
52206
|
+
// this is potentially simplifiable to
|
|
52207
|
+
// checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52208
|
+
// but that may confuse users who read the output more.
|
|
52209
|
+
// On the other hand,
|
|
52210
|
+
// checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52211
|
+
// may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
|
|
52212
|
+
return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
|
|
52213
|
+
}
|
|
52188
52214
|
var saveInferTypeParameters = context.inferTypeParameters;
|
|
52189
52215
|
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52190
52216
|
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
|
|
52191
52217
|
context.inferTypeParameters = saveInferTypeParameters;
|
|
52192
52218
|
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
|
|
52193
52219
|
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
|
|
52194
|
-
context.approximateLength += 15;
|
|
52195
52220
|
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
|
|
52196
52221
|
}
|
|
52197
52222
|
function typeToTypeNodeOrCircularityElision(type) {
|
|
@@ -76694,7 +76719,7 @@ var ts;
|
|
|
76694
76719
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
76695
76720
|
newSymbol.parent = originalSymbol;
|
|
76696
76721
|
newSymbol.nameType = getStringLiteralType("default");
|
|
76697
|
-
newSymbol.
|
|
76722
|
+
newSymbol.aliasTarget = resolveSymbol(symbol);
|
|
76698
76723
|
memberTable.set("default" /* Default */, newSymbol);
|
|
76699
76724
|
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
76700
76725
|
}
|
|
@@ -79508,14 +79533,19 @@ var ts;
|
|
|
79508
79533
|
}
|
|
79509
79534
|
if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
|
|
79510
79535
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79511
|
-
if (modifiers
|
|
79536
|
+
if (modifiers) {
|
|
79512
79537
|
var symbol = getSymbolOfNode(node.parent);
|
|
79513
|
-
|
|
79514
|
-
|
|
79515
|
-
|
|
79516
|
-
|
|
79517
|
-
|
|
79518
|
-
|
|
79538
|
+
if (node.parent.kind === 259 /* TypeAliasDeclaration */ && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79539
|
+
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79540
|
+
}
|
|
79541
|
+
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
79542
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
|
|
79543
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
|
|
79544
|
+
var saveVarianceTypeParameter = typeParameter;
|
|
79545
|
+
varianceTypeParameter = typeParameter;
|
|
79546
|
+
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
79547
|
+
varianceTypeParameter = saveVarianceTypeParameter;
|
|
79548
|
+
}
|
|
79519
79549
|
}
|
|
79520
79550
|
}
|
|
79521
79551
|
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
@@ -86175,11 +86205,11 @@ var ts;
|
|
|
86175
86205
|
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
|
|
86176
86206
|
return leftSpread ? [leftSpread, rightSpread]
|
|
86177
86207
|
: syntheticOrigin ? [syntheticOrigin]
|
|
86178
|
-
: ts.singleElementArray(
|
|
86208
|
+
: ts.singleElementArray(tryGetTarget(symbol));
|
|
86179
86209
|
}
|
|
86180
86210
|
return undefined;
|
|
86181
86211
|
}
|
|
86182
|
-
function
|
|
86212
|
+
function tryGetTarget(symbol) {
|
|
86183
86213
|
var target;
|
|
86184
86214
|
var next = symbol;
|
|
86185
86215
|
while (next = getSymbolLinks(next).target) {
|
|
@@ -86409,7 +86439,7 @@ var ts;
|
|
|
86409
86439
|
if (links === null || links === void 0 ? void 0 : links.referenced) {
|
|
86410
86440
|
return true;
|
|
86411
86441
|
}
|
|
86412
|
-
var target = getSymbolLinks(symbol).
|
|
86442
|
+
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
86413
86443
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
|
|
86414
86444
|
target.flags & 111551 /* Value */ &&
|
|
86415
86445
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
@@ -108405,6 +108435,10 @@ var ts;
|
|
|
108405
108435
|
return factory.updateModifiers(statement, modifiers);
|
|
108406
108436
|
}
|
|
108407
108437
|
function transformTopLevelDeclaration(input) {
|
|
108438
|
+
if (lateMarkedStatements) {
|
|
108439
|
+
while (ts.orderedRemoveItem(lateMarkedStatements, input))
|
|
108440
|
+
;
|
|
108441
|
+
}
|
|
108408
108442
|
if (shouldStripInternal(input))
|
|
108409
108443
|
return;
|
|
108410
108444
|
switch (input.kind) {
|
|
@@ -158843,6 +158877,7 @@ var ts;
|
|
|
158843
158877
|
Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
|
158844
158878
|
Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
|
158845
158879
|
Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
|
|
158880
|
+
Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
|
|
158846
158881
|
})(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
|
|
158847
158882
|
var RangeFacts;
|
|
158848
158883
|
(function (RangeFacts) {
|
|
@@ -158851,10 +158886,11 @@ var ts;
|
|
|
158851
158886
|
RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
|
|
158852
158887
|
RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
|
|
158853
158888
|
RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
|
|
158889
|
+
RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
|
|
158854
158890
|
/**
|
|
158855
158891
|
* The range is in a function which needs the 'static' modifier in a class
|
|
158856
158892
|
*/
|
|
158857
|
-
RangeFacts[RangeFacts["InStaticRegion"] =
|
|
158893
|
+
RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
|
|
158858
158894
|
})(RangeFacts || (RangeFacts = {}));
|
|
158859
158895
|
/**
|
|
158860
158896
|
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
|
|
@@ -158885,6 +158921,7 @@ var ts;
|
|
|
158885
158921
|
// We'll modify these flags as we walk the tree to collect data
|
|
158886
158922
|
// about what things need to be done as part of the extraction.
|
|
158887
158923
|
var rangeFacts = RangeFacts.None;
|
|
158924
|
+
var thisNode;
|
|
158888
158925
|
if (!start || !end) {
|
|
158889
158926
|
// cannot find either start or end node
|
|
158890
158927
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
@@ -158923,7 +158960,7 @@ var ts;
|
|
|
158923
158960
|
// the expression.
|
|
158924
158961
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
158925
158962
|
}
|
|
158926
|
-
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
|
|
158963
|
+
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
|
|
158927
158964
|
}
|
|
158928
158965
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
158929
158966
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -158935,7 +158972,7 @@ var ts;
|
|
|
158935
158972
|
if (errors) {
|
|
158936
158973
|
return { errors: errors };
|
|
158937
158974
|
}
|
|
158938
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
|
|
158975
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
|
|
158939
158976
|
/**
|
|
158940
158977
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
158941
158978
|
* @param node The unrefined extraction node.
|
|
@@ -159027,6 +159064,14 @@ var ts;
|
|
|
159027
159064
|
var permittedJumps = 4 /* Return */;
|
|
159028
159065
|
var seenLabels;
|
|
159029
159066
|
visit(nodeToCheck);
|
|
159067
|
+
if (rangeFacts & RangeFacts.UsesThis) {
|
|
159068
|
+
var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
|
|
159069
|
+
if (container.kind === 256 /* FunctionDeclaration */ ||
|
|
159070
|
+
(container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) ||
|
|
159071
|
+
container.kind === 213 /* FunctionExpression */) {
|
|
159072
|
+
rangeFacts |= RangeFacts.UsesThisInFunction;
|
|
159073
|
+
}
|
|
159074
|
+
}
|
|
159030
159075
|
return errors;
|
|
159031
159076
|
function visit(node) {
|
|
159032
159077
|
if (errors) {
|
|
@@ -159065,6 +159110,7 @@ var ts;
|
|
|
159065
159110
|
}
|
|
159066
159111
|
else {
|
|
159067
159112
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159113
|
+
thisNode = node;
|
|
159068
159114
|
}
|
|
159069
159115
|
break;
|
|
159070
159116
|
case 214 /* ArrowFunction */:
|
|
@@ -159072,6 +159118,7 @@ var ts;
|
|
|
159072
159118
|
ts.forEachChild(node, function check(n) {
|
|
159073
159119
|
if (ts.isThis(n)) {
|
|
159074
159120
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159121
|
+
thisNode = node;
|
|
159075
159122
|
}
|
|
159076
159123
|
else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
|
|
159077
159124
|
return false;
|
|
@@ -159128,6 +159175,7 @@ var ts;
|
|
|
159128
159175
|
case 192 /* ThisType */:
|
|
159129
159176
|
case 108 /* ThisKeyword */:
|
|
159130
159177
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159178
|
+
thisNode = node;
|
|
159131
159179
|
break;
|
|
159132
159180
|
case 250 /* LabeledStatement */: {
|
|
159133
159181
|
var label = node.label;
|
|
@@ -159215,7 +159263,7 @@ var ts;
|
|
|
159215
159263
|
*/
|
|
159216
159264
|
function collectEnclosingScopes(range) {
|
|
159217
159265
|
var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
|
|
159218
|
-
if (range.facts & RangeFacts.UsesThis) {
|
|
159266
|
+
if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
|
|
159219
159267
|
// if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class
|
|
159220
159268
|
var containingClass = ts.getContainingClass(current);
|
|
159221
159269
|
if (containingClass) {
|
|
@@ -159421,6 +159469,7 @@ var ts;
|
|
|
159421
159469
|
var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
|
|
159422
159470
|
ts.suppressLeadingAndTrailingTrivia(body);
|
|
159423
159471
|
var newFunction;
|
|
159472
|
+
var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
|
|
159424
159473
|
if (ts.isClassLike(scope)) {
|
|
159425
159474
|
// always create private method in TypeScript files
|
|
159426
159475
|
var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
|
|
@@ -159435,6 +159484,15 @@ var ts;
|
|
|
159435
159484
|
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
|
|
159436
159485
|
}
|
|
159437
159486
|
else {
|
|
159487
|
+
if (callThis) {
|
|
159488
|
+
parameters.unshift(ts.factory.createParameterDeclaration(
|
|
159489
|
+
/*decorators*/ undefined,
|
|
159490
|
+
/*modifiers*/ undefined,
|
|
159491
|
+
/*dotDotDotToken*/ undefined,
|
|
159492
|
+
/*name*/ "this",
|
|
159493
|
+
/*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */),
|
|
159494
|
+
/*initializer*/ undefined));
|
|
159495
|
+
}
|
|
159438
159496
|
newFunction = ts.factory.createFunctionDeclaration(
|
|
159439
159497
|
/*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body);
|
|
159440
159498
|
}
|
|
@@ -159451,7 +159509,10 @@ var ts;
|
|
|
159451
159509
|
var newNodes = [];
|
|
159452
159510
|
// replace range with function call
|
|
159453
159511
|
var called = getCalledExpression(scope, range, functionNameText);
|
|
159454
|
-
|
|
159512
|
+
if (callThis) {
|
|
159513
|
+
callArguments.unshift(ts.factory.createIdentifier("this"));
|
|
159514
|
+
}
|
|
159515
|
+
var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference
|
|
159455
159516
|
callArguments);
|
|
159456
159517
|
if (range.facts & RangeFacts.IsGenerator) {
|
|
159457
159518
|
call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
|
|
@@ -160062,6 +160123,9 @@ var ts;
|
|
|
160062
160123
|
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
|
|
160063
160124
|
constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
|
|
160064
160125
|
}
|
|
160126
|
+
if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
|
|
160127
|
+
functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
|
|
160128
|
+
}
|
|
160065
160129
|
var hasWrite = false;
|
|
160066
160130
|
var readonlyClassPropertyWrite;
|
|
160067
160131
|
usagesPerScope[i].usages.forEach(function (value) {
|