@@ -42,29 +42,28 @@ export function reactStatelessFunctionMakePropsTransformFactoryFactory(typeCheck
42
42
}
43
43
44
44
function visitSourceFile ( sourceFile : ts . SourceFile , typeChecker : ts . TypeChecker ) {
45
- let statements = sourceFile . statements ;
46
-
47
45
// Look for propType assignment statements
48
- const propTypeAssignments = statements . filter ( statement =>
46
+ const propTypeAssignments = sourceFile . statements . filter ( statement =>
49
47
helpers . isReactPropTypeAssignmentStatement ( statement ) ,
50
48
) as ts . ExpressionStatement [ ] ;
51
49
50
+ let newSourceFile = sourceFile ;
52
51
for ( const propTypeAssignment of propTypeAssignments ) {
53
- const componentName = helpers . getComponentName ( propTypeAssignment , sourceFile ) ;
52
+ const componentName = helpers . getComponentName ( propTypeAssignment , newSourceFile ) ;
54
53
55
- const funcComponent = ( _ . find ( statements , s => {
54
+ const funcComponent = ( _ . find ( newSourceFile . statements , s => {
56
55
return (
57
56
( ts . isFunctionDeclaration ( s ) && s . name !== undefined && s . name . getText ( ) === componentName ) ||
58
57
( ts . isVariableStatement ( s ) && s . declarationList . declarations [ 0 ] . name . getText ( ) === componentName )
59
58
) ;
60
59
} ) as { } ) as ts . FunctionDeclaration | ts . VariableStatement ; // Type weirdness
61
60
62
61
if ( funcComponent ) {
63
- return visitReactStatelessComponent ( funcComponent , propTypeAssignment , sourceFile ) ;
62
+ newSourceFile = visitReactStatelessComponent ( funcComponent , propTypeAssignment , newSourceFile ) ;
64
63
}
65
64
}
66
65
67
- return sourceFile ;
66
+ return newSourceFile ;
68
67
}
69
68
70
69
function visitReactStatelessComponent (
0 commit comments