@@ -262,12 +262,13 @@ export class JavaScriptParserVisitor {
262262 private mapModifiers ( node : ts . VariableDeclarationList | ts . VariableStatement | ts . ClassDeclaration | ts . PropertyDeclaration
263263 | ts . FunctionDeclaration | ts . ParameterDeclaration | ts . MethodDeclaration | ts . EnumDeclaration | ts . InterfaceDeclaration
264264 | ts . PropertySignature | ts . ConstructorDeclaration | ts . ModuleDeclaration | ts . GetAccessorDeclaration | ts . SetAccessorDeclaration
265- | ts . ArrowFunction | ts . IndexSignatureDeclaration | ts . TypeAliasDeclaration | ts . ExportDeclaration | ts . ExportAssignment | ts . FunctionExpression ) {
265+ | ts . ArrowFunction | ts . IndexSignatureDeclaration | ts . TypeAliasDeclaration | ts . ExportDeclaration | ts . ExportAssignment | ts . FunctionExpression
266+ | ts . ConstructorTypeNode ) {
266267 if ( ts . isVariableStatement ( node ) || ts . isModuleDeclaration ( node ) || ts . isClassDeclaration ( node ) || ts . isEnumDeclaration ( node )
267268 || ts . isInterfaceDeclaration ( node ) || ts . isPropertyDeclaration ( node ) || ts . isPropertySignature ( node ) || ts . isParameter ( node )
268269 || ts . isMethodDeclaration ( node ) || ts . isConstructorDeclaration ( node ) || ts . isArrowFunction ( node )
269270 || ts . isIndexSignatureDeclaration ( node ) || ts . isTypeAliasDeclaration ( node ) || ts . isExportDeclaration ( node )
270- || ts . isFunctionDeclaration ( node ) || ts . isFunctionExpression ( node ) ) {
271+ || ts . isFunctionDeclaration ( node ) || ts . isFunctionExpression ( node ) || ts . isConstructorTypeNode ( node ) ) {
271272 return node . modifiers ? node . modifiers ?. filter ( ts . isModifier ) . map ( this . mapModifier ) : [ ] ;
272273 }
273274 else if ( ts . isExportAssignment ( node ) ) {
@@ -1148,6 +1149,25 @@ export class JavaScriptParserVisitor {
11481149 }
11491150
11501151 visitGetAccessor ( node : ts . GetAccessorDeclaration ) {
1152+ const name = this . visit ( node . name ) ;
1153+ if ( ! ( name instanceof J . Identifier ) ) {
1154+ return new JS . JSMethodDeclaration (
1155+ randomId ( ) ,
1156+ this . prefix ( node ) ,
1157+ Markers . EMPTY ,
1158+ [ ] ,
1159+ this . mapModifiers ( node ) ,
1160+ null ,
1161+ this . mapTypeInfo ( node ) ,
1162+ name ,
1163+ this . mapCommaSeparatedList ( this . getParameterListNodes ( node ) ) ,
1164+ null ,
1165+ node . body ? this . convert < J . Block > ( node . body ) : null ,
1166+ null ,
1167+ this . mapMethodType ( node )
1168+ ) ;
1169+ }
1170+
11511171 return new J . MethodDeclaration (
11521172 randomId ( ) ,
11531173 this . prefix ( node ) ,
@@ -1157,7 +1177,7 @@ export class JavaScriptParserVisitor {
11571177 null ,
11581178 this . mapTypeInfo ( node ) ,
11591179 new J . MethodDeclaration . IdentifierWithAnnotations (
1160- this . visit ( node . name ) ,
1180+ name ,
11611181 [ ]
11621182 ) ,
11631183 this . mapCommaSeparatedList ( this . getParameterListNodes ( node ) ) ,
@@ -1169,6 +1189,25 @@ export class JavaScriptParserVisitor {
11691189 }
11701190
11711191 visitSetAccessor ( node : ts . SetAccessorDeclaration ) {
1192+ const name = this . visit ( node . name ) ;
1193+ if ( ! ( name instanceof J . Identifier ) ) {
1194+ return new JS . JSMethodDeclaration (
1195+ randomId ( ) ,
1196+ this . prefix ( node ) ,
1197+ Markers . EMPTY ,
1198+ [ ] ,
1199+ this . mapModifiers ( node ) ,
1200+ null ,
1201+ null ,
1202+ name ,
1203+ this . mapCommaSeparatedList ( this . getParameterListNodes ( node ) ) ,
1204+ null ,
1205+ node . body ? this . convert < J . Block > ( node . body ) : null ,
1206+ null ,
1207+ this . mapMethodType ( node )
1208+ ) ;
1209+ }
1210+
11721211 return new J . MethodDeclaration (
11731212 randomId ( ) ,
11741213 this . prefix ( node ) ,
@@ -1178,7 +1217,7 @@ export class JavaScriptParserVisitor {
11781217 null ,
11791218 null ,
11801219 new J . MethodDeclaration . IdentifierWithAnnotations (
1181- this . visit ( node . name ) ,
1220+ name ,
11821221 [ ]
11831222 ) ,
11841223 this . mapCommaSeparatedList ( this . getParameterListNodes ( node ) ) ,
@@ -1289,7 +1328,8 @@ export class JavaScriptParserVisitor {
12891328 randomId ( ) ,
12901329 this . prefix ( node ) ,
12911330 Markers . EMPTY ,
1292- this . rightPadded ( false , Space . EMPTY ) ,
1331+ [ ] ,
1332+ this . leftPadded ( Space . EMPTY , false ) ,
12931333 this . mapTypeParametersAsObject ( node ) ,
12941334 new JContainer (
12951335 this . prefix ( node . getChildAt ( node . getChildren ( ) . findIndex ( n => n . pos === node . parameters . pos ) - 1 ) ) ,
@@ -1305,7 +1345,8 @@ export class JavaScriptParserVisitor {
13051345 randomId ( ) ,
13061346 this . prefix ( node ) ,
13071347 Markers . EMPTY ,
1308- this . rightPadded ( true , this . suffix ( this . findChildNode ( node , ts . SyntaxKind . NewKeyword ) ! ) ) ,
1348+ this . mapModifiers ( node ) ,
1349+ this . leftPadded ( this . prefix ( this . findChildNode ( node , ts . SyntaxKind . NewKeyword ) ! ) , true ) ,
13091350 this . mapTypeParametersAsObject ( node ) ,
13101351 new JContainer (
13111352 this . prefix ( node . getChildAt ( node . getChildren ( ) . findIndex ( n => n . pos === node . parameters . pos ) - 1 ) ) ,
@@ -1920,7 +1961,7 @@ export class JavaScriptParserVisitor {
19201961 this . visit ( node . expression ) ,
19211962 this . mapTypeArguments ( this . prefix ( this . findChildNode ( node , ts . SyntaxKind . LessThanToken ) ! ) , node . typeArguments ) ,
19221963 null
1923- ) : this . visit ( node . expression ) ,
1964+ ) : new TypeTreeExpression ( randomId ( ) , Space . EMPTY , Markers . EMPTY , this . visit ( node . expression ) ) ,
19241965 this . mapCommaSeparatedList ( this . getParameterListNodes ( node ) ) ,
19251966 null ,
19261967 this . mapMethodType ( node )
@@ -2926,7 +2967,7 @@ export class JavaScriptParserVisitor {
29262967 }
29272968
29282969 visitModuleDeclaration ( node : ts . ModuleDeclaration ) {
2929- const body = this . visit ( node . body as ts . Node ) ;
2970+ const body = node . body ? this . visit ( node . body as ts . Node ) : null ;
29302971
29312972 let namespaceKeyword = this . findChildNode ( node , ts . SyntaxKind . NamespaceKeyword ) ;
29322973 const keywordType = namespaceKeyword ? JS . NamespaceDeclaration . KeywordType . Namespace : JS . NamespaceDeclaration . KeywordType . Module
@@ -3035,7 +3076,32 @@ export class JavaScriptParserVisitor {
30353076 }
30363077
30373078 visitNamespaceExportDeclaration ( node : ts . NamespaceExportDeclaration ) {
3038- return this . visitUnknown ( node ) ;
3079+ return new JS . NamespaceDeclaration (
3080+ randomId ( ) ,
3081+ this . prefix ( node ) ,
3082+ Markers . EMPTY ,
3083+ [
3084+ new J . Modifier (
3085+ randomId ( ) ,
3086+ Space . EMPTY ,
3087+ Markers . EMPTY ,
3088+ 'export' ,
3089+ J . Modifier . Type . LanguageExtension ,
3090+ [ ]
3091+ ) ,
3092+ new J . Modifier (
3093+ randomId ( ) ,
3094+ this . prefix ( this . findChildNode ( node , ts . SyntaxKind . AsKeyword ) ! ) ,
3095+ Markers . EMPTY ,
3096+ 'as' ,
3097+ J . Modifier . Type . LanguageExtension ,
3098+ [ ]
3099+ )
3100+ ] ,
3101+ this . leftPadded ( this . prefix ( this . findChildNode ( node , ts . SyntaxKind . NamespaceKeyword ) ! ) , JS . NamespaceDeclaration . KeywordType . Namespace ) ,
3102+ this . rightPadded ( this . convert ( node . name ) , this . suffix ( node . name ) ) ,
3103+ null
3104+ ) ;
30393105 }
30403106
30413107 visitImportEqualsDeclaration ( node : ts . ImportEqualsDeclaration ) {
0 commit comments