@axel-hq/fddtsc
v0.2.0
Published
<i><u>f</u>oun<u>d</u>atsion <u>d</u>eclaration <u>t</u>ype<u>s</u>cript file <u>c</u>ompiler</i>
Downloads
13
Readme
fddtsc
foundatsion declaration typescript file compiler
usage
ffaq (fake frequently asked questions)
This, here, is the compiler magic that makes newtypes disappear within d.ts files.
transform calls //!
Leading comments (comments directly above a type) trigger type transforms.
foundatsion::newtype
: every reference to this type is replaced withunknown
.foundatsion::unwrap
: every reference to this type is replaced with it's first type argument.foundatsion::bake
: this type's simplification is baked into the output.
// @file example.ts
//! foundatsion::unwrap
type bar<baz> = never;
type reverse_string<s extends string> =
s extends `${infer head}${infer tail}`
? `${reverse_string<tail>}${head}`
: "";
export type so = bar<"shouldn't this be never?">;
//! foundatsion::bake
export type baked = reverse_string<"Hello, World!">;
// @file example.d.ts
export type so = "shouldn't this be never?";
export type baked = "!dlroW ,olleH";
for Reasons We Do Not Fully Understand, neither newtype nor unwrap work all the time
for developers
make install
make build
make install
(again to install what you just built into the test)make test