Converts JavaScript Enums to TypeScript Enums
| .gitignore | ||
| converter.py | ||
| README.md | ||
| to_const.py | ||
| to_enum.py | ||
| util.py | ||
JStoTSenum
Coded this as a tool to speed up Typing of DoctorMcKay/node-steam-user This converter takes JavaScript Enums like these:
module.exports = {
"NoCost": 0,
"BillOnceOnly": 1,
"BillMonthly": 2,
"ProofOfPrepurchaseOnly": 3,
"GuestPass": 4,
"HardwarePromo": 5,
"Gift": 6,
}
and converts them to TypeScript Enums like this:
export enum EBillingType {
"NoCost" = 0;
"BillOnceOnly" = 1;
"BillMonthly" = 2;
"ProofOfPrepurchaseOnly" = 3;
"GuestPass" = 4;
"HardwarePromo" = 5;
"Gift" = 6;
}
Enum naming is based on the JavaScript Filenames, so there can only be one Enum per JavaScript file. The converter takes a directory full of JavaScript files as input, and the output directory can be configured.