//ts code
function div(props?: { id?: String; style?: any }) {
return function(...children: ReactNode[]) {
return createElement("div", props, ...children);
};
}
const d = div({ id: "hello" })("welcome to TS");
Generated JS code
function div(props) {
return function () {
var children = [];
for (var _i = 0; _i < arguments.length; _i++) {
children[_i] = arguments[_i];
}
return createElement("div",props,...);
};
}
var d = div({ id: "hello" })("welcome to TS");
// Trying to achieve
var d = createElement("div",{ id: "hello" },"welcome to TS")
does typescript support @inline functions ? if not whats the best way achieve similar ..
does typescript support @inline functions ?
No.
if not whats the best way achieve similar
You will have to write a tool yourself. I would just not worry about it.
Use the TypeScript compiler to find references to functions you want to inline, and then interpolate the function body to that location.
Start: Some compiler docs https://basarat.gitbook.io/typescript/overview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With