Is there any way to compile types using generics?

Viewed 41

I'm creating a type definition-only module (only *.d.ts files ) for an API. I'm using some complex generics to shorten the source code and avoid mistakes. The types are so complicated they're taking a while to load (ex: vscode showing type on hover) and even tripping up typescript (types are compiling incorrectly).

Is there any way to compile the types using generics beforehand?

For example, having this...

// index.ts
type A = 'hello'
type B<A extends string> = `${A} world!`
type C = B<A>

... compile to this.

/// index.d.ts
type A = 'hello'
type B<A extends string> = `${A} world!`
type C = 'hello world!'
0 Answers
Related