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 (facebook#40860)

Summary:

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
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Oct 12, 2023
1 parent 11d9b9c commit adf44a6
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 adf44a6

Please sign in to comment.