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/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220408";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8911,6 +8911,7 @@ var ts;
|
|
|
8911
8911
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8912
8912
|
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."),
|
|
8913
8913
|
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."),
|
|
8914
|
+
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."),
|
|
8914
8915
|
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."),
|
|
8915
8916
|
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."),
|
|
8916
8917
|
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."),
|
|
@@ -45966,6 +45967,7 @@ var ts;
|
|
|
45966
45967
|
case 261 /* ModuleDeclaration */:
|
|
45967
45968
|
case 259 /* TypeAliasDeclaration */:
|
|
45968
45969
|
case 195 /* MappedType */:
|
|
45970
|
+
case 176 /* IndexSignature */:
|
|
45969
45971
|
return 1 /* IsContainer */ | 32 /* HasLocals */;
|
|
45970
45972
|
case 305 /* SourceFile */:
|
|
45971
45973
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */;
|
|
@@ -45984,7 +45986,6 @@ var ts;
|
|
|
45984
45986
|
case 317 /* JSDocFunctionType */:
|
|
45985
45987
|
case 179 /* FunctionType */:
|
|
45986
45988
|
case 175 /* ConstructSignature */:
|
|
45987
|
-
case 176 /* IndexSignature */:
|
|
45988
45989
|
case 180 /* ConstructorType */:
|
|
45989
45990
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
45990
45991
|
return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */;
|
|
@@ -50562,27 +50563,27 @@ var ts;
|
|
|
50562
50563
|
function resolveAlias(symbol) {
|
|
50563
50564
|
ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
50564
50565
|
var links = getSymbolLinks(symbol);
|
|
50565
|
-
if (!links.
|
|
50566
|
-
links.
|
|
50566
|
+
if (!links.aliasTarget) {
|
|
50567
|
+
links.aliasTarget = resolvingSymbol;
|
|
50567
50568
|
var node = getDeclarationOfAliasSymbol(symbol);
|
|
50568
50569
|
if (!node)
|
|
50569
50570
|
return ts.Debug.fail();
|
|
50570
50571
|
var target = getTargetOfAliasDeclaration(node);
|
|
50571
|
-
if (links.
|
|
50572
|
-
links.
|
|
50572
|
+
if (links.aliasTarget === resolvingSymbol) {
|
|
50573
|
+
links.aliasTarget = target || unknownSymbol;
|
|
50573
50574
|
}
|
|
50574
50575
|
else {
|
|
50575
50576
|
error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
|
|
50576
50577
|
}
|
|
50577
50578
|
}
|
|
50578
|
-
else if (links.
|
|
50579
|
-
links.
|
|
50579
|
+
else if (links.aliasTarget === resolvingSymbol) {
|
|
50580
|
+
links.aliasTarget = unknownSymbol;
|
|
50580
50581
|
}
|
|
50581
|
-
return links.
|
|
50582
|
+
return links.aliasTarget;
|
|
50582
50583
|
}
|
|
50583
50584
|
function tryResolveAlias(symbol) {
|
|
50584
50585
|
var links = getSymbolLinks(symbol);
|
|
50585
|
-
if (links.
|
|
50586
|
+
if (links.aliasTarget !== resolvingSymbol) {
|
|
50586
50587
|
return resolveAlias(symbol);
|
|
50587
50588
|
}
|
|
50588
50589
|
return undefined;
|
|
@@ -52379,13 +52380,37 @@ var ts;
|
|
|
52379
52380
|
return ts.Debug.fail("Should be unreachable.");
|
|
52380
52381
|
function conditionalTypeToTypeNode(type) {
|
|
52381
52382
|
var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
|
|
52383
|
+
context.approximateLength += 15;
|
|
52384
|
+
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
52385
|
+
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52386
|
+
var name = typeParameterToName(newParam, context);
|
|
52387
|
+
var newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
52388
|
+
context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type
|
|
52389
|
+
var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper);
|
|
52390
|
+
var saveInferTypeParameters_1 = context.inferTypeParameters;
|
|
52391
|
+
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52392
|
+
var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context);
|
|
52393
|
+
context.inferTypeParameters = saveInferTypeParameters_1;
|
|
52394
|
+
var trueTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.trueType), newMapper));
|
|
52395
|
+
var falseTypeNode_1 = typeToTypeNodeOrCircularityElision(instantiateType(getTypeFromTypeNode(type.root.node.falseType), newMapper));
|
|
52396
|
+
// outermost conditional makes `T` a type parameter, allowing the inner conditionals to be distributive
|
|
52397
|
+
// second conditional makes `T` have `T & checkType` substitution, so it is correctly usable as the checkType
|
|
52398
|
+
// inner conditional runs the check the user provided on the check type (distributively) and returns the result
|
|
52399
|
+
// checkType extends infer T ? T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never : never;
|
|
52400
|
+
// this is potentially simplifiable to
|
|
52401
|
+
// checkType extends infer T ? T extends checkType & extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52402
|
+
// but that may confuse users who read the output more.
|
|
52403
|
+
// On the other hand,
|
|
52404
|
+
// checkType extends infer T extends checkType ? T extends extendsType<T> ? trueType<T> : falseType<T> : never;
|
|
52405
|
+
// may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS.
|
|
52406
|
+
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 */));
|
|
52407
|
+
}
|
|
52382
52408
|
var saveInferTypeParameters = context.inferTypeParameters;
|
|
52383
52409
|
context.inferTypeParameters = type.root.inferTypeParameters;
|
|
52384
52410
|
var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
|
|
52385
52411
|
context.inferTypeParameters = saveInferTypeParameters;
|
|
52386
52412
|
var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
|
|
52387
52413
|
var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
|
|
52388
|
-
context.approximateLength += 15;
|
|
52389
52414
|
return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
|
|
52390
52415
|
}
|
|
52391
52416
|
function typeToTypeNodeOrCircularityElision(type) {
|
|
@@ -76888,7 +76913,7 @@ var ts;
|
|
|
76888
76913
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
76889
76914
|
newSymbol.parent = originalSymbol;
|
|
76890
76915
|
newSymbol.nameType = getStringLiteralType("default");
|
|
76891
|
-
newSymbol.
|
|
76916
|
+
newSymbol.aliasTarget = resolveSymbol(symbol);
|
|
76892
76917
|
memberTable.set("default" /* Default */, newSymbol);
|
|
76893
76918
|
return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
76894
76919
|
}
|
|
@@ -79702,14 +79727,19 @@ var ts;
|
|
|
79702
79727
|
}
|
|
79703
79728
|
if (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 257 /* ClassDeclaration */ || node.parent.kind === 259 /* TypeAliasDeclaration */) {
|
|
79704
79729
|
var modifiers = getVarianceModifiers(typeParameter);
|
|
79705
|
-
if (modifiers
|
|
79730
|
+
if (modifiers) {
|
|
79706
79731
|
var symbol = getSymbolOfNode(node.parent);
|
|
79707
|
-
|
|
79708
|
-
|
|
79709
|
-
|
|
79710
|
-
|
|
79711
|
-
|
|
79712
|
-
|
|
79732
|
+
if (node.parent.kind === 259 /* TypeAliasDeclaration */ && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) {
|
|
79733
|
+
error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
|
79734
|
+
}
|
|
79735
|
+
else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
|
|
79736
|
+
var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType);
|
|
79737
|
+
var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType);
|
|
79738
|
+
var saveVarianceTypeParameter = typeParameter;
|
|
79739
|
+
varianceTypeParameter = typeParameter;
|
|
79740
|
+
checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
|
79741
|
+
varianceTypeParameter = saveVarianceTypeParameter;
|
|
79742
|
+
}
|
|
79713
79743
|
}
|
|
79714
79744
|
}
|
|
79715
79745
|
addLazyDiagnostic(function () { return checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); });
|
|
@@ -86369,11 +86399,11 @@ var ts;
|
|
|
86369
86399
|
var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
|
|
86370
86400
|
return leftSpread ? [leftSpread, rightSpread]
|
|
86371
86401
|
: syntheticOrigin ? [syntheticOrigin]
|
|
86372
|
-
: ts.singleElementArray(
|
|
86402
|
+
: ts.singleElementArray(tryGetTarget(symbol));
|
|
86373
86403
|
}
|
|
86374
86404
|
return undefined;
|
|
86375
86405
|
}
|
|
86376
|
-
function
|
|
86406
|
+
function tryGetTarget(symbol) {
|
|
86377
86407
|
var target;
|
|
86378
86408
|
var next = symbol;
|
|
86379
86409
|
while (next = getSymbolLinks(next).target) {
|
|
@@ -86603,7 +86633,7 @@ var ts;
|
|
|
86603
86633
|
if (links === null || links === void 0 ? void 0 : links.referenced) {
|
|
86604
86634
|
return true;
|
|
86605
86635
|
}
|
|
86606
|
-
var target = getSymbolLinks(symbol).
|
|
86636
|
+
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
86607
86637
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ &&
|
|
86608
86638
|
target.flags & 111551 /* Value */ &&
|
|
86609
86639
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
@@ -108599,6 +108629,10 @@ var ts;
|
|
|
108599
108629
|
return factory.updateModifiers(statement, modifiers);
|
|
108600
108630
|
}
|
|
108601
108631
|
function transformTopLevelDeclaration(input) {
|
|
108632
|
+
if (lateMarkedStatements) {
|
|
108633
|
+
while (ts.orderedRemoveItem(lateMarkedStatements, input))
|
|
108634
|
+
;
|
|
108635
|
+
}
|
|
108602
108636
|
if (shouldStripInternal(input))
|
|
108603
108637
|
return;
|
|
108604
108638
|
switch (input.kind) {
|
|
@@ -159454,6 +159488,7 @@ var ts;
|
|
|
159454
159488
|
Messages.cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
|
159455
159489
|
Messages.cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
|
159456
159490
|
Messages.cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
|
|
159491
|
+
Messages.cannotExtractFunctionsContainingThisToMethod = createMessage("Cannot extract functions containing this to method");
|
|
159457
159492
|
})(Messages = extractSymbol.Messages || (extractSymbol.Messages = {}));
|
|
159458
159493
|
var RangeFacts;
|
|
159459
159494
|
(function (RangeFacts) {
|
|
@@ -159462,10 +159497,11 @@ var ts;
|
|
|
159462
159497
|
RangeFacts[RangeFacts["IsGenerator"] = 2] = "IsGenerator";
|
|
159463
159498
|
RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction";
|
|
159464
159499
|
RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis";
|
|
159500
|
+
RangeFacts[RangeFacts["UsesThisInFunction"] = 16] = "UsesThisInFunction";
|
|
159465
159501
|
/**
|
|
159466
159502
|
* The range is in a function which needs the 'static' modifier in a class
|
|
159467
159503
|
*/
|
|
159468
|
-
RangeFacts[RangeFacts["InStaticRegion"] =
|
|
159504
|
+
RangeFacts[RangeFacts["InStaticRegion"] = 32] = "InStaticRegion";
|
|
159469
159505
|
})(RangeFacts || (RangeFacts = {}));
|
|
159470
159506
|
/**
|
|
159471
159507
|
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
|
|
@@ -159496,6 +159532,7 @@ var ts;
|
|
|
159496
159532
|
// We'll modify these flags as we walk the tree to collect data
|
|
159497
159533
|
// about what things need to be done as part of the extraction.
|
|
159498
159534
|
var rangeFacts = RangeFacts.None;
|
|
159535
|
+
var thisNode;
|
|
159499
159536
|
if (!start || !end) {
|
|
159500
159537
|
// cannot find either start or end node
|
|
159501
159538
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
@@ -159534,7 +159571,7 @@ var ts;
|
|
|
159534
159571
|
// the expression.
|
|
159535
159572
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
159536
159573
|
}
|
|
159537
|
-
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } };
|
|
159574
|
+
return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations, thisNode: thisNode } };
|
|
159538
159575
|
}
|
|
159539
159576
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
159540
159577
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -159546,7 +159583,7 @@ var ts;
|
|
|
159546
159583
|
if (errors) {
|
|
159547
159584
|
return { errors: errors };
|
|
159548
159585
|
}
|
|
159549
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217
|
|
159586
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations, thisNode: thisNode } }; // TODO: GH#18217
|
|
159550
159587
|
/**
|
|
159551
159588
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
159552
159589
|
* @param node The unrefined extraction node.
|
|
@@ -159638,6 +159675,14 @@ var ts;
|
|
|
159638
159675
|
var permittedJumps = 4 /* Return */;
|
|
159639
159676
|
var seenLabels;
|
|
159640
159677
|
visit(nodeToCheck);
|
|
159678
|
+
if (rangeFacts & RangeFacts.UsesThis) {
|
|
159679
|
+
var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false);
|
|
159680
|
+
if (container.kind === 256 /* FunctionDeclaration */ ||
|
|
159681
|
+
(container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) ||
|
|
159682
|
+
container.kind === 213 /* FunctionExpression */) {
|
|
159683
|
+
rangeFacts |= RangeFacts.UsesThisInFunction;
|
|
159684
|
+
}
|
|
159685
|
+
}
|
|
159641
159686
|
return errors;
|
|
159642
159687
|
function visit(node) {
|
|
159643
159688
|
if (errors) {
|
|
@@ -159676,6 +159721,7 @@ var ts;
|
|
|
159676
159721
|
}
|
|
159677
159722
|
else {
|
|
159678
159723
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159724
|
+
thisNode = node;
|
|
159679
159725
|
}
|
|
159680
159726
|
break;
|
|
159681
159727
|
case 214 /* ArrowFunction */:
|
|
@@ -159683,6 +159729,7 @@ var ts;
|
|
|
159683
159729
|
ts.forEachChild(node, function check(n) {
|
|
159684
159730
|
if (ts.isThis(n)) {
|
|
159685
159731
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159732
|
+
thisNode = node;
|
|
159686
159733
|
}
|
|
159687
159734
|
else if (ts.isClassLike(n) || (ts.isFunctionLike(n) && !ts.isArrowFunction(n))) {
|
|
159688
159735
|
return false;
|
|
@@ -159739,6 +159786,7 @@ var ts;
|
|
|
159739
159786
|
case 192 /* ThisType */:
|
|
159740
159787
|
case 108 /* ThisKeyword */:
|
|
159741
159788
|
rangeFacts |= RangeFacts.UsesThis;
|
|
159789
|
+
thisNode = node;
|
|
159742
159790
|
break;
|
|
159743
159791
|
case 250 /* LabeledStatement */: {
|
|
159744
159792
|
var label = node.label;
|
|
@@ -159826,7 +159874,7 @@ var ts;
|
|
|
159826
159874
|
*/
|
|
159827
159875
|
function collectEnclosingScopes(range) {
|
|
159828
159876
|
var current = isReadonlyArray(range.range) ? ts.first(range.range) : range.range;
|
|
159829
|
-
if (range.facts & RangeFacts.UsesThis) {
|
|
159877
|
+
if (range.facts & RangeFacts.UsesThis && !(range.facts & RangeFacts.UsesThisInFunction)) {
|
|
159830
159878
|
// 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
|
|
159831
159879
|
var containingClass = ts.getContainingClass(current);
|
|
159832
159880
|
if (containingClass) {
|
|
@@ -160032,6 +160080,7 @@ var ts;
|
|
|
160032
160080
|
var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty;
|
|
160033
160081
|
ts.suppressLeadingAndTrailingTrivia(body);
|
|
160034
160082
|
var newFunction;
|
|
160083
|
+
var callThis = !!(range.facts & RangeFacts.UsesThisInFunction);
|
|
160035
160084
|
if (ts.isClassLike(scope)) {
|
|
160036
160085
|
// always create private method in TypeScript files
|
|
160037
160086
|
var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)];
|
|
@@ -160046,6 +160095,15 @@ var ts;
|
|
|
160046
160095
|
/*questionToken*/ undefined, typeParameters, parameters, returnType, body);
|
|
160047
160096
|
}
|
|
160048
160097
|
else {
|
|
160098
|
+
if (callThis) {
|
|
160099
|
+
parameters.unshift(ts.factory.createParameterDeclaration(
|
|
160100
|
+
/*decorators*/ undefined,
|
|
160101
|
+
/*modifiers*/ undefined,
|
|
160102
|
+
/*dotDotDotToken*/ undefined,
|
|
160103
|
+
/*name*/ "this",
|
|
160104
|
+
/*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */),
|
|
160105
|
+
/*initializer*/ undefined));
|
|
160106
|
+
}
|
|
160049
160107
|
newFunction = ts.factory.createFunctionDeclaration(
|
|
160050
160108
|
/*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);
|
|
160051
160109
|
}
|
|
@@ -160062,7 +160120,10 @@ var ts;
|
|
|
160062
160120
|
var newNodes = [];
|
|
160063
160121
|
// replace range with function call
|
|
160064
160122
|
var called = getCalledExpression(scope, range, functionNameText);
|
|
160065
|
-
|
|
160123
|
+
if (callThis) {
|
|
160124
|
+
callArguments.unshift(ts.factory.createIdentifier("this"));
|
|
160125
|
+
}
|
|
160126
|
+
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
|
|
160066
160127
|
callArguments);
|
|
160067
160128
|
if (range.facts & RangeFacts.IsGenerator) {
|
|
160068
160129
|
call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call);
|
|
@@ -160673,6 +160734,9 @@ var ts;
|
|
|
160673
160734
|
var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range;
|
|
160674
160735
|
constantErrorsPerScope[i].push(ts.createDiagnosticForNode(errorNode, Messages.cannotAccessVariablesFromNestedScopes));
|
|
160675
160736
|
}
|
|
160737
|
+
if (targetRange.facts & RangeFacts.UsesThisInFunction && ts.isClassLike(scopes[i])) {
|
|
160738
|
+
functionErrorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.thisNode, Messages.cannotExtractFunctionsContainingThisToMethod));
|
|
160739
|
+
}
|
|
160676
160740
|
var hasWrite = false;
|
|
160677
160741
|
var readonlyClassPropertyWrite;
|
|
160678
160742
|
usagesPerScope[i].usages.forEach(function (value) {
|