ts-macros
ts-macros copied to clipboard
[BUG] I'm trying to replicatee something closer to the PROPERTY macro in Qt
Describe the bug Does not work inside classes
Code to reproduce
function $property() {
property = 0
}
$property!()
export class ArduPilotSub extends Vehicle.Abstract {
$property!()
constructor() {
super(Vehicle.Firmware.ArduPilot, Vehicle.Type.Sub)
}
}
Expected behavior The output would be something like:
export class ArduPilotSub extends Vehicle.Abstract {
property = 0;
constructor() {
super(Vehicle.Firmware.ArduPilot, Vehicle.Type.Sub);
}
}
Ref: https://doc.qt.io/qt-5/properties.html
Additional context
It would be nice to have more examples, like:
How do I use a type as a parameter.
$macro!(number, test, 0)
Generating something like:
const test: number = 0
Yeah, this is not possible currently because macro calls are just regular function calls, you can only use them where you can call functions :(.
As of using a macro parameter as a type - this isn't really possible either because code generated from macros is not type-checked.