> Next, let's go to the frontend … const user = cast<User>(userJson);
Wait, how can Deepkit's `cast` work on the frontend? Do you compile to WASM?
Quickly skimming the current Deepkit homepage and intro blog post didn't seem to hint at this.
Wait, how can Deepkit's `cast` work on the frontend? Do you compile to WASM?
Quickly skimming the current Deepkit homepage and intro blog post didn't seem to hint at this.
My summary is that the DeepKit compiler is a JS transpiler (used as a ts-node or webpack plugin, or conveniently/invasively as a replacement of node_modules/typescript) that produces code like this:
//TypeScript
export type TypeA = string[];
//generated JavaScript
export const __ΩtypeA = ['&F'];
//TypeScript
function log(message: string): void {}
//generated JavaScript
function log(message) {}
log.__type = ['message', 'log', 'P&2!$/"'];
Where '&F' and 'P&2!$/"' are the compact bytecode translations of the types ("&" means string, "F" means array) and '__Ω' is a prefix used to avoid naming conflicts.Personally, I'd love to see a live example of code in & compiled code out on the homepage. I'm sure it's on your roadmap :)