# tsc-fancy

> Snazzy utilities around the TypeScript CLI.

Latest version **1.1.2** (published 2018-02-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install tsc-fancy
pnpm add tsc-fancy
yarn add tsc-fancy
bun add tsc-fancy
```

Provides the commands `tscf`, `tsc-fancy`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-02-23 |
| First published | 2018-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Josh Goldberg |
| Maintainers | joshuakgoldberg |

## Links

- npm: https://www.npmjs.com/package/tsc-fancy
- Repository: https://github.com/joshuakgoldberg/tsc-fancy
- Homepage: https://github.com/joshuakgoldberg/tsc-fancy#readme
- Issues: https://github.com/joshuakgoldberg/tsc-fancy/issues
- npm.io page: https://npm.io/package/tsc-fancy

## Recent versions

- 1.1.2 (latest) — 2018-02-23
- 1.1.1 — 2018-02-20
- 1.1.0 — 2018-02-20
- 1.0.0 — 2018-02-16

## README

# `tsc-fancy`
[![Build Status](https://travis-ci.org/JoshuaKGoldberg/tsc-fancy.svg?branch=master)](https://travis-ci.org/joshuakgoldberg/tsc-fancy)
[![npm version](https://badge.fury.io/js/tsc-fancy.svg)](https://www.npmjs.com/package/tsc-fancy)
[![Downloads](https://img.shields.io/npm/dm/tsc-fancy.svg)](https://www.npmjs.com/package/tsc-fancy)

✨ Snazzy utilities around the TypeScript CLI. ✨

```shell
npm install --global tsc-fancy

tsc-fancy
```

_Or for the terse:_

```shell
tscf
```

## What?

Some user-requested features are too esoteric for TypeScript to add them.
That's fine!
We can just stick them here, outside of the main repository. 🔥

Everything passed to the `tsc-fancy` CLI that it doesn't recognize is given directly to `tsc`.
Thus, you can use `tsc-fancy` as a drop-in replacement for `tsc`.

## CLI Flags

### `--preserveConsoleOutput`

Use with `tsc`'s `-w`/`--watch` mode to stop it from clearing the screen on recompiles.
This is useful for tools such as monorepo build aggregators that run multiple `tsc` instances at once.

```shell
> tsc-fancy --preserveConsoleOutput --pretty --watch

[1:23:45 PM] Compilation complete. Watching for file changes.
[1:23:56 PM] File change detected. Starting incremental compilation...
[1:23:56 PM] Compilation complete. Watching for file changes.
```

See [TypeScript#21295](https://github.com/Microsoft/TypeScript/issues/21295).

> `--preserveConsoleOutput` uses `--replace` logic under the hood to remove the console clearing character `\x1Bc` / `\u001bc`.

### `--replace`

Replaces TSC characters with your own.
Each replacement is converted to a `RegExp` with the `/gi` flag.

```shell
> tsc-fancy --replace error "Oh dearest me!" --pretty false

src/file.ts(1,5): Oh dearest me! TS2322: Type '"no"' is not assignable to type 'number'.
src/file.ts(2,5): Oh dearest me! TS2322: Type '"yes"' is not assignable to type 'number'.
```

### `--tsc`

Alias of the tsc executable to [`exec`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback), if not `"tsc"`.

```shell
> tsc-fancy --tsc ../TypeScript/built/local/tsc.js
```

## Programmatic Usage

This package exposes an `execTsc` method that takes in an options object and returns the spawned [`ChildProcess`](https://nodejs.org/api/child_process.html).

```typescript
import { execTsc } from "tsc-fancy";

execTsc()
    .on("close", (code: number) => {
        console.log("All done! Exit code:", code);
    });
    .on("error", (error: error) => {
        console.log("Oh no! Error:", error);
    });
```

The options object's type is exported as `ExecTscOptions`.

### `args: string[]`

Arguments to directly pass to `tsc`.

```typescript
execTsc({
    args: ["--p", ".", "--watch"],
});
```

> In CLI usage, these are everything not known by `tsc-fancy`.

### `replacers: Map<RegExp, string>`

Regular expressions with text to replace them with.

```typescript
execTsc({
    replacers: new Map([
        [/error/gi, "Oh dearest me!"],
    ]),
});
```

### `tsc: string`

Alias of the tsc executable to [`exec`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback), if not `"tsc"`.

```typescript
execTsc({
    tsc: "../TypeScript/built/local/tsc.js",
});
```

## Contributing

🙌 See [Contributing.md](./CONTRIBUTING.md). 🙌

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