mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Remove uses of visitNodes and visitNode in visitEachChild (#49992)
This commit is contained in:
parent
6aefc1dcea
commit
966e732ed4
@ -616,7 +616,7 @@ namespace ts {
|
||||
nodeVisitor(node.argument, visitor, isTypeNode),
|
||||
nodeVisitor(node.assertions, visitor, isNode),
|
||||
nodeVisitor(node.qualifier, visitor, isEntityName),
|
||||
visitNodes(node.typeArguments, visitor, isTypeNode),
|
||||
nodesVisitor(node.typeArguments, visitor, isTypeNode),
|
||||
node.isTypeOf
|
||||
);
|
||||
|
||||
@ -630,10 +630,10 @@ namespace ts {
|
||||
case SyntaxKind.NamedTupleMember:
|
||||
Debug.type<NamedTupleMember>(node);
|
||||
return factory.updateNamedTupleMember(node,
|
||||
visitNode(node.dotDotDotToken, visitor, isDotDotDotToken),
|
||||
visitNode(node.name, visitor, isIdentifier),
|
||||
visitNode(node.questionToken, visitor, isQuestionToken),
|
||||
visitNode(node.type, visitor, isTypeNode),
|
||||
nodeVisitor(node.dotDotDotToken, visitor, isDotDotDotToken),
|
||||
nodeVisitor(node.name, visitor, isIdentifier),
|
||||
nodeVisitor(node.questionToken, visitor, isQuestionToken),
|
||||
nodeVisitor(node.type, visitor, isTypeNode),
|
||||
);
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
@ -761,7 +761,7 @@ namespace ts {
|
||||
Debug.type<TaggedTemplateExpression>(node);
|
||||
return factory.updateTaggedTemplateExpression(node,
|
||||
nodeVisitor(node.tag, visitor, isExpression),
|
||||
visitNodes(node.typeArguments, visitor, isTypeNode),
|
||||
nodesVisitor(node.typeArguments, visitor, isTypeNode),
|
||||
nodeVisitor(node.template, visitor, isTemplateLiteral));
|
||||
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
|
||||
@ -691,6 +691,7 @@ namespace ts.formatting {
|
||||
undecoratedParentStartLine: number,
|
||||
isListItem: boolean,
|
||||
isFirstListItem?: boolean): number {
|
||||
Debug.assert(!nodeIsSynthesized(child));
|
||||
|
||||
if (nodeIsMissing(child)) {
|
||||
return inheritedIndentation;
|
||||
@ -778,6 +779,7 @@ namespace ts.formatting {
|
||||
parentStartLine: number,
|
||||
parentDynamicIndentation: DynamicIndentation): void {
|
||||
Debug.assert(isNodeArray(nodes));
|
||||
Debug.assert(!nodeIsSynthesized(nodes));
|
||||
|
||||
const listStartToken = getOpenTokenForList(parent, nodes);
|
||||
|
||||
|
||||
62
tests/cases/fourslash/extractFunctionWithSyntheticNodes.ts
Normal file
62
tests/cases/fourslash/extractFunctionWithSyntheticNodes.ts
Normal file
@ -0,0 +1,62 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @filename: /project/tsconfig.json
|
||||
//// {}
|
||||
|
||||
// @filename: /project/index.esm.d.ts
|
||||
//// export declare class Chart {
|
||||
//// constructor(config: ChartConfiguration);
|
||||
//// }
|
||||
////
|
||||
//// export interface ChartConfiguration {
|
||||
//// options?: Partial<TickOptions>;
|
||||
//// }
|
||||
////
|
||||
//// export interface TickOptions {
|
||||
//// callback: (this: Scale, tickValue: number | string) => string | string[] | number | number[] | null | undefined;
|
||||
//// }
|
||||
////
|
||||
//// export interface CoreScaleOptions {
|
||||
//// opt: boolean;
|
||||
//// }
|
||||
////
|
||||
//// export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> {
|
||||
//// opts: O;
|
||||
//// getLabelForValue(value: number): string;
|
||||
//// }
|
||||
|
||||
// @filename: /project/options.ts
|
||||
//// import { Chart } from './index.esm';
|
||||
////
|
||||
//// const chart = new Chart({
|
||||
//// options: {
|
||||
//// callback(tickValue) {
|
||||
//// /*a*/const value = this.getLabelForValue(tickValue as number);/*b*/
|
||||
//// return '$' + value;
|
||||
//// }
|
||||
//// }
|
||||
//// });
|
||||
|
||||
goTo.file("/project/options.ts");
|
||||
verify.noErrors();
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Extract Symbol",
|
||||
actionName: "function_scope_0",
|
||||
actionDescription: "Extract to inner function in method 'callback'",
|
||||
newContent:
|
||||
`import { Chart } from './index.esm';
|
||||
|
||||
const chart = new Chart({
|
||||
options: {
|
||||
callback(tickValue) {
|
||||
const value = /*RENAME*/newFunction.call(this);
|
||||
return '$' + value;
|
||||
|
||||
function newFunction(this: import("/project/index.esm").Scale<import("/project/index.esm").CoreScaleOptions>) {
|
||||
return this.getLabelForValue(tickValue as number);
|
||||
}
|
||||
}
|
||||
}
|
||||
});`
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user