From 385debec5f50ff96d561b9a3a52b041e586924c3 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 18 May 2017 14:19:30 -0700 Subject: [PATCH 1/2] Make {create/update}TypeAliasDeclaration API consistent (closes #15918) --- src/compiler/factory.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 63c2028c424..80e3e995e38 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -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 = 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; } From 226b2ef08742ac3500a744b5c65563c2eca10afe Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Fri, 19 May 2017 15:20:31 -0700 Subject: [PATCH 2/2] Fix updateTypeAliasDeclaration call --- src/compiler/visitor.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index eb28721a142..af18a5620c6 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -700,6 +700,8 @@ namespace ts { case SyntaxKind.TypeAliasDeclaration: return updateTypeAliasDeclaration(node, + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitNode((node).type, visitor, isTypeNode));