@typescript-deploys/pr-build 5.3.0-pr-56122-13 → 5.3.0-pr-56131-2
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 +4 -4
- package/lib/tsserver.js +139 -52
- package/lib/typescript.js +139 -52
- package/lib/typingsInstaller.js +3 -3
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -13878,9 +13878,9 @@ function ownsJSDocTag(hostNode, tag) {
|
|
|
13878
13878
|
}
|
|
13879
13879
|
function getNextJSDocCommentLocation(node) {
|
|
13880
13880
|
const parent = node.parent;
|
|
13881
|
-
if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) ||
|
|
13881
|
+
if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || isAssignmentExpression(node)) {
|
|
13882
13882
|
return parent;
|
|
13883
|
-
} else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node ||
|
|
13883
|
+
} else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || isAssignmentExpression(parent))) {
|
|
13884
13884
|
return parent.parent;
|
|
13885
13885
|
} else if (parent.parent && parent.parent.parent && (getSingleVariableOfVariableStatement(parent.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || getSourceOfDefaultedAssignment(parent.parent.parent))) {
|
|
13886
13886
|
return parent.parent.parent;
|
|
@@ -34843,7 +34843,7 @@ var commandOptionsWithoutBuild = [
|
|
|
34843
34843
|
affectsBuildInfo: true,
|
|
34844
34844
|
affectsDeclarationPath: true,
|
|
34845
34845
|
isFilePath: false,
|
|
34846
|
-
// This is intentionally broken to support
|
|
34846
|
+
// This is intentionally broken to support compatibility with existing tsconfig files
|
|
34847
34847
|
// for correct behaviour, please use outFile
|
|
34848
34848
|
category: Diagnostics.Backwards_Compatibility,
|
|
34849
34849
|
paramType: Diagnostics.FILE,
|
|
@@ -67350,7 +67350,7 @@ function createTypeChecker(host) {
|
|
|
67350
67350
|
return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
|
|
67351
67351
|
}
|
|
67352
67352
|
const parent = walkUpParenthesizedExpressions(func.parent);
|
|
67353
|
-
if (parent
|
|
67353
|
+
if (isAssignmentExpression(parent)) {
|
|
67354
67354
|
const target = parent.left;
|
|
67355
67355
|
if (isAccessExpression(target)) {
|
|
67356
67356
|
const { expression } = target;
|
package/lib/tsserver.js
CHANGED
|
@@ -17745,9 +17745,9 @@ function ownsJSDocTag(hostNode, tag) {
|
|
|
17745
17745
|
}
|
|
17746
17746
|
function getNextJSDocCommentLocation(node) {
|
|
17747
17747
|
const parent2 = node.parent;
|
|
17748
|
-
if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) ||
|
|
17748
|
+
if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) || isAssignmentExpression(node)) {
|
|
17749
17749
|
return parent2;
|
|
17750
|
-
} else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node ||
|
|
17750
|
+
} else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node || isAssignmentExpression(parent2))) {
|
|
17751
17751
|
return parent2.parent;
|
|
17752
17752
|
} else if (parent2.parent && parent2.parent.parent && (getSingleVariableOfVariableStatement(parent2.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent2.parent.parent) === node || getSourceOfDefaultedAssignment(parent2.parent.parent))) {
|
|
17753
17753
|
return parent2.parent.parent;
|
|
@@ -39247,7 +39247,7 @@ var commandOptionsWithoutBuild = [
|
|
|
39247
39247
|
affectsBuildInfo: true,
|
|
39248
39248
|
affectsDeclarationPath: true,
|
|
39249
39249
|
isFilePath: false,
|
|
39250
|
-
// This is intentionally broken to support
|
|
39250
|
+
// This is intentionally broken to support compatibility with existing tsconfig files
|
|
39251
39251
|
// for correct behaviour, please use outFile
|
|
39252
39252
|
category: Diagnostics.Backwards_Compatibility,
|
|
39253
39253
|
paramType: Diagnostics.FILE,
|
|
@@ -72062,7 +72062,7 @@ function createTypeChecker(host) {
|
|
|
72062
72062
|
return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
|
|
72063
72063
|
}
|
|
72064
72064
|
const parent2 = walkUpParenthesizedExpressions(func.parent);
|
|
72065
|
-
if (parent2
|
|
72065
|
+
if (isAssignmentExpression(parent2)) {
|
|
72066
72066
|
const target = parent2.left;
|
|
72067
72067
|
if (isAccessExpression(target)) {
|
|
72068
72068
|
const { expression } = target;
|
|
@@ -138605,26 +138605,46 @@ function getRangeToExtract(context, considerEmptySpans = true) {
|
|
|
138605
138605
|
const current = getTokenAtPosition(file, startPosition);
|
|
138606
138606
|
const range = createTextRangeFromSpan(getRefactorContextSpan(context));
|
|
138607
138607
|
const cursorRequest = range.pos === range.end && considerEmptySpans;
|
|
138608
|
-
const
|
|
138609
|
-
if (!
|
|
138608
|
+
const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || nodeOverlapsWithStartEnd(current, file, range.pos, range.end)));
|
|
138609
|
+
if (!firstType || !isTypeNode(firstType))
|
|
138610
138610
|
return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
|
|
138611
138611
|
const checker = context.program.getTypeChecker();
|
|
138612
|
-
const enclosingNode = getEnclosingNode(
|
|
138612
|
+
const enclosingNode = getEnclosingNode(firstType, isJS);
|
|
138613
138613
|
if (enclosingNode === void 0)
|
|
138614
138614
|
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
138615
|
+
const typeList = [];
|
|
138616
|
+
if ((isUnionTypeNode(firstType.parent) || isIntersectionTypeNode(firstType.parent)) && range.end > firstType.end) {
|
|
138617
|
+
addRange(
|
|
138618
|
+
typeList,
|
|
138619
|
+
firstType.parent.types.filter((type) => {
|
|
138620
|
+
return type.getStart() >= range.pos && type.getEnd() <= range.end;
|
|
138621
|
+
})
|
|
138622
|
+
);
|
|
138623
|
+
}
|
|
138624
|
+
const selection = typeList.length > 1 ? typeList : firstType;
|
|
138615
138625
|
const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file);
|
|
138616
138626
|
if (!typeParameters)
|
|
138617
138627
|
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
138618
138628
|
const typeElements = flattenTypeLiteralNodeReference(checker, selection);
|
|
138619
138629
|
return { isJS, selection, enclosingNode, typeParameters, typeElements };
|
|
138620
138630
|
}
|
|
138621
|
-
function flattenTypeLiteralNodeReference(checker,
|
|
138622
|
-
if (!
|
|
138631
|
+
function flattenTypeLiteralNodeReference(checker, selection) {
|
|
138632
|
+
if (!selection)
|
|
138623
138633
|
return void 0;
|
|
138624
|
-
if (
|
|
138634
|
+
if (isArray(selection)) {
|
|
138635
|
+
const result = [];
|
|
138636
|
+
for (const type of selection) {
|
|
138637
|
+
const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type);
|
|
138638
|
+
if (!flattenedTypeMembers)
|
|
138639
|
+
return void 0;
|
|
138640
|
+
addRange(result, flattenedTypeMembers);
|
|
138641
|
+
}
|
|
138642
|
+
return result;
|
|
138643
|
+
}
|
|
138644
|
+
if (isIntersectionTypeNode(selection)) {
|
|
138625
138645
|
const result = [];
|
|
138626
138646
|
const seen = /* @__PURE__ */ new Map();
|
|
138627
|
-
for (const type of
|
|
138647
|
+
for (const type of selection.types) {
|
|
138628
138648
|
const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type);
|
|
138629
138649
|
if (!flattenedTypeMembers || !flattenedTypeMembers.every((type2) => type2.name && addToSeen(seen, getNameFromPropertyName(type2.name)))) {
|
|
138630
138650
|
return void 0;
|
|
@@ -138632,18 +138652,30 @@ function flattenTypeLiteralNodeReference(checker, node) {
|
|
|
138632
138652
|
addRange(result, flattenedTypeMembers);
|
|
138633
138653
|
}
|
|
138634
138654
|
return result;
|
|
138635
|
-
} else if (isParenthesizedTypeNode(
|
|
138636
|
-
return flattenTypeLiteralNodeReference(checker,
|
|
138637
|
-
} else if (isTypeLiteralNode(
|
|
138638
|
-
return
|
|
138655
|
+
} else if (isParenthesizedTypeNode(selection)) {
|
|
138656
|
+
return flattenTypeLiteralNodeReference(checker, selection.type);
|
|
138657
|
+
} else if (isTypeLiteralNode(selection)) {
|
|
138658
|
+
return selection.members;
|
|
138639
138659
|
}
|
|
138640
138660
|
return void 0;
|
|
138641
138661
|
}
|
|
138642
138662
|
function rangeContainsSkipTrivia(r1, node, file) {
|
|
138643
|
-
|
|
138663
|
+
const r1Range = arrayToNode(r1);
|
|
138664
|
+
const nodeRange = arrayToNode(node);
|
|
138665
|
+
return rangeContainsStartEnd(r1Range, skipTrivia(file.text, nodeRange.pos), nodeRange.end);
|
|
138666
|
+
function arrayToNode(rangeOrArray) {
|
|
138667
|
+
return isArray(rangeOrArray) ? { pos: rangeOrArray[0].pos, end: rangeOrArray[rangeOrArray.length - 1].end } : rangeOrArray;
|
|
138668
|
+
}
|
|
138644
138669
|
}
|
|
138645
138670
|
function collectTypeParameters(checker, selection, enclosingNode, file) {
|
|
138646
138671
|
const result = [];
|
|
138672
|
+
if (isArray(selection)) {
|
|
138673
|
+
selection.forEach((t) => {
|
|
138674
|
+
if (!visitor(t))
|
|
138675
|
+
return void 0;
|
|
138676
|
+
});
|
|
138677
|
+
return result;
|
|
138678
|
+
}
|
|
138647
138679
|
return visitor(selection) ? void 0 : result;
|
|
138648
138680
|
function visitor(node) {
|
|
138649
138681
|
if (isTypeReferenceNode(node)) {
|
|
@@ -138704,32 +138736,62 @@ function collectTypeParameters(checker, selection, enclosingNode, file) {
|
|
|
138704
138736
|
}
|
|
138705
138737
|
function doTypeAliasChange(changes, file, name, info) {
|
|
138706
138738
|
const { enclosingNode, selection, typeParameters } = info;
|
|
138707
|
-
|
|
138708
|
-
|
|
138709
|
-
|
|
138710
|
-
|
|
138711
|
-
|
|
138712
|
-
|
|
138713
|
-
id.
|
|
138739
|
+
if (isArray(selection)) {
|
|
138740
|
+
const newTypeValue = isUnionTypeNode(selection[0].parent) ? factory.createUnionTypeNode(selection) : factory.createIntersectionTypeNode(selection);
|
|
138741
|
+
const newTypeDeclaration = factory.createTypeAliasDeclaration(
|
|
138742
|
+
/*modifiers*/
|
|
138743
|
+
void 0,
|
|
138744
|
+
name,
|
|
138745
|
+
typeParameters.map((id) => factory.updateTypeParameterDeclaration(
|
|
138746
|
+
id,
|
|
138747
|
+
id.modifiers,
|
|
138748
|
+
id.name,
|
|
138749
|
+
id.constraint,
|
|
138750
|
+
/*defaultType*/
|
|
138751
|
+
void 0
|
|
138752
|
+
)),
|
|
138753
|
+
newTypeValue
|
|
138754
|
+
);
|
|
138755
|
+
changes.insertNodeBefore(
|
|
138756
|
+
file,
|
|
138757
|
+
enclosingNode,
|
|
138758
|
+
ignoreSourceNewlines(newTypeDeclaration),
|
|
138759
|
+
/*blankLineBetween*/
|
|
138760
|
+
true
|
|
138761
|
+
);
|
|
138762
|
+
changes.replaceNodeRange(file, selection[0], selection[selection.length - 1], factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
138714
138763
|
id.name,
|
|
138715
|
-
|
|
138716
|
-
/*defaultType*/
|
|
138764
|
+
/*typeArguments*/
|
|
138717
138765
|
void 0
|
|
138718
|
-
)),
|
|
138719
|
-
|
|
138720
|
-
|
|
138721
|
-
|
|
138722
|
-
|
|
138723
|
-
|
|
138724
|
-
|
|
138725
|
-
|
|
138726
|
-
|
|
138727
|
-
|
|
138728
|
-
|
|
138729
|
-
|
|
138730
|
-
|
|
138731
|
-
|
|
138732
|
-
|
|
138766
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
138767
|
+
} else {
|
|
138768
|
+
const newTypeNode = factory.createTypeAliasDeclaration(
|
|
138769
|
+
/*modifiers*/
|
|
138770
|
+
void 0,
|
|
138771
|
+
name,
|
|
138772
|
+
typeParameters.map((id) => factory.updateTypeParameterDeclaration(
|
|
138773
|
+
id,
|
|
138774
|
+
id.modifiers,
|
|
138775
|
+
id.name,
|
|
138776
|
+
id.constraint,
|
|
138777
|
+
/*defaultType*/
|
|
138778
|
+
void 0
|
|
138779
|
+
)),
|
|
138780
|
+
selection
|
|
138781
|
+
);
|
|
138782
|
+
changes.insertNodeBefore(
|
|
138783
|
+
file,
|
|
138784
|
+
enclosingNode,
|
|
138785
|
+
ignoreSourceNewlines(newTypeNode),
|
|
138786
|
+
/*blankLineBetween*/
|
|
138787
|
+
true
|
|
138788
|
+
);
|
|
138789
|
+
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
138790
|
+
id.name,
|
|
138791
|
+
/*typeArguments*/
|
|
138792
|
+
void 0
|
|
138793
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
138794
|
+
}
|
|
138733
138795
|
}
|
|
138734
138796
|
function doInterfaceChange(changes, file, name, info) {
|
|
138735
138797
|
var _a;
|
|
@@ -138751,19 +138813,36 @@ function doInterfaceChange(changes, file, name, info) {
|
|
|
138751
138813
|
/*blankLineBetween*/
|
|
138752
138814
|
true
|
|
138753
138815
|
);
|
|
138754
|
-
|
|
138755
|
-
|
|
138756
|
-
|
|
138757
|
-
|
|
138758
|
-
|
|
138816
|
+
if (isArray(selection)) {
|
|
138817
|
+
changes.replaceNodeRange(file, selection[0], selection[selection.length - 1], factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
138818
|
+
id.name,
|
|
138819
|
+
/*typeArguments*/
|
|
138820
|
+
void 0
|
|
138821
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
138822
|
+
} else {
|
|
138823
|
+
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
138824
|
+
id.name,
|
|
138825
|
+
/*typeArguments*/
|
|
138826
|
+
void 0
|
|
138827
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
138828
|
+
}
|
|
138759
138829
|
}
|
|
138760
138830
|
function doTypedefChange(changes, context, file, name, info) {
|
|
138761
138831
|
var _a;
|
|
138762
138832
|
const { enclosingNode, selection, typeParameters } = info;
|
|
138763
|
-
|
|
138833
|
+
let newTypeValue;
|
|
138834
|
+
if (isArray(selection)) {
|
|
138835
|
+
selection.forEach((typeNode) => {
|
|
138836
|
+
setEmitFlags(typeNode, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
138837
|
+
});
|
|
138838
|
+
newTypeValue = isUnionTypeNode(selection[0].parent) ? factory.createUnionTypeNode(selection) : factory.createIntersectionTypeNode(selection);
|
|
138839
|
+
} else {
|
|
138840
|
+
setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
138841
|
+
newTypeValue = selection;
|
|
138842
|
+
}
|
|
138764
138843
|
const node = factory.createJSDocTypedefTag(
|
|
138765
138844
|
factory.createIdentifier("typedef"),
|
|
138766
|
-
factory.createJSDocTypeExpression(
|
|
138845
|
+
factory.createJSDocTypeExpression(newTypeValue),
|
|
138767
138846
|
factory.createIdentifier(name)
|
|
138768
138847
|
);
|
|
138769
138848
|
const templates = [];
|
|
@@ -138801,11 +138880,19 @@ function doTypedefChange(changes, context, file, name, info) {
|
|
|
138801
138880
|
true
|
|
138802
138881
|
);
|
|
138803
138882
|
}
|
|
138804
|
-
|
|
138805
|
-
|
|
138806
|
-
|
|
138807
|
-
|
|
138808
|
-
|
|
138883
|
+
if (isArray(selection)) {
|
|
138884
|
+
changes.replaceNodeRange(file, selection[0], selection[selection.length - 1], factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
138885
|
+
id.name,
|
|
138886
|
+
/*typeArguments*/
|
|
138887
|
+
void 0
|
|
138888
|
+
))));
|
|
138889
|
+
} else {
|
|
138890
|
+
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
138891
|
+
id.name,
|
|
138892
|
+
/*typeArguments*/
|
|
138893
|
+
void 0
|
|
138894
|
+
))));
|
|
138895
|
+
}
|
|
138809
138896
|
}
|
|
138810
138897
|
function getEnclosingNode(node, isJS) {
|
|
138811
138898
|
return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0);
|
package/lib/typescript.js
CHANGED
|
@@ -15128,9 +15128,9 @@ ${lanes.join("\n")}
|
|
|
15128
15128
|
}
|
|
15129
15129
|
function getNextJSDocCommentLocation(node) {
|
|
15130
15130
|
const parent2 = node.parent;
|
|
15131
|
-
if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) ||
|
|
15131
|
+
if (parent2.kind === 303 /* PropertyAssignment */ || parent2.kind === 277 /* ExportAssignment */ || parent2.kind === 172 /* PropertyDeclaration */ || parent2.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent2.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent2) || isAssignmentExpression(node)) {
|
|
15132
15132
|
return parent2;
|
|
15133
|
-
} else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node ||
|
|
15133
|
+
} else if (parent2.parent && (getSingleVariableOfVariableStatement(parent2.parent) === node || isAssignmentExpression(parent2))) {
|
|
15134
15134
|
return parent2.parent;
|
|
15135
15135
|
} else if (parent2.parent && parent2.parent.parent && (getSingleVariableOfVariableStatement(parent2.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent2.parent.parent) === node || getSourceOfDefaultedAssignment(parent2.parent.parent))) {
|
|
15136
15136
|
return parent2.parent.parent;
|
|
@@ -38730,7 +38730,7 @@ ${lanes.join("\n")}
|
|
|
38730
38730
|
affectsBuildInfo: true,
|
|
38731
38731
|
affectsDeclarationPath: true,
|
|
38732
38732
|
isFilePath: false,
|
|
38733
|
-
// This is intentionally broken to support
|
|
38733
|
+
// This is intentionally broken to support compatibility with existing tsconfig files
|
|
38734
38734
|
// for correct behaviour, please use outFile
|
|
38735
38735
|
category: Diagnostics.Backwards_Compatibility,
|
|
38736
38736
|
paramType: Diagnostics.FILE,
|
|
@@ -69829,7 +69829,7 @@ ${lanes.join("\n")}
|
|
|
69829
69829
|
return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
|
|
69830
69830
|
}
|
|
69831
69831
|
const parent2 = walkUpParenthesizedExpressions(func.parent);
|
|
69832
|
-
if (parent2
|
|
69832
|
+
if (isAssignmentExpression(parent2)) {
|
|
69833
69833
|
const target = parent2.left;
|
|
69834
69834
|
if (isAccessExpression(target)) {
|
|
69835
69835
|
const { expression } = target;
|
|
@@ -136916,26 +136916,46 @@ ${lanes.join("\n")}
|
|
|
136916
136916
|
const current = getTokenAtPosition(file, startPosition);
|
|
136917
136917
|
const range = createTextRangeFromSpan(getRefactorContextSpan(context));
|
|
136918
136918
|
const cursorRequest = range.pos === range.end && considerEmptySpans;
|
|
136919
|
-
const
|
|
136920
|
-
if (!
|
|
136919
|
+
const firstType = findAncestor(current, (node) => node.parent && isTypeNode(node) && !rangeContainsSkipTrivia(range, node.parent, file) && (cursorRequest || nodeOverlapsWithStartEnd(current, file, range.pos, range.end)));
|
|
136920
|
+
if (!firstType || !isTypeNode(firstType))
|
|
136921
136921
|
return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
|
|
136922
136922
|
const checker = context.program.getTypeChecker();
|
|
136923
|
-
const enclosingNode = getEnclosingNode(
|
|
136923
|
+
const enclosingNode = getEnclosingNode(firstType, isJS);
|
|
136924
136924
|
if (enclosingNode === void 0)
|
|
136925
136925
|
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
136926
|
+
const typeList = [];
|
|
136927
|
+
if ((isUnionTypeNode(firstType.parent) || isIntersectionTypeNode(firstType.parent)) && range.end > firstType.end) {
|
|
136928
|
+
addRange(
|
|
136929
|
+
typeList,
|
|
136930
|
+
firstType.parent.types.filter((type) => {
|
|
136931
|
+
return type.getStart() >= range.pos && type.getEnd() <= range.end;
|
|
136932
|
+
})
|
|
136933
|
+
);
|
|
136934
|
+
}
|
|
136935
|
+
const selection = typeList.length > 1 ? typeList : firstType;
|
|
136926
136936
|
const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file);
|
|
136927
136937
|
if (!typeParameters)
|
|
136928
136938
|
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
136929
136939
|
const typeElements = flattenTypeLiteralNodeReference(checker, selection);
|
|
136930
136940
|
return { isJS, selection, enclosingNode, typeParameters, typeElements };
|
|
136931
136941
|
}
|
|
136932
|
-
function flattenTypeLiteralNodeReference(checker,
|
|
136933
|
-
if (!
|
|
136942
|
+
function flattenTypeLiteralNodeReference(checker, selection) {
|
|
136943
|
+
if (!selection)
|
|
136934
136944
|
return void 0;
|
|
136935
|
-
if (
|
|
136945
|
+
if (isArray(selection)) {
|
|
136946
|
+
const result = [];
|
|
136947
|
+
for (const type of selection) {
|
|
136948
|
+
const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type);
|
|
136949
|
+
if (!flattenedTypeMembers)
|
|
136950
|
+
return void 0;
|
|
136951
|
+
addRange(result, flattenedTypeMembers);
|
|
136952
|
+
}
|
|
136953
|
+
return result;
|
|
136954
|
+
}
|
|
136955
|
+
if (isIntersectionTypeNode(selection)) {
|
|
136936
136956
|
const result = [];
|
|
136937
136957
|
const seen = /* @__PURE__ */ new Map();
|
|
136938
|
-
for (const type of
|
|
136958
|
+
for (const type of selection.types) {
|
|
136939
136959
|
const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type);
|
|
136940
136960
|
if (!flattenedTypeMembers || !flattenedTypeMembers.every((type2) => type2.name && addToSeen(seen, getNameFromPropertyName(type2.name)))) {
|
|
136941
136961
|
return void 0;
|
|
@@ -136943,18 +136963,30 @@ ${lanes.join("\n")}
|
|
|
136943
136963
|
addRange(result, flattenedTypeMembers);
|
|
136944
136964
|
}
|
|
136945
136965
|
return result;
|
|
136946
|
-
} else if (isParenthesizedTypeNode(
|
|
136947
|
-
return flattenTypeLiteralNodeReference(checker,
|
|
136948
|
-
} else if (isTypeLiteralNode(
|
|
136949
|
-
return
|
|
136966
|
+
} else if (isParenthesizedTypeNode(selection)) {
|
|
136967
|
+
return flattenTypeLiteralNodeReference(checker, selection.type);
|
|
136968
|
+
} else if (isTypeLiteralNode(selection)) {
|
|
136969
|
+
return selection.members;
|
|
136950
136970
|
}
|
|
136951
136971
|
return void 0;
|
|
136952
136972
|
}
|
|
136953
136973
|
function rangeContainsSkipTrivia(r1, node, file) {
|
|
136954
|
-
|
|
136974
|
+
const r1Range = arrayToNode(r1);
|
|
136975
|
+
const nodeRange = arrayToNode(node);
|
|
136976
|
+
return rangeContainsStartEnd(r1Range, skipTrivia(file.text, nodeRange.pos), nodeRange.end);
|
|
136977
|
+
function arrayToNode(rangeOrArray) {
|
|
136978
|
+
return isArray(rangeOrArray) ? { pos: rangeOrArray[0].pos, end: rangeOrArray[rangeOrArray.length - 1].end } : rangeOrArray;
|
|
136979
|
+
}
|
|
136955
136980
|
}
|
|
136956
136981
|
function collectTypeParameters(checker, selection, enclosingNode, file) {
|
|
136957
136982
|
const result = [];
|
|
136983
|
+
if (isArray(selection)) {
|
|
136984
|
+
selection.forEach((t) => {
|
|
136985
|
+
if (!visitor(t))
|
|
136986
|
+
return void 0;
|
|
136987
|
+
});
|
|
136988
|
+
return result;
|
|
136989
|
+
}
|
|
136958
136990
|
return visitor(selection) ? void 0 : result;
|
|
136959
136991
|
function visitor(node) {
|
|
136960
136992
|
if (isTypeReferenceNode(node)) {
|
|
@@ -137015,32 +137047,62 @@ ${lanes.join("\n")}
|
|
|
137015
137047
|
}
|
|
137016
137048
|
function doTypeAliasChange(changes, file, name, info) {
|
|
137017
137049
|
const { enclosingNode, selection, typeParameters } = info;
|
|
137018
|
-
|
|
137019
|
-
|
|
137020
|
-
|
|
137021
|
-
|
|
137022
|
-
|
|
137023
|
-
|
|
137024
|
-
id.
|
|
137050
|
+
if (isArray(selection)) {
|
|
137051
|
+
const newTypeValue = isUnionTypeNode(selection[0].parent) ? factory.createUnionTypeNode(selection) : factory.createIntersectionTypeNode(selection);
|
|
137052
|
+
const newTypeDeclaration = factory.createTypeAliasDeclaration(
|
|
137053
|
+
/*modifiers*/
|
|
137054
|
+
void 0,
|
|
137055
|
+
name,
|
|
137056
|
+
typeParameters.map((id) => factory.updateTypeParameterDeclaration(
|
|
137057
|
+
id,
|
|
137058
|
+
id.modifiers,
|
|
137059
|
+
id.name,
|
|
137060
|
+
id.constraint,
|
|
137061
|
+
/*defaultType*/
|
|
137062
|
+
void 0
|
|
137063
|
+
)),
|
|
137064
|
+
newTypeValue
|
|
137065
|
+
);
|
|
137066
|
+
changes.insertNodeBefore(
|
|
137067
|
+
file,
|
|
137068
|
+
enclosingNode,
|
|
137069
|
+
ignoreSourceNewlines(newTypeDeclaration),
|
|
137070
|
+
/*blankLineBetween*/
|
|
137071
|
+
true
|
|
137072
|
+
);
|
|
137073
|
+
changes.replaceNodeRange(file, selection[0], selection[selection.length - 1], factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
137025
137074
|
id.name,
|
|
137026
|
-
|
|
137027
|
-
/*defaultType*/
|
|
137075
|
+
/*typeArguments*/
|
|
137028
137076
|
void 0
|
|
137029
|
-
)),
|
|
137030
|
-
|
|
137031
|
-
|
|
137032
|
-
|
|
137033
|
-
|
|
137034
|
-
|
|
137035
|
-
|
|
137036
|
-
|
|
137037
|
-
|
|
137038
|
-
|
|
137039
|
-
|
|
137040
|
-
|
|
137041
|
-
|
|
137042
|
-
|
|
137043
|
-
|
|
137077
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
137078
|
+
} else {
|
|
137079
|
+
const newTypeNode = factory.createTypeAliasDeclaration(
|
|
137080
|
+
/*modifiers*/
|
|
137081
|
+
void 0,
|
|
137082
|
+
name,
|
|
137083
|
+
typeParameters.map((id) => factory.updateTypeParameterDeclaration(
|
|
137084
|
+
id,
|
|
137085
|
+
id.modifiers,
|
|
137086
|
+
id.name,
|
|
137087
|
+
id.constraint,
|
|
137088
|
+
/*defaultType*/
|
|
137089
|
+
void 0
|
|
137090
|
+
)),
|
|
137091
|
+
selection
|
|
137092
|
+
);
|
|
137093
|
+
changes.insertNodeBefore(
|
|
137094
|
+
file,
|
|
137095
|
+
enclosingNode,
|
|
137096
|
+
ignoreSourceNewlines(newTypeNode),
|
|
137097
|
+
/*blankLineBetween*/
|
|
137098
|
+
true
|
|
137099
|
+
);
|
|
137100
|
+
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
137101
|
+
id.name,
|
|
137102
|
+
/*typeArguments*/
|
|
137103
|
+
void 0
|
|
137104
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
137105
|
+
}
|
|
137044
137106
|
}
|
|
137045
137107
|
function doInterfaceChange(changes, file, name, info) {
|
|
137046
137108
|
var _a;
|
|
@@ -137062,19 +137124,36 @@ ${lanes.join("\n")}
|
|
|
137062
137124
|
/*blankLineBetween*/
|
|
137063
137125
|
true
|
|
137064
137126
|
);
|
|
137065
|
-
|
|
137066
|
-
|
|
137067
|
-
|
|
137068
|
-
|
|
137069
|
-
|
|
137127
|
+
if (isArray(selection)) {
|
|
137128
|
+
changes.replaceNodeRange(file, selection[0], selection[selection.length - 1], factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
137129
|
+
id.name,
|
|
137130
|
+
/*typeArguments*/
|
|
137131
|
+
void 0
|
|
137132
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
137133
|
+
} else {
|
|
137134
|
+
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
137135
|
+
id.name,
|
|
137136
|
+
/*typeArguments*/
|
|
137137
|
+
void 0
|
|
137138
|
+
))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
137139
|
+
}
|
|
137070
137140
|
}
|
|
137071
137141
|
function doTypedefChange(changes, context, file, name, info) {
|
|
137072
137142
|
var _a;
|
|
137073
137143
|
const { enclosingNode, selection, typeParameters } = info;
|
|
137074
|
-
|
|
137144
|
+
let newTypeValue;
|
|
137145
|
+
if (isArray(selection)) {
|
|
137146
|
+
selection.forEach((typeNode) => {
|
|
137147
|
+
setEmitFlags(typeNode, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
137148
|
+
});
|
|
137149
|
+
newTypeValue = isUnionTypeNode(selection[0].parent) ? factory.createUnionTypeNode(selection) : factory.createIntersectionTypeNode(selection);
|
|
137150
|
+
} else {
|
|
137151
|
+
setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
137152
|
+
newTypeValue = selection;
|
|
137153
|
+
}
|
|
137075
137154
|
const node = factory.createJSDocTypedefTag(
|
|
137076
137155
|
factory.createIdentifier("typedef"),
|
|
137077
|
-
factory.createJSDocTypeExpression(
|
|
137156
|
+
factory.createJSDocTypeExpression(newTypeValue),
|
|
137078
137157
|
factory.createIdentifier(name)
|
|
137079
137158
|
);
|
|
137080
137159
|
const templates = [];
|
|
@@ -137112,11 +137191,19 @@ ${lanes.join("\n")}
|
|
|
137112
137191
|
true
|
|
137113
137192
|
);
|
|
137114
137193
|
}
|
|
137115
|
-
|
|
137116
|
-
|
|
137117
|
-
|
|
137118
|
-
|
|
137119
|
-
|
|
137194
|
+
if (isArray(selection)) {
|
|
137195
|
+
changes.replaceNodeRange(file, selection[0], selection[selection.length - 1], factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
137196
|
+
id.name,
|
|
137197
|
+
/*typeArguments*/
|
|
137198
|
+
void 0
|
|
137199
|
+
))));
|
|
137200
|
+
} else {
|
|
137201
|
+
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(
|
|
137202
|
+
id.name,
|
|
137203
|
+
/*typeArguments*/
|
|
137204
|
+
void 0
|
|
137205
|
+
))));
|
|
137206
|
+
}
|
|
137120
137207
|
}
|
|
137121
137208
|
function getEnclosingNode(node, isJS) {
|
|
137122
137209
|
return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0);
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -10593,9 +10593,9 @@ function ownsJSDocTag(hostNode, tag) {
|
|
|
10593
10593
|
}
|
|
10594
10594
|
function getNextJSDocCommentLocation(node) {
|
|
10595
10595
|
const parent = node.parent;
|
|
10596
|
-
if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) ||
|
|
10596
|
+
if (parent.kind === 303 /* PropertyAssignment */ || parent.kind === 277 /* ExportAssignment */ || parent.kind === 172 /* PropertyDeclaration */ || parent.kind === 244 /* ExpressionStatement */ && node.kind === 211 /* PropertyAccessExpression */ || parent.kind === 253 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || isAssignmentExpression(node)) {
|
|
10597
10597
|
return parent;
|
|
10598
|
-
} else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node ||
|
|
10598
|
+
} else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || isAssignmentExpression(parent))) {
|
|
10599
10599
|
return parent.parent;
|
|
10600
10600
|
} else if (parent.parent && parent.parent.parent && (getSingleVariableOfVariableStatement(parent.parent.parent) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || getSourceOfDefaultedAssignment(parent.parent.parent))) {
|
|
10601
10601
|
return parent.parent.parent;
|
|
@@ -26652,7 +26652,7 @@ var commandOptionsWithoutBuild = [
|
|
|
26652
26652
|
affectsBuildInfo: true,
|
|
26653
26653
|
affectsDeclarationPath: true,
|
|
26654
26654
|
isFilePath: false,
|
|
26655
|
-
// This is intentionally broken to support
|
|
26655
|
+
// This is intentionally broken to support compatibility with existing tsconfig files
|
|
26656
26656
|
// for correct behaviour, please use outFile
|
|
26657
26657
|
category: Diagnostics.Backwards_Compatibility,
|
|
26658
26658
|
paramType: Diagnostics.FILE,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typescript-deploys/pr-build",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.3.0-pr-
|
|
5
|
+
"version": "5.3.0-pr-56131-2",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"node": "20.1.0",
|
|
116
116
|
"npm": "8.19.4"
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "e200ac3a5a2ed19564bf2d945bff492fa5a9576f"
|
|
119
119
|
}
|