Get the latest tech news

Comptime.ts: compile-time expressions for TypeScript


A simple-to-use compiler and Vite plugin to evaluate TypeScript expressions at build time.

Apart from function calls and tagged template literals, all sorts of expressions are supported (even complex ones like index access and simple ones like imported constants). Avoid using comptime for: Complex runtime logic Side effects Non-deterministic operations (unless you understand the implications) Note: To force comptime.ts to print the constructed evaluation block for each expression and other debug logs, set the environment variable DEBUG=comptime:*.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of TypeScript

TypeScript

Photo of Comptime.ts

Comptime.ts

Photo of time expressions

time expressions

Related news:

News photo

Rust, Python, and TypeScript: the new trifecta

News photo

A parser for TypeScript types, written in TypeScript types

News photo

Show HN: Tsbro – TypeScript for the browser, no build step