@@ -62,6 +62,7 @@ export enum NodeKind {
6262 SWITCH ,
6363 THROW ,
6464 TRY ,
65+ TYPEDECLARATION ,
6566 VARIABLE , // wraps declarations
6667 VARIABLEDECLARATION ,
6768 WHILE ,
@@ -542,6 +543,17 @@ export abstract class Node {
542543 return stmt ;
543544 }
544545
546+ static createTypeDeclaration ( identifier : IdentifierExpression , alias : TypeNode , modifiers : Modifier [ ] | null , decorators : Decorator [ ] | null , range : Range ) : TypeDeclaration {
547+ const stmt : TypeDeclaration = new TypeDeclaration ( ) ;
548+ stmt . range = range ;
549+ ( stmt . name = identifier ) . parent = stmt ;
550+ ( stmt . alias = alias ) . parent = stmt ;
551+ let i : i32 , k : i32 ;
552+ if ( stmt . modifiers = modifiers ) for ( i = 0 , k = ( < Modifier [ ] > modifiers ) . length ; i < k ; ++ i ) ( < Modifier [ ] > modifiers ) [ i ] . parent = stmt ;
553+ if ( stmt . decorators = decorators ) for ( i = 0 , k = ( < Decorator [ ] > decorators ) . length ; i < k ; ++ i ) ( < Decorator [ ] > decorators ) [ i ] . parent = stmt ;
554+ return stmt ;
555+ }
556+
545557 static createVariable ( declarations : VariableDeclaration [ ] , modifiers : Modifier [ ] | null , decorators : Decorator [ ] | null , range : Range ) : VariableStatement {
546558 const stmt : VariableStatement = new VariableStatement ( ) ;
547559 stmt . range = range ;
@@ -552,10 +564,10 @@ export abstract class Node {
552564 return stmt ;
553565 }
554566
555- static createVariableDeclaration ( identifier : IdentifierExpression , type : TypeNode | null , initializer : Expression | null , modifiers : Modifier [ ] | null , decorators : Decorator [ ] | null , range : Range ) : VariableDeclaration {
567+ static createVariableDeclaration ( name : IdentifierExpression , type : TypeNode | null , initializer : Expression | null , modifiers : Modifier [ ] | null , decorators : Decorator [ ] | null , range : Range ) : VariableDeclaration {
556568 const elem : VariableDeclaration = new VariableDeclaration ( ) ;
557569 elem . range = range ;
558- ( elem . name = identifier ) . parent = elem ;
570+ ( elem . name = name ) . parent = elem ;
559571 if ( elem . type = type ) ( < TypeNode > type ) . parent = elem ;
560572 if ( elem . initializer = initializer ) ( < Expression > initializer ) . parent = elem ;
561573 elem . modifiers = modifiers ;
@@ -1864,6 +1876,33 @@ export class TryStatement extends Statement {
18641876 }
18651877}
18661878
1879+ /** Represents a `type` declaration. */
1880+ export class TypeDeclaration extends DeclarationStatement {
1881+
1882+ kind = NodeKind . TYPEDECLARATION ;
1883+
1884+ /** Type being aliased. */
1885+ alias : TypeNode ;
1886+
1887+ serialize ( sb : string [ ] ) : void {
1888+ let i : i32 , k : i32 ;
1889+ if ( this . decorators )
1890+ for ( i = 0 , k = this . decorators . length ; i < k ; ++ i ) {
1891+ this . decorators [ i ] . serialize ( sb ) ;
1892+ sb . push ( "\n" ) ;
1893+ }
1894+ if ( this . modifiers )
1895+ for ( i = 0 , k = ( < Modifier [ ] > this . modifiers ) . length ; i < k ; ++ i ) {
1896+ ( < Modifier [ ] > this . modifiers ) [ i ] . serialize ( sb ) ;
1897+ sb . push ( " " ) ;
1898+ }
1899+ sb . push ( "type " ) ;
1900+ this . name . serialize ( sb ) ;
1901+ sb . push ( " = " ) ;
1902+ this . alias . serialize ( sb ) ;
1903+ }
1904+ }
1905+
18671906/** Represents a single variable declaration within a {@link VariableStatement}. */
18681907export class VariableDeclaration extends VariableLikeDeclarationStatement {
18691908
0 commit comments