mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
More reliable mechanism for _this/_super simplification (#56130)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
__String,
|
||||
AccessorDeclaration,
|
||||
addRange,
|
||||
append,
|
||||
appendIfUnique,
|
||||
@@ -1180,6 +1181,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
mergeLexicalEnvironment,
|
||||
replaceModifiers,
|
||||
replaceDecoratorsAndModifiers,
|
||||
replacePropertyName,
|
||||
};
|
||||
|
||||
forEach(nodeFactoryPatchers, fn => fn(factory));
|
||||
@@ -7149,6 +7151,26 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
Debug.assertNever(node);
|
||||
}
|
||||
|
||||
function replacePropertyName<T extends AccessorDeclaration | MethodDeclaration | MethodSignature | PropertyDeclaration | PropertySignature | PropertyAssignment>(node: T, name: T["name"]): T;
|
||||
function replacePropertyName(node: AccessorDeclaration | MethodDeclaration | MethodSignature | PropertyDeclaration | PropertySignature | PropertyAssignment, name: PropertyName) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
return updateGetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.type, node.body);
|
||||
case SyntaxKind.SetAccessor:
|
||||
return updateSetAccessorDeclaration(node, node.modifiers, name, node.parameters, node.body);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return updateMethodDeclaration(node, node.modifiers, node.asteriskToken, name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
|
||||
case SyntaxKind.MethodSignature:
|
||||
return updateMethodSignature(node, node.modifiers, name, node.questionToken, node.typeParameters, node.parameters, node.type);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
return updatePropertyDeclaration(node, node.modifiers, name, node.questionToken ?? node.exclamationToken, node.type, node.initializer);
|
||||
case SyntaxKind.PropertySignature:
|
||||
return updatePropertySignature(node, node.modifiers, name, node.questionToken, node.type);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return updatePropertyAssignment(node, name, node.initializer);
|
||||
}
|
||||
}
|
||||
|
||||
function asNodeArray<T extends Node>(array: readonly T[]): NodeArray<T>;
|
||||
function asNodeArray<T extends Node>(array: readonly T[] | undefined): NodeArray<T> | undefined;
|
||||
function asNodeArray<T extends Node>(array: readonly T[] | undefined): NodeArray<T> | undefined {
|
||||
|
||||
+555
-247
File diff suppressed because it is too large
Load Diff
@@ -9080,6 +9080,10 @@ export interface NodeFactory {
|
||||
* Updates a node that may contain decorators or modifiers, replacing only the decorators and modifiers of the node.
|
||||
*/
|
||||
replaceDecoratorsAndModifiers<T extends HasModifiers & HasDecorators>(node: T, modifiers: readonly ModifierLike[] | undefined): T;
|
||||
/**
|
||||
* Updates a node that contains a property name, replacing only the name of the node.
|
||||
*/
|
||||
replacePropertyName<T extends AccessorDeclaration | MethodDeclaration | MethodSignature | PropertyDeclaration | PropertySignature | PropertyAssignment>(node: T, name: T["name"]): T;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
Reference in New Issue
Block a user