@@ -535,6 +535,10 @@ export class JavaScriptParserVisitor {
535535 return this . mapLiteral ( node , null ) ;
536536 }
537537
538+ visitNeverKeyword ( node : ts . Node ) {
539+ return this . mapIdentifier ( node , 'never' ) ;
540+ }
541+
538542 private mapLiteral ( node : ts . LiteralExpression | ts . TrueLiteral | ts . FalseLiteral | ts . NullLiteral | ts . Identifier
539543 | ts . TemplateHead | ts . TemplateMiddle | ts . TemplateTail , value : any ) : J . Literal {
540544 return new J . Literal (
@@ -1030,7 +1034,7 @@ export class JavaScriptParserVisitor {
10301034
10311035 private mapTypeInfo ( node : ts . MethodDeclaration | ts . PropertyDeclaration | ts . VariableDeclaration | ts . ParameterDeclaration
10321036 | ts . PropertySignature | ts . MethodSignature | ts . ArrowFunction | ts . CallSignatureDeclaration | ts . GetAccessorDeclaration
1033- | ts . FunctionDeclaration | ts . ConstructSignatureDeclaration | ts . FunctionExpression ) {
1037+ | ts . FunctionDeclaration | ts . ConstructSignatureDeclaration | ts . FunctionExpression | ts . NamedTupleMember ) {
10341038 return node . type ? new JS . TypeInfo ( randomId ( ) , this . prefix ( node . getChildAt ( node . getChildren ( ) . indexOf ( node . type ) - 1 ) ) , Markers . EMPTY , this . visit ( node . type ) ) : null ;
10351039 }
10361040
@@ -1181,7 +1185,15 @@ export class JavaScriptParserVisitor {
11811185 }
11821186
11831187 visitTypePredicate ( node : ts . TypePredicateNode ) {
1184- return this . visitUnknown ( node ) ;
1188+ return new JS . TypePredicate (
1189+ randomId ( ) ,
1190+ this . prefix ( node ) ,
1191+ Markers . EMPTY ,
1192+ node . assertsModifier ? this . leftPadded ( this . prefix ( node . assertsModifier ) , true ) : this . leftPadded ( Space . EMPTY , false ) ,
1193+ this . visit ( node . parameterName ) ,
1194+ node . type ? this . leftPadded ( this . suffix ( node . parameterName ) , this . convert ( node . type ) ) : null ,
1195+ this . mapType ( node )
1196+ ) ;
11851197 }
11861198
11871199 visitTypeReference ( node : ts . TypeReferenceNode ) {
@@ -1363,15 +1375,32 @@ export class JavaScriptParserVisitor {
13631375 }
13641376
13651377 visitInferType ( node : ts . InferTypeNode ) {
1366- return this . visitUnknown ( node ) ;
1378+ return new JS . InferType (
1379+ randomId ( ) ,
1380+ this . prefix ( node ) ,
1381+ Markers . EMPTY ,
1382+ this . leftPadded ( Space . EMPTY , this . convert ( node . typeParameter ) ) ,
1383+ this . mapType ( node )
1384+ ) ;
13671385 }
13681386
13691387 visitParenthesizedType ( node : ts . ParenthesizedTypeNode ) {
1370- return this . visitUnknown ( node ) ;
1388+ return new J . ParenthesizedTypeTree (
1389+ randomId ( ) ,
1390+ Space . EMPTY ,
1391+ Markers . EMPTY ,
1392+ [ ] ,
1393+ new J . Parentheses (
1394+ randomId ( ) ,
1395+ this . prefix ( node ) ,
1396+ Markers . EMPTY ,
1397+ this . rightPadded ( this . convert ( node . type ) , this . prefix ( node . getLastToken ( ) ! ) )
1398+ )
1399+ ) ;
13711400 }
13721401
13731402 visitThisType ( node : ts . ThisTypeNode ) {
1374- return this . visitUnknown ( node ) ;
1403+ return this . mapIdentifier ( node , 'this' ) ;
13751404 }
13761405
13771406 visitTypeOperator ( node : ts . TypeOperatorNode ) {
@@ -1394,19 +1423,113 @@ export class JavaScriptParserVisitor {
13941423 }
13951424
13961425 visitIndexedAccessType ( node : ts . IndexedAccessTypeNode ) {
1397- return this . visitUnknown ( node ) ;
1426+ return new J . ArrayAccess (
1427+ randomId ( ) ,
1428+ this . prefix ( node ) ,
1429+ Markers . EMPTY ,
1430+ this . convert ( node . objectType ) ,
1431+ new J . ArrayDimension (
1432+ randomId ( ) ,
1433+ this . prefix ( this . findChildNode ( node , ts . SyntaxKind . OpenBracketToken ) ! ) ,
1434+ Markers . EMPTY ,
1435+ this . rightPadded ( this . convert ( node . indexType ) , this . suffix ( node . indexType ) )
1436+ ) ,
1437+ this . mapType ( node )
1438+ ) ;
13981439 }
13991440
14001441 visitMappedType ( node : ts . MappedTypeNode ) {
14011442 return this . visitUnknown ( node ) ;
14021443 }
14031444
14041445 visitLiteralType ( node : ts . LiteralTypeNode ) {
1405- return this . visit ( node . literal ) ;
1446+ return new JS . LiteralType (
1447+ randomId ( ) ,
1448+ this . prefix ( node ) ,
1449+ Markers . EMPTY ,
1450+ this . visit ( node . literal ) ,
1451+ this . mapType ( node ) !
1452+ ) ;
14061453 }
14071454
14081455 visitNamedTupleMember ( node : ts . NamedTupleMember ) {
1409- return this . visitUnknown ( node ) ;
1456+ if ( node . questionToken ) {
1457+ return new JS . JSVariableDeclarations (
1458+ randomId ( ) ,
1459+ this . prefix ( node ) ,
1460+ Markers . EMPTY ,
1461+ [ ] ,
1462+ [ ] ,
1463+ this . mapTypeInfo ( node ) ,
1464+ null ,
1465+ [ this . rightPadded (
1466+ new JS . JSVariableDeclarations . JSNamedVariable (
1467+ randomId ( ) ,
1468+ this . prefix ( node . name ) ,
1469+ Markers . EMPTY ,
1470+ this . getOptionalUnary ( node ) ,
1471+ [ ] ,
1472+ null ,
1473+ this . mapVariableType ( node )
1474+ ) ,
1475+ this . suffix ( node . name )
1476+ ) ]
1477+ ) ;
1478+ }
1479+
1480+ if ( node . dotDotDotToken ) {
1481+ return new JS . JSVariableDeclarations (
1482+ randomId ( ) ,
1483+ this . prefix ( node ) ,
1484+ Markers . EMPTY ,
1485+ [ ] ,
1486+ [ ] ,
1487+ this . mapTypeInfo ( node ) ,
1488+ null ,
1489+ [ this . rightPadded (
1490+ new JS . JSVariableDeclarations . JSNamedVariable (
1491+ randomId ( ) ,
1492+ Space . EMPTY ,
1493+ Markers . EMPTY ,
1494+ new JS . Unary (
1495+ randomId ( ) ,
1496+ Space . EMPTY ,
1497+ Markers . EMPTY ,
1498+ this . leftPadded ( Space . EMPTY , JS . Unary . Type . Spread ) ,
1499+ this . visit ( node . name ) ,
1500+ this . mapType ( node )
1501+ ) ,
1502+ [ ] ,
1503+ null ,
1504+ this . mapVariableType ( node )
1505+ ) ,
1506+ this . suffix ( node . name )
1507+ ) ]
1508+ ) ;
1509+ }
1510+
1511+ return new J . VariableDeclarations (
1512+ randomId ( ) ,
1513+ this . prefix ( node ) ,
1514+ Markers . EMPTY ,
1515+ [ ] ,
1516+ [ ] ,
1517+ this . mapTypeInfo ( node ) ,
1518+ null ,
1519+ [ ] ,
1520+ [ this . rightPadded (
1521+ new J . VariableDeclarations . NamedVariable (
1522+ randomId ( ) ,
1523+ this . prefix ( node . name ) ,
1524+ Markers . EMPTY ,
1525+ this . visit ( node . name ) ,
1526+ [ ] ,
1527+ null ,
1528+ this . mapVariableType ( node )
1529+ ) ,
1530+ this . suffix ( node . name )
1531+ ) ]
1532+ ) ;
14101533 }
14111534
14121535 visitTemplateLiteralType ( node : ts . TemplateLiteralTypeNode ) {
@@ -1431,7 +1554,27 @@ export class JavaScriptParserVisitor {
14311554 }
14321555
14331556 visitImportType ( node : ts . ImportTypeNode ) {
1434- return this . visitUnknown ( node ) ;
1557+ return new JS . ImportType (
1558+ randomId ( ) ,
1559+ this . prefix ( node ) ,
1560+ Markers . EMPTY ,
1561+ node . isTypeOf ? this . rightPadded ( true , this . suffix ( this . findChildNode ( node , ts . SyntaxKind . TypeOfKeyword ) ! ) ) : this . rightPadded ( false , Space . EMPTY ) ,
1562+ new J . ParenthesizedTypeTree (
1563+ randomId ( ) ,
1564+ this . suffix ( this . findChildNode ( node , ts . SyntaxKind . ImportKeyword ) ! ) ,
1565+ Markers . EMPTY ,
1566+ [ ] ,
1567+ new J . Parentheses (
1568+ randomId ( ) ,
1569+ Space . EMPTY ,
1570+ Markers . EMPTY ,
1571+ this . rightPadded ( this . visit ( node . argument ) , this . suffix ( node . argument ) )
1572+ )
1573+ ) ,
1574+ node . qualifier ? this . leftPadded ( this . prefix ( this . findChildNode ( node , ts . SyntaxKind . DotToken ) ! ) , this . visit ( node . qualifier ) ) : null ,
1575+ node . typeArguments ? this . mapTypeArguments ( this . suffix ( node . qualifier ! ) , node . typeArguments ) : null ,
1576+ this . mapType ( node )
1577+ ) ;
14351578 }
14361579
14371580 visitObjectBindingPattern ( node : ts . ObjectBindingPattern ) {
@@ -2132,7 +2275,14 @@ export class JavaScriptParserVisitor {
21322275 }
21332276
21342277 visitSatisfiesExpression ( node : ts . SatisfiesExpression ) {
2135- return this . visitUnknown ( node ) ;
2278+ return new JS . SatisfiesExpression (
2279+ randomId ( ) ,
2280+ this . prefix ( node ) ,
2281+ Markers . EMPTY ,
2282+ this . visit ( node . expression ) ,
2283+ this . leftPadded ( this . suffix ( node . expression ) , this . visit ( node . type ) ) ,
2284+ this . mapType ( node )
2285+ ) ;
21362286 }
21372287
21382288 visitTemplateSpan ( node : ts . TemplateSpan ) {
@@ -3368,7 +3518,7 @@ export class JavaScriptParserVisitor {
33683518 return new J . Empty ( randomId ( ) , prefix , markers ?? Markers . EMPTY ) ;
33693519 }
33703520
3371- private getOptionalUnary ( node : ts . MethodSignature | ts . MethodDeclaration | ts . ParameterDeclaration | ts . PropertySignature | ts . PropertyDeclaration ) {
3521+ private getOptionalUnary ( node : ts . MethodSignature | ts . MethodDeclaration | ts . ParameterDeclaration | ts . PropertySignature | ts . PropertyDeclaration | ts . NamedTupleMember ) {
33723522 return new JS . Unary (
33733523 randomId ( ) ,
33743524 Space . EMPTY ,
0 commit comments