0.1.0-alpha.5 • Published 5 months ago

ts-resolve-type v0.1.0-alpha.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

ts-resolve-type

Requirements

  • Node 16 or higher
  • TypeScript 5 or higher
    • strict: true in tsconfig.json

Known limitations

  • The type has to be export'ed
    • Most probably it's because TypeScript checker ignores types that are not used (??)
  • Does not resolve enum
  • Does not preserve function argument names
    • Prints args_0, args_1 etc instead of original function arguments names

Installation

npm i -D ts-resolve-type typescript

Usage

// src/index.ts
type Keys = 1 | 2 | 3;

export type InputType = {
  [K in Keys]: number;
};

CLI

Find InputType in src/index.ts file and get the output type:

npx ts-resolve-type src/index.ts InputType

Outputs

type InputType = {
  1: number;
  2: number;
  3: number;
};

Node.js

import { resolve } from "ts-resolve-type";

const resolved = await resolve("./src/index.ts", "InputType");

/*
const resolved = `type InputType = {
  1: number;
  2: number;
  3: number;
};`
*/
0.1.0-alpha.5

5 months ago

0.1.0-alpha.4

5 months ago

0.1.0-alpha.3

5 months ago

0.1.0-alpha.2

5 months ago

0.1.0-alpha.1

5 months ago