# ts-resolve-type

> Get resolved TypeScript type

Latest version **0.1.0-alpha.5** (published 2023-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-resolve-type
pnpm add ts-resolve-type
yarn add ts-resolve-type
bun add ts-resolve-type
```

Provides the command `ts-resolve-type`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.5 |
| Published | 2023-11-29 |
| First published | 2023-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 16 |
| Dependencies | 0 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jędrzej Ginter |
| Maintainers | jedrzejginter |
| Keywords | typescript, type, resolve |

## Links

- npm: https://www.npmjs.com/package/ts-resolve-type
- Repository: https://github.com/jedrzejginter/ts-resolve-type
- Homepage: https://github.com/jedrzejginter/ts-resolve-type#readme
- Issues: https://github.com/jedrzejginter/ts-resolve-type/issues
- npm.io page: https://npm.io/package/ts-resolve-type

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.1.0-alpha.5 (latest) — 2023-11-29
- 0.1.0-alpha.4 — 2023-11-29
- 0.1.0-alpha.3 — 2023-11-29
- 0.1.0-alpha.2 — 2023-11-29
- 0.1.0-alpha.1 — 2023-11-29

## README

# 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

```console
npm i -D ts-resolve-type typescript
```

## Usage

```ts
// 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:

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

Outputs

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

### Node.js

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

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

/*
const resolved = `type InputType = {
  1: number;
  2: number;
  3: number;
};`
*/
```

---
_Source: https://npm.io/package/ts-resolve-type · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
