Skip to content

Commit 872fdee

Browse files
author
Mohsen Azimi
committed
Add createTypeAliasDeclaration and updateTypeAliasDeclaration factories
1 parent 88f9a97 commit 872fdee

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/compiler/factory.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,22 @@ namespace ts {
14621462
: node;
14631463
}
14641464

1465+
export function createTypeAliasDeclaration(name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: ts.TypeNode) {
1466+
const node = <TypeAliasDeclaration>createSynthesizedNode(SyntaxKind.TypeAliasDeclaration);
1467+
node.name = asName(name);
1468+
node.typeParameters = asNodeArray(typeParameters);
1469+
node.type = type;
1470+
return node;
1471+
}
1472+
1473+
export function updateTypeAliasDeclaration(node: TypeAliasDeclaration, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: ts.TypeNode) {
1474+
return node.name !== name
1475+
|| node.typeParameters !== typeParameters
1476+
|| node.type !== type
1477+
? updateNode(createTypeAliasDeclaration(name, typeParameters, type), node)
1478+
: node;
1479+
}
1480+
14651481
export function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]) {
14661482
const node = <EnumDeclaration>createSynthesizedNode(SyntaxKind.EnumDeclaration);
14671483
node.decorators = asNodeArray(decorators);

0 commit comments

Comments
 (0)