@@ -856,17 +856,13 @@ const thisConverter: TypeConverter<ts.ThisTypeNode> = {
856
856
const tupleConverter : TypeConverter < ts . TupleTypeNode , ts . TupleTypeReference > = {
857
857
kind : [ ts . SyntaxKind . TupleType ] ,
858
858
convert ( context , node ) {
859
- // TS 3.9 support
860
- const elementTypes = node . elements ?? ( node as any ) . elementTypes ;
861
- const elements = elementTypes . map ( ( node ) => convertType ( context , node ) ) ;
859
+ const elements = node . elements . map ( ( node ) =>
860
+ convertType ( context , node )
861
+ ) ;
862
862
return new TupleType ( elements ) ;
863
863
} ,
864
- convertType ( context , type , node ) {
865
- // TS 3.9 support
866
- const elementTypes = node . elements ?? ( node as any ) . elementTypes ;
867
- // We need to do this because of type argument constraints, see GH1449
868
- // In TS 4.0 we could use type.target.fixedLength
869
- const types = type . typeArguments ?. slice ( 0 , elementTypes . length ) ;
864
+ convertType ( context , type ) {
865
+ const types = type . typeArguments ?. slice ( 0 , type . target . fixedLength ) ;
870
866
let elements = types ?. map ( ( type ) => convertType ( context , type ) ) ;
871
867
872
868
if ( type . target . labeledElementDeclarations ) {
@@ -881,34 +877,31 @@ const tupleConverter: TypeConverter<ts.TupleTypeNode, ts.TupleTypeReference> = {
881
877
) ;
882
878
}
883
879
884
- // TS 3.9 support - always defined in 4.0
885
- if ( type . target . elementFlags ) {
886
- elements = elements ?. map ( ( el , i ) => {
887
- if ( type . target . elementFlags [ i ] & ts . ElementFlags . Variable ) {
888
- // In the node case, we don't need to add the wrapping Array type... but we do here.
889
- if ( el instanceof NamedTupleMember ) {
890
- return new RestType (
891
- new NamedTupleMember (
892
- el . name ,
893
- el . isOptional ,
894
- new ArrayType ( el . element )
895
- )
896
- ) ;
897
- }
898
-
899
- return new RestType ( new ArrayType ( el ) ) ;
880
+ elements = elements ?. map ( ( el , i ) => {
881
+ if ( type . target . elementFlags [ i ] & ts . ElementFlags . Variable ) {
882
+ // In the node case, we don't need to add the wrapping Array type... but we do here.
883
+ if ( el instanceof NamedTupleMember ) {
884
+ return new RestType (
885
+ new NamedTupleMember (
886
+ el . name ,
887
+ el . isOptional ,
888
+ new ArrayType ( el . element )
889
+ )
890
+ ) ;
900
891
}
901
892
902
- if (
903
- type . target . elementFlags [ i ] & ts . ElementFlags . Optional &&
904
- ! ( el instanceof NamedTupleMember )
905
- ) {
906
- return new OptionalType ( removeUndefined ( el ) ) ;
907
- }
893
+ return new RestType ( new ArrayType ( el ) ) ;
894
+ }
908
895
909
- return el ;
910
- } ) ;
911
- }
896
+ if (
897
+ type . target . elementFlags [ i ] & ts . ElementFlags . Optional &&
898
+ ! ( el instanceof NamedTupleMember )
899
+ ) {
900
+ return new OptionalType ( removeUndefined ( el ) ) ;
901
+ }
902
+
903
+ return el ;
904
+ } ) ;
912
905
913
906
return new TupleType ( elements ?? [ ] ) ;
914
907
} ,
0 commit comments