Skip to content

Commit d5993ba

Browse files
authored
Merge pull request #15940 from phated/fix-createTypeAliasDeclaration-parameters
Make {create/update}TypeAliasDeclaration API consistent (closes #15918)
2 parents f489f5a + 226b2ef commit d5993ba

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/compiler/factory.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,19 +1502,23 @@ namespace ts {
15021502
: node;
15031503
}
15041504

1505-
export function createTypeAliasDeclaration(name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
1505+
export function createTypeAliasDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
15061506
const node = <TypeAliasDeclaration>createSynthesizedNode(SyntaxKind.TypeAliasDeclaration);
1507+
node.decorators = asNodeArray(decorators);
1508+
node.modifiers = asNodeArray(modifiers);
15071509
node.name = asName(name);
15081510
node.typeParameters = asNodeArray(typeParameters);
15091511
node.type = type;
15101512
return node;
15111513
}
15121514

1513-
export function updateTypeAliasDeclaration(node: TypeAliasDeclaration, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
1514-
return node.name !== name
1515+
export function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
1516+
return node.decorators !== decorators
1517+
|| node.modifiers !== modifiers
1518+
|| node.name !== name
15151519
|| node.typeParameters !== typeParameters
15161520
|| node.type !== type
1517-
? updateNode(createTypeAliasDeclaration(name, typeParameters, type), node)
1521+
? updateNode(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
15181522
: node;
15191523
}
15201524

src/compiler/visitor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ namespace ts {
701701

702702
case SyntaxKind.TypeAliasDeclaration:
703703
return updateTypeAliasDeclaration(<TypeAliasDeclaration>node,
704+
nodesVisitor((<TypeAliasDeclaration>node).decorators, visitor, isDecorator),
705+
nodesVisitor((<TypeAliasDeclaration>node).modifiers, visitor, isModifier),
704706
visitNode((<TypeAliasDeclaration>node).name, visitor, isIdentifier),
705707
nodesVisitor((<TypeAliasDeclaration>node).typeParameters, visitor, isTypeParameter),
706708
visitNode((<TypeAliasDeclaration>node).type, visitor, isTypeNode));

0 commit comments

Comments
 (0)