mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 20:44:53 -05:00
Make {create/update}TypeAliasDeclaration API consistent (closes #15918)
This commit is contained in:
@@ -1502,19 +1502,23 @@ namespace ts {
|
||||
: node;
|
||||
}
|
||||
|
||||
export function createTypeAliasDeclaration(name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
|
||||
export function createTypeAliasDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
|
||||
const node = <TypeAliasDeclaration>createSynthesizedNode(SyntaxKind.TypeAliasDeclaration);
|
||||
node.decorators = asNodeArray(decorators);
|
||||
node.modifiers = asNodeArray(modifiers);
|
||||
node.name = asName(name);
|
||||
node.typeParameters = asNodeArray(typeParameters);
|
||||
node.type = type;
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateTypeAliasDeclaration(node: TypeAliasDeclaration, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
|
||||
return node.name !== name
|
||||
export function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
|
||||
return node.decorators !== decorators
|
||||
|| node.modifiers !== modifiers
|
||||
|| node.name !== name
|
||||
|| node.typeParameters !== typeParameters
|
||||
|| node.type !== type
|
||||
? updateNode(createTypeAliasDeclaration(name, typeParameters, type), node)
|
||||
? updateNode(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
|
||||
: node;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user