File tree Expand file tree Collapse file tree 3 files changed +62
-5
lines changed Expand file tree Collapse file tree 3 files changed +62
-5
lines changed Original file line number Diff line number Diff line change @@ -821,6 +821,36 @@ Object {
821
821
}
822
822
` ;
823
823
824
+ exports [` flow class with this expression 1` ] = `
825
+ Object {
826
+ " component" : Object {
827
+ " kind" : " generic" ,
828
+ " value" : Object {
829
+ " kind" : " object" ,
830
+ " members" : Array [
831
+ Object {
832
+ " default" : Object {
833
+ " kind" : " number" ,
834
+ " value" : 1 ,
835
+ },
836
+ " key" : Object {
837
+ " kind" : " id" ,
838
+ " name" : " ok" ,
839
+ },
840
+ " kind" : " property" ,
841
+ " optional" : false ,
842
+ " value" : Object {
843
+ " kind" : " number" ,
844
+ },
845
+ },
846
+ ],
847
+ " referenceIdName" : " Props" ,
848
+ },
849
+ },
850
+ " kind" : " program" ,
851
+ }
852
+ ` ;
853
+
824
854
exports [` flow default class export 1` ] = `
825
855
Object {
826
856
" component" : Object {
Original file line number Diff line number Diff line change @@ -213,11 +213,8 @@ function convertReactComponentFunction(path, context) {
213
213
path . hub . file . path . traverse ( {
214
214
// look for MyComponent.defaultProps = ...
215
215
AssignmentExpression ( assignmentPath ) {
216
- const component = convert ( assignmentPath . get ( 'left' ) , {
217
- ...context ,
218
- mode : 'value'
219
- } ) ;
220
- if ( component . object . referenceIdName === name ) {
216
+ const left = assignmentPath . get ( 'left.object' ) ;
217
+ if ( left . isIdentifier ( ) && left . node . name === name ) {
221
218
let initialConversion = convert ( assignmentPath . get ( 'right' ) , {
222
219
...context ,
223
220
mode : 'value'
Original file line number Diff line number Diff line change @@ -1300,6 +1300,36 @@ const TESTS = [
1300
1300
}
1301
1301
}
1302
1302
`
1303
+ } ,
1304
+ {
1305
+ name : 'flow class with this expression' ,
1306
+ typeSystem : 'flow' ,
1307
+ code : `
1308
+ type Props = {
1309
+ ok: number
1310
+ }
1311
+
1312
+ class FieldInner extends React.Component<Props> {
1313
+ unregisterField = () => {};
1314
+
1315
+ componentDidMount() {
1316
+ this.unregisterField = this.register();
1317
+ }
1318
+
1319
+ componentWillUnmount() {
1320
+ this.unregisterField();
1321
+ }
1322
+ }
1323
+
1324
+ const Field = (props: Props) => <FieldInner {...props} />;
1325
+
1326
+ Field.defaultProps = {
1327
+ ok: 1
1328
+ };
1329
+
1330
+ export default Field;
1331
+
1332
+ `
1303
1333
}
1304
1334
] ;
1305
1335
You can’t perform that action at this time.
0 commit comments