File tree 4 files changed +77
-1
lines changed
4 files changed +77
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' extract-react-types ' : patch
3
+ ---
4
+
5
+ Fixes a bug where variable names clash with type properties of the same name, causing a "Missing converter for: [ path] " error
Original file line number Diff line number Diff line change @@ -233,6 +233,59 @@ Object {
233
233
}
234
234
` ;
235
235
236
+ exports [` TypeScript: does not conflict with ambiguously named type properties 1` ] = `
237
+ Object {
238
+ " kind" : " generic" ,
239
+ " name" : Object {
240
+ " kind" : " id" ,
241
+ " name" : " Icon" ,
242
+ " type" : null ,
243
+ },
244
+ " value" : Object {
245
+ " kind" : " object" ,
246
+ " members" : Array [
247
+ Object {
248
+ " key" : Object {
249
+ " kind" : " id" ,
250
+ " name" : " size" ,
251
+ },
252
+ " kind" : " property" ,
253
+ " leadingComments" : Array [
254
+ Object {
255
+ " raw" : " Icon sizes" ,
256
+ " type" : " commentLine" ,
257
+ " value" : " Icon sizes" ,
258
+ },
259
+ ],
260
+ " optional" : true ,
261
+ " value" : Object {
262
+ " kind" : " union" ,
263
+ " types" : Array [
264
+ Object {
265
+ " kind" : " string" ,
266
+ " value" : " small" ,
267
+ },
268
+ Object {
269
+ " kind" : " string" ,
270
+ " value" : " medium" ,
271
+ },
272
+ Object {
273
+ " kind" : " string" ,
274
+ " value" : " large" ,
275
+ },
276
+ Object {
277
+ " kind" : " string" ,
278
+ " value" : " xlarge" ,
279
+ },
280
+ ],
281
+ },
282
+ },
283
+ ],
284
+ " referenceIdName" : " IconProps" ,
285
+ },
286
+ }
287
+ ` ;
288
+
236
289
exports [` TypeScript: follow export default export 1` ] = `
237
290
Object {
238
291
" kind" : " generic" ,
Original file line number Diff line number Diff line change @@ -618,6 +618,24 @@ const TESTS = [
618
618
619
619
export default MyComponent;
620
620
`
621
+ } ,
622
+ {
623
+ name : 'does not conflict with ambiguously named type properties ' ,
624
+ typeSystem : 'typescript' ,
625
+ code : `
626
+ import React, { FC } from 'react';
627
+
628
+ const size = 'My var name conflicts with the property name';
629
+
630
+ export interface IconProps {
631
+ // Icon sizes
632
+ size?: 'small' | 'medium' | 'large' | 'xlarge';
633
+ }
634
+
635
+ const Icon: FC<IconProps> = ({ size = 'medium' }) => null;
636
+
637
+ export default Icon;
638
+ `
621
639
}
622
640
] ;
623
641
Original file line number Diff line number Diff line change @@ -846,7 +846,7 @@ converters.TSTypeLiteral = (path, context): K.Obj => ({
846
846
converters . TSPropertySignature = ( path , context ) : K . Property => ( {
847
847
kind : 'property' ,
848
848
optional : ! ! path . node . optional ,
849
- key : convert ( path . get ( 'key' ) , context ) ,
849
+ key : { kind : 'id' , name : path . node . key . name } ,
850
850
value : convert ( path . get ( 'typeAnnotation' ) , context )
851
851
} ) ;
852
852
You can’t perform that action at this time.
0 commit comments