Skip to content

Commit da9ab6a

Browse files
dmytrorykunblakef
authored andcommitted
SVC Codegen: Handle TSAsExpression when looking for the codegen declaration (#40860)
Summary: Pull Request resolved: #40860 This diff adds support for the `AS` expression in TS sources. The following codegen declaration should work now: ``` export default codegenNativeComponent<NativeProps>( 'MyComponentView', ) as HostComponent<NativeProps>; ``` Changelog: [General][Added] - Handle TSAsExpression when looking for the codegen declaration Reviewed By: shwanton Differential Revision: D50225241 fbshipit-source-id: 247a3d341d742b548e82318d0fa21dff9884d2bd
1 parent 5d85296 commit da9ab6a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/babel-plugin-codegen/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ function isCodegenDeclaration(declaration) {
8383
declaration.expression.callee.name === 'codegenNativeComponent'
8484
) {
8585
return true;
86+
} else if (
87+
declaration.type === 'TSAsExpression' &&
88+
declaration.expression &&
89+
declaration.expression.callee &&
90+
declaration.expression.callee.name &&
91+
declaration.expression.callee.name === 'codegenNativeComponent'
92+
) {
93+
return true;
8694
}
8795

8896
return false;

0 commit comments

Comments
 (0)