mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 02:30:15 -06:00
Merge pull request #15511 from mohsen1/add-ts.createTypeAliasDeclaration
Add createTypeAliasDeclaration and updateTypeAliasDeclaration factories
This commit is contained in:
commit
1db4f96fd1
@ -1462,6 +1462,22 @@ namespace ts {
|
||||
: node;
|
||||
}
|
||||
|
||||
export function createTypeAliasDeclaration(name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) {
|
||||
const node = <TypeAliasDeclaration>createSynthesizedNode(SyntaxKind.TypeAliasDeclaration);
|
||||
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
|
||||
|| node.typeParameters !== typeParameters
|
||||
|| node.type !== type
|
||||
? updateNode(createTypeAliasDeclaration(name, typeParameters, type), node)
|
||||
: node;
|
||||
}
|
||||
|
||||
export function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]) {
|
||||
const node = <EnumDeclaration>createSynthesizedNode(SyntaxKind.EnumDeclaration);
|
||||
node.decorators = asNodeArray(decorators);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user