@@ -23,7 +23,7 @@ export class FieldInfoGenerator {
2323
2424 createFieldInfoLiterals ( source : TypescriptFile , fieldInfos : readonly rt . PartialFieldInfo [ ] ) : ts . ArrayLiteralExpression {
2525 fieldInfos = fieldInfos . map ( fi => FieldInfoGenerator . denormalizeFieldInfo ( fi ) ) ;
26- return ts . createArrayLiteral ( fieldInfos . map ( fi => this . createFieldInfoLiteral ( source , fi ) ) , true ) ;
26+ return ts . factory . createArrayLiteralExpression ( fieldInfos . map ( fi => this . createFieldInfoLiteral ( source , fi ) ) , true ) ;
2727 }
2828
2929
@@ -39,23 +39,23 @@ export class FieldInfoGenerator {
3939 // oneof: The name of the `oneof` group, if this field belongs to one.
4040 for ( let key of [ "no" , "name" , "kind" , "localName" , "jsonName" , "oneof" ] as const ) {
4141 if ( fieldInfo [ key ] !== undefined ) {
42- properties . push ( ts . createPropertyAssignment (
42+ properties . push ( ts . factory . createPropertyAssignment (
4343 key , typescriptLiteralFromValue ( fieldInfo [ key ] )
4444 ) ) ;
4545 }
4646 }
4747
4848 // repeat: Is the field repeated?
4949 if ( fieldInfo . repeat !== undefined ) {
50- properties . push ( ts . createPropertyAssignment (
50+ properties . push ( ts . factory . createPropertyAssignment (
5151 "repeat" ,
5252 this . createRepeatType ( fieldInfo . repeat )
5353 ) ) ;
5454 }
5555
5656 // opt: Is the field optional?
5757 if ( fieldInfo . opt !== undefined ) {
58- properties . push ( ts . createPropertyAssignment (
58+ properties . push ( ts . factory . createPropertyAssignment (
5959 "opt" , typescriptLiteralFromValue ( fieldInfo . opt )
6060 ) ) ;
6161 }
@@ -64,43 +64,43 @@ export class FieldInfoGenerator {
6464 case "scalar" :
6565
6666 // T: Scalar field type.
67- properties . push ( ts . createPropertyAssignment ( "T" , this . createScalarType ( fieldInfo . T ) ) ) ;
67+ properties . push ( ts . factory . createPropertyAssignment ( "T" , this . createScalarType ( fieldInfo . T ) ) ) ;
6868
6969 // L?: JavaScript long type
7070 if ( fieldInfo . L !== undefined ) {
71- properties . push ( ts . createPropertyAssignment ( "L" , this . createLongType ( fieldInfo . L ) ) ) ;
71+ properties . push ( ts . factory . createPropertyAssignment ( "L" , this . createLongType ( fieldInfo . L ) ) ) ;
7272 }
7373 break ;
7474
7575 case "enum" :
7676 // T: Return enum field type info.
77- properties . push ( ts . createPropertyAssignment ( ts . createIdentifier ( 'T' ) , this . createEnumT ( source , fieldInfo . T ( ) ) ) ) ;
77+ properties . push ( ts . factory . createPropertyAssignment ( ts . factory . createIdentifier ( 'T' ) , this . createEnumT ( source , fieldInfo . T ( ) ) ) ) ;
7878 break ;
7979
8080 case "message" :
8181 // T: Return message field type handler.
82- properties . push ( ts . createPropertyAssignment ( ts . createIdentifier ( 'T' ) , this . createMessageT ( source , fieldInfo . T ( ) ) ) ) ;
82+ properties . push ( ts . factory . createPropertyAssignment ( ts . factory . createIdentifier ( 'T' ) , this . createMessageT ( source , fieldInfo . T ( ) ) ) ) ;
8383 break ;
8484
8585
8686 case "map" :
8787 // K: Map field key type.
88- properties . push ( ts . createPropertyAssignment ( "K" , this . createScalarType ( fieldInfo . K ) ) ) ;
88+ properties . push ( ts . factory . createPropertyAssignment ( "K" , this . createScalarType ( fieldInfo . K ) ) ) ;
8989
9090 // V: Map field value type.
91- properties . push ( ts . createPropertyAssignment ( "V" , this . createMapV ( source , fieldInfo . V ) ) ) ;
91+ properties . push ( ts . factory . createPropertyAssignment ( "V" , this . createMapV ( source , fieldInfo . V ) ) ) ;
9292 break ;
9393 }
9494
9595 // options:
9696 if ( fieldInfo . options ) {
97- properties . push ( ts . createPropertyAssignment (
98- ts . createIdentifier ( 'options' ) ,
97+ properties . push ( ts . factory . createPropertyAssignment (
98+ ts . factory . createIdentifier ( 'options' ) ,
9999 typescriptLiteralFromValue ( fieldInfo . options )
100100 ) ) ;
101101 }
102102
103- return ts . createObjectLiteral ( properties , false ) ;
103+ return ts . factory . createObjectLiteralExpression ( properties , false ) ;
104104 }
105105
106106
@@ -139,10 +139,10 @@ export class FieldInfoGenerator {
139139 let descriptor = this . registry . getMessage ( type . typeName ) ;
140140 assert ( descriptor ) ;
141141 let generatedMessage = this . imports . type ( source , descriptor ) ;
142- return ts . createArrowFunction (
142+ return ts . factory . createArrowFunction (
143143 undefined , undefined , [ ] , undefined ,
144- ts . createToken ( ts . SyntaxKind . EqualsGreaterThanToken ) ,
145- ts . createIdentifier ( generatedMessage )
144+ ts . factory . createToken ( ts . SyntaxKind . EqualsGreaterThanToken ) ,
145+ ts . factory . createIdentifier ( generatedMessage )
146146 ) ;
147147 }
148148
@@ -152,36 +152,36 @@ export class FieldInfoGenerator {
152152 assert ( descriptor ) ;
153153 let generatedEnum = this . imports . type ( source , descriptor ) ,
154154 enumInfoLiteral : ts . Expression [ ] = [
155- ts . createStringLiteral ( pbTypeName ) ,
156- ts . createIdentifier ( generatedEnum ) ,
155+ ts . factory . createStringLiteral ( pbTypeName ) ,
156+ ts . factory . createIdentifier ( generatedEnum ) ,
157157 ] ;
158158 if ( sharedPrefix ) {
159- enumInfoLiteral . push ( ts . createStringLiteral ( sharedPrefix ) ) ;
159+ enumInfoLiteral . push ( ts . factory . createStringLiteral ( sharedPrefix ) ) ;
160160 }
161- return ts . createArrowFunction (
161+ return ts . factory . createArrowFunction (
162162 undefined , undefined , [ ] , undefined ,
163- ts . createToken ( ts . SyntaxKind . EqualsGreaterThanToken ) ,
164- ts . createArrayLiteral ( enumInfoLiteral , false )
163+ ts . factory . createToken ( ts . SyntaxKind . EqualsGreaterThanToken ) ,
164+ ts . factory . createArrayLiteralExpression ( enumInfoLiteral , false )
165165 ) ;
166166 }
167167
168168
169169 private createRepeatType ( type : rt . RepeatType ) : ts . Expression {
170- const expr = ts . createNumericLiteral ( type . toString ( ) ) ;
170+ const expr = ts . factory . createNumericLiteral ( type . toString ( ) ) ;
171171 ts . addSyntheticTrailingComment ( expr , ts . SyntaxKind . MultiLineCommentTrivia , `RepeatType.${ rt . RepeatType [ type ] } ` ) ;
172172 return expr ;
173173 }
174174
175175
176176 private createScalarType ( type : rt . ScalarType ) : ts . Expression {
177- const expr = ts . createNumericLiteral ( type . toString ( ) ) ;
177+ const expr = ts . factory . createNumericLiteral ( type . toString ( ) ) ;
178178 ts . addSyntheticTrailingComment ( expr , ts . SyntaxKind . MultiLineCommentTrivia , `ScalarType.${ rt . ScalarType [ type ] } ` ) ;
179179 return expr ;
180180 }
181181
182182
183183 private createLongType ( type : rt . LongType ) : ts . Expression {
184- const expr = ts . createNumericLiteral ( type . toString ( ) ) ;
184+ const expr = ts . factory . createNumericLiteral ( type . toString ( ) ) ;
185185 ts . addSyntheticTrailingComment ( expr , ts . SyntaxKind . MultiLineCommentTrivia , `LongType.${ rt . LongType [ type ] } ` ) ;
186186 return expr ;
187187 }
@@ -205,15 +205,15 @@ export class FieldInfoGenerator {
205205 break ;
206206 }
207207 const properties : ts . ObjectLiteralElementLike [ ] = [
208- ts . createPropertyAssignment ( ts . createIdentifier ( 'kind' ) , ts . createStringLiteral ( mapV . kind ) ) ,
209- ts . createPropertyAssignment ( ts . createIdentifier ( 'T' ) , T )
208+ ts . factory . createPropertyAssignment ( ts . factory . createIdentifier ( 'kind' ) , ts . factory . createStringLiteral ( mapV . kind ) ) ,
209+ ts . factory . createPropertyAssignment ( ts . factory . createIdentifier ( 'T' ) , T )
210210 ] ;
211211 if ( L ) {
212212 properties . push (
213- ts . createPropertyAssignment ( ts . createIdentifier ( 'L' ) , L )
213+ ts . factory . createPropertyAssignment ( ts . factory . createIdentifier ( 'L' ) , L )
214214 ) ;
215215 }
216- return ts . createObjectLiteral ( properties ) ;
216+ return ts . factory . createObjectLiteralExpression ( properties ) ;
217217 }
218218
219219
0 commit comments