Skip to content

Commit

Permalink
Make {create/update}TypeAliasDeclaration API consistent (closes micro…
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed May 18, 2017
1 parent 5e20c1c commit 385debe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 385debe

Please sign in to comment.