Enjoy type-level programming with TypeScript!
npm install compile-time-typescriptEnjoy type-level programming with TypeScript!
``shell`
$ npm install -g compile-time-typescript
`shell`
$ ctts script.ts
There are several examples under examples/. For example, hello.ts:
`typescriptHello, ${Input}!\n
type Main = ;`
export default Main;
`shell`
$ echo -n "world" | ctts hello.ts
Hello, world!
- From TypeScript 4.1
- Template Literal Types
- Recursive Conditional Types
- From TypeScript 4.5
- Tail-Recursion Elimination on Conditional Types
- From TypeScript 4.7
- extends Constraints on infer Type Variables
When ctts script.ts is executed, compile-time-typescript creates a caller like this:
`typescript`
import Main from "/path/to/script";
type Input = "HERE COMES THE INPUT";
type Output = Main;
So the program must have a default export of a generic type that takes a type parameter and constructs a string literal type.
Then compile-time-typescript type-checks the caller and extracts the type information of Output.
If Output` is a string literal type, its content is printed. Otherwise, an error occurs.
- hakatashi/esolang-box - Easy and standardized docker images for 200+ esoteric (and non-esoteric) languages.
- 型レベル TypeScript の esolang としての展望について - Qiita
- 第7回Esolang Codegolf Contest Writeup · hakatashi/esolang-battle Wiki