Hacker News new | ask | show | jobs
by MKRhere 306 days ago
Author here.

To be clear, what you're asking for is basically:

const X = comptime(condition ? A : B);

and have it compile down to

const X = A;

without attempting to serialise the functions themselves. Is this correct? The way comptime.ts currently works is that it runs the expression in a constructed block. But perhaps a new primitive, like

import { conditional } from "comptime.ts" with { type: "comptime" };

const X = conditional(condition, X, Y);

Might work though! I'm also interested in conditional comptime code removal, but not sure about the API design there. I know bundlers already do it, but I'd like for it to be possible in source->source transformations too, for example shipping a version of a library with debugs/traces.

Feel free to open an issue if you'd like to discuss ideas.