Skip to content

Commit

Permalink
SVC Codegen: Handle TSAsExpression when looking for the codegen decla…
Browse files Browse the repository at this point in the history
…ration (#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
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Oct 12, 2023
1 parent eef823b commit 0295771
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/babel-plugin-codegen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ function isCodegenDeclaration(declaration) {
declaration.expression.callee.name === 'codegenNativeComponent'
) {
return true;
} else if (
declaration.type === 'TSAsExpression' &&
declaration.expression &&
declaration.expression.callee &&
declaration.expression.callee.name &&
declaration.expression.callee.name === 'codegenNativeComponent'
) {
return true;
}

return false;
Expand Down

0 comments on commit 0295771

Please sign in to comment.