webidl2ts
webidl2ts copied to clipboard
...doesn't like inheritance with underscores
Hi, thank you for this great project!
I tried to use this tool on this idl file (I am using Emscripten in this project). With that file, I get the following error.
$ yarn webidl2ts -i ./opencascade.idl -n opencascade -ed -o ./dist/opencascade.d.ts
yarn run v1.22.4
$ /home/sebastian/Projects/opencascade.js/node_modules/.bin/webidl2ts -i ./opencascade.idl -n opencascade -ed -o ./dist/opencascade.d.ts
(node:173512) UnhandledPromiseRejectionWarning: WebIDLParseError: Syntax error at line 107, since `interface BRepPrimAPI_MakeCylinder`:
BRepPrimAPI_MakeCylinder implements BRepPrimAPI_MakeOneAxis;
^ Unrecognised tokens
at tokeniser_Tokeniser.error (/home/sebastian/Projects/opencascade.js/node_modules/webidl2/dist/webidl2.js:1:20350)
at r (/home/sebastian/Projects/opencascade.js/node_modules/webidl2/dist/webidl2.js:1:33487)
at L (/home/sebastian/Projects/opencascade.js/node_modules/webidl2/dist/webidl2.js:1:34464)
at Module.q (/home/sebastian/Projects/opencascade.js/node_modules/webidl2/dist/webidl2.js:1:34604)
at Object.<anonymous> (/home/sebastian/Projects/opencascade.js/node_modules/webidl2ts/dist/parse-idl.js:47:43)
at step (/home/sebastian/Projects/opencascade.js/node_modules/webidl2ts/dist/parse-idl.js:33:23)
at Object.next (/home/sebastian/Projects/opencascade.js/node_modules/webidl2ts/dist/parse-idl.js:14:53)
at /home/sebastian/Projects/opencascade.js/node_modules/webidl2ts/dist/parse-idl.js:8:71
at new Promise (<anonymous>)
at __awaiter (/home/sebastian/Projects/opencascade.js/node_modules/webidl2ts/dist/parse-idl.js:4:12)
(node:173512) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:173512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 0.87s.
I found a workaround: If I replace all underscores with some arbitrary text, it works. Seems to me like this could be a bug which is somehow related to inheritance and underscores.
Thank you for the report and i am sorry i missed the issue. Your provided IDL file is not available any more.
Emscripten uses an old Web IDL version. This project uses webidl2 to parse given IDL file and it breaks an anything that does not meet the specification of webidl2.
This tool tries to fix the given IDL if emscripten mode is enabled. Your IDL probably hits a case, where i dont have a fix available. https://github.com/giniedp/webidl2ts/blob/master/src/fixes.ts#L2
Please provide your IDL, so i can check it.