0.0.6 • Published 2 years ago

@ts-r/cli v0.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

ts.runtime

This tool converts TypeScript types into TS Runtime objects.

Usage - via CLI

Install it globally:

npm i ts.runtime -g

We have this file:

// test/test.ts
export type Type = string | 4 | 2 | boolean;

To convert the type in the file above, we do this:

ts.runtime test/test.ts

This generates the TS Runtime objects from the types in the file and prints them:

export type Type = string | 4 | 2 | boolean;

export type TsRuntimeObject_Type = {
  type: "union";
  members: [
    { type: "string" },
    { type: "number"; value: 4 },
    { type: "number"; value: 2 },
    { type: "boolean" }
  ];
};

Usage - via programmatic interface

You can use ts.runtime in your projects.

npm i ts.runtime

In our project, we import generateTSRuntimeObjectFromFile from ts.runtime:

import { generateTSRuntimeObjectFromFile } from "ts.runtime";

const tsRuntimeObject = generateTSRuntimeObjectFromFile("test/test.ts");
0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.1-alpha.1

2 years ago