Currently, I am employing JSX syntax in my TypeScript node.js project (without relying on React).
Within my tsconfig
, I have specified my custom jsxFactory
{
"compilerOptions": {
...
"jsxFactory": "myJSXFactory",
...
}
}
<MyBanner backgroundColor="red" />
Everything is functioning smoothly and the above JSX gets transformed to this post TSC compilation
myJSXFactory(MyBanner, {
backgroundColor: 'red'
});
At this juncture, I desire to append additional props
to All
JSX components at compile time, as shown below:
myJSXFactory(MyBanner, {
backgroundColor: 'red',
theme: myTheme // a variable accessible in the parent context
});
I delved into the Compiler API for guidance, but it's somewhat vague on how to edit the source during JSX transformation.