File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
2
3
+ ### Bug Fixes
4
+
5
+ - Fixed conversion of intrinsic string mapping types when converting without a type node, #2079 .
6
+
3
7
## v0.23.17 (2022-10-18)
4
8
5
9
### Features
Original file line number Diff line number Diff line change @@ -644,7 +644,7 @@ const queryConverter: TypeConverter<ts.TypeQueryNode> = {
644
644
645
645
const referenceConverter : TypeConverter <
646
646
ts . TypeReferenceNode ,
647
- ts . TypeReference
647
+ ts . TypeReference | ts . StringMappingType
648
648
> = {
649
649
kind : [ ts . SyntaxKind . TypeReference ] ,
650
650
convert ( context , node ) {
@@ -688,9 +688,17 @@ const referenceConverter: TypeConverter<
688
688
context . resolveAliasedSymbol ( symbol ) ,
689
689
context
690
690
) ;
691
- ref . typeArguments = (
692
- type . aliasSymbol ? type . aliasTypeArguments : type . typeArguments
693
- ) ?. map ( ( ref ) => convertType ( context , ref ) ) ;
691
+ if ( type . flags & ts . TypeFlags . StringMapping ) {
692
+ ref . typeArguments = [
693
+ convertType ( context , ( type as ts . StringMappingType ) . type ) ,
694
+ ] ;
695
+ } else {
696
+ ref . typeArguments = (
697
+ type . aliasSymbol
698
+ ? type . aliasTypeArguments
699
+ : ( type as ts . TypeReference ) . typeArguments
700
+ ) ?. map ( ( ref ) => convertType ( context , ref ) ) ;
701
+ }
694
702
return ref ;
695
703
} ,
696
704
} ;
Original file line number Diff line number Diff line change
1
+ export function capitalize < T extends string > ( string : T ) {
2
+ return (
3
+ string === "" ? "" : string [ 0 ] . toUpperCase ( ) + string . slice ( 1 )
4
+ ) as Capitalize < T > ;
5
+ }
Original file line number Diff line number Diff line change @@ -803,4 +803,10 @@ export const issueTests: {
803
803
gh2064 ( project ) {
804
804
query ( project , "PrivateCtorDecl.x" ) ;
805
805
} ,
806
+
807
+ gh2079 ( project ) {
808
+ const cap = query ( project , "capitalize" ) ;
809
+ const sig = cap . signatures ! [ 0 ] ;
810
+ equal ( sig . type ?. toString ( ) , "Capitalize<T>" ) ;
811
+ } ,
806
812
} ;
You can’t perform that action at this time.
0 commit comments