Hi,

I wanted to plug my own project for some time here on the mailing list
because it also handles JavaScript - C++ interop and now wajic came up so I
thought I pitch in.

My project https://github.com/think-cell/typescripten produces type-safe
C++ interfaces to JavaScript standard libraries or third-party libraries.
It reads TypeScript interface definition files and transforms them into C++
shims based on emscripten.

The resulting C++ code is often a straight-forward port from
TypeScript/JavaScript, e.g.,

JavaScript:

var elem = document.createElement("p")
elem.innerText = "Hello CppCon 2021"
elem.style.fontSize = "20.0"
document.body.appendChild(elem)

C++:

auto elem = js::document()->createElement(js::string("p"));
elem->innerText(js::string("Hello CppCon 2021"));
elem->style()->fontSize(js::string("20vh"));
js::document()->body()->appendChild(elem);

No macros and the C++ functions return typed JavaScript objects! Because we
use the TypeScript interface definitions, the C++ code is typechecked.
Passing a number to fontSize will create a compiler error.

The project is not yet meaningfully complete but it bootstraps
successfully, i.e., the compiler understands the interface definition file
for the TypeScript compiler and parser API that it uses itself. TypeScript
generic constraints are not yet supported, for example, but should be.

Maybe somebody else finds this useful. We have used it internally for a
small web app already that needed to call the tableau.com JavaScript API.

Regards
Sebastian

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAN%3D%3DuddahRRPV02%3DT9TaQd2%3D3YzxqHDBAqg8%3DsWJL-Taqh4-SQ%40mail.gmail.com.

Reply via email to