# get-type-text

> ample-project

Latest version **0.0.5** (published 2019-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-type-text
pnpm add get-type-text
yarn add get-type-text
bun add get-type-text
```

Provides the command `get-type-text`.

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2019-03-19 |
| First published | 2019-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Sebastián Gurin |
| Maintainers | cancerberosgx |
| Keywords | JavaScript, TypeScript, utilities, miscellaneous |

## Links

- npm: https://www.npmjs.com/package/get-type-text
- Repository: https://github.com/cancerberoSgx/misc-utils-of-mine
- Homepage: https://github.com/cancerberoSgx/misc-utils-of-mine#readme
- Issues: https://github.com/cancerberoSgx/misc-utils-of-mine/issues
- npm.io page: https://npm.io/package/get-type-text

## Dependencies (1)

- [yargs-parser](https://npm.io/package/yargs-parser.md) ^13.0.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2019-03-19
- 0.0.4 — 2019-03-18
- 0.0.3 — 2019-03-18
- 0.0.2 — 2019-03-18
- 0.0.1 — 2019-03-18

## README

# get-type-text 

An unconventional way of getting a type text at runtime in TypeScript

# Why ?

 * https://github.com/Microsoft/TypeScript/issues/14419
 * I need to get a type text at runtime and I cannot hardcode it as string since it will get outdated on code refactors
 * I don't want to use a tsc wrapper like ttypescript
 
# What ?

```
npm install -D get-type-text
```

```ts
import TypeText from 'get-type-text'
import { UnionOf } from '..'
const x = TypeText<UnionOf<[1, Date[]]>>()
const z = TypeText<UnionOf<[1, boolean | string]>>()
console.log(x, z)
```

Executing the program gives, as expected:

```sh
undefined undefined
```

But executing:

```sh
npx get-type-text
```

and running the program again we get:

```sh
Type<Date> { a: 'a' } { a: "a" }
UnionOf<[1, Date[]]> UnionOf<[1, boolean | string]>
```

But at a terrible cost, go back to your source file and see how it changed:

```ts
import TypeText from 'get-type-text'
import { UnionOf } from '..'
const x = TypeText<UnionOf<[1, Date[]]>>('UnionOf<[1, Date[]]>')
const z = TypeText<UnionOf<[1, boolean | string]>>('UnionOf<[1, boolean | string]>')
console.log(x, z)
```

## Options


## Workflow

Basically use this only for test projects. Run `npx get-type-text` before `npm test` or `tsc`, `ts-node`, `jest`, etc. 

### Rollback

To rollback the changes execute the following command. It will clean all the added arguments:

```
npx get-type-string --cleanArguments
```

# API

 * [Per-project JS API](api/interfaces/_types_.config.md)
 * [Per-file JS API](api/interfaces/_types_.replacefunctioncallsoptions.md)

(all the options apply to the CLI)


## Motivation

Trying to test types utilities, like:

```ts
import TypeText from 'get-type-text'
import { UnionOf } from '..'
test('UnionOf transform a tuple into an union type', () => {
  expect(2).not.toMatchType(TypeText<UnionOf<[1, false]>>)
  expect(1).toMatchType(TypeText<UnionOf<[1, false]>>)
})
```

Trying to develop a preprocessing tool to mutate TypeScript and replace certain function call expressions with referenced type text so we have access to this info at runtime. tsd-check is not enough for me since I need to verify types at runtime to reproduce false positives, and isNot helpers. (I cannot reproduce an error at compile time in a test)

## TODO / ISSUES

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