File tree Expand file tree Collapse file tree 3 files changed +64
-7
lines changed Expand file tree Collapse file tree 3 files changed +64
-7
lines changed Original file line number Diff line number Diff line change @@ -4093,19 +4093,61 @@ Object {
4093
4093
}
4094
4094
` ;
4095
4095
4096
- exports [` typescript indexed type 1` ] = `
4096
+ exports [` typescript indexed imported type 1` ] = `
4097
4097
Object {
4098
4098
" classes" : Array [
4099
4099
Object {
4100
- " kind" : " generic" ,
4100
+ " kind" : " object" ,
4101
+ " members" : Array [
4102
+ Object {
4103
+ " key" : Object {
4104
+ " kind" : " id" ,
4105
+ " name" : " foo" ,
4106
+ },
4107
+ " kind" : " property" ,
4108
+ " optional" : false ,
4109
+ " value" : Object {
4110
+ " kind" : " generic" ,
4111
+ " value" : Object {
4112
+ " kind" : " id" ,
4113
+ " name" : " ImportedType['props']" ,
4114
+ },
4115
+ },
4116
+ },
4117
+ ],
4101
4118
" name" : Object {
4102
4119
" kind" : " id" ,
4103
4120
" name" : " Component" ,
4104
4121
" type" : null ,
4105
4122
},
4106
- " value" : Object {
4107
- " kind" : " object" ,
4108
- " name" : " MyType['props']" ,
4123
+ },
4124
+ ],
4125
+ " kind" : " program" ,
4126
+ }
4127
+ ` ;
4128
+
4129
+ exports [` typescript indexed type 1` ] = `
4130
+ Object {
4131
+ " classes" : Array [
4132
+ Object {
4133
+ " kind" : " object" ,
4134
+ " members" : Array [
4135
+ Object {
4136
+ " key" : Object {
4137
+ " kind" : " id" ,
4138
+ " name" : " foo" ,
4139
+ },
4140
+ " kind" : " property" ,
4141
+ " optional" : false ,
4142
+ " value" : Object {
4143
+ " kind" : " number" ,
4144
+ },
4145
+ },
4146
+ ],
4147
+ " name" : Object {
4148
+ " kind" : " id" ,
4149
+ " name" : " Component" ,
4150
+ " type" : null ,
4109
4151
},
4110
4152
},
4111
4153
],
Original file line number Diff line number Diff line change @@ -831,6 +831,14 @@ converters.TSIndexedAccessType = (path, context) => {
831
831
const indexKey = path . get ( 'indexType' ) . node . literal . value ;
832
832
833
833
if ( type . kind === 'generic' ) {
834
+ if ( type . value . members ) {
835
+ const member = type . value . members . find ( ( member ) =>
836
+ member . key . name === indexKey
837
+ ) ;
838
+ if ( member ) {
839
+ return member . value ;
840
+ }
841
+ }
834
842
return {
835
843
kind : 'generic' ,
836
844
value : {
Original file line number Diff line number Diff line change @@ -1114,10 +1114,17 @@ const TESTS = [
1114
1114
typeSystem : 'typescript' ,
1115
1115
code : `
1116
1116
type MyType = {
1117
- props: RecursiveType
1117
+ props: number;
1118
1118
}
1119
1119
1120
- class Component extends React.Component<MyType['props']> {}
1120
+ class Component extends React.Component<{ foo: MyType['props'] }> {}
1121
+ `
1122
+ } ,
1123
+ {
1124
+ name : 'typescript indexed imported type' ,
1125
+ typeSystem : 'typescript' ,
1126
+ code : `
1127
+ class Component extends React.Component<{ foo: ImportedType['props'] }> {}
1121
1128
`
1122
1129
} ,
1123
1130
] ;
You can’t perform that action at this time.
0 commit comments