[go: up one dir, main page]

yatts-typescript
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

yatts-typescript

Keep your typescript version synchronized with a patched version that exposes internal definitions and some private methods for type checking.

How does it work?

When you run pnpm yatts-typescript-sync, it will look for your installed version of typescript, make a copy in its own location, apply the patches and re-export the patched version. So you can import yatts-typescript and enjoy your patched version of typescript while keeping your original version intact.

What does it add/remove?

  1. Removes all @internal tags which allows you to access internal types, classes, properties and methods with their declarations.

  2. Export some very useful private methods from the TypeChecker:

    function isTypeSubtypeOf(source: Type, target: Type): boolean;
    function isTypeIdenticalTo(source: Type, target: Type): boolean;
    function isTypeDerivedFrom(source: Type, target: Type): boolean;
    function isTypeAssignableTo(source: Type, target: Type): boolean;
    function isTypeComparableTo(source: Type, target: Type): boolean;
    function areTypesComparable(source: Type, target: Type): boolean;

Installation

pnpm add typescript yatts-typescript

Keep yatts-typescript in sync with each installation/update of typescript

Add an postinstall or prepare field in your package.json with pnpm yatts-typescript-sync in it.

{
  "postinstall": "pnpm yatts-typescript-sync"
}

Usage

import ts from 'yatts-typescript';

// Use ts as usual.

Programmatic API

import { patch } from 'yatts-typescript/patch';

const { error, success, modulePath } = patch(options);

Options

  • typescriptModuleId: string | undefined - Default to typescript.
  • outputDirectory: string | undefined - Default to node_modules/yatts-typescript/lib.
  • patchRules: [PatchRule, ...PatchRule[]] | undefined - Default to undefined.
  • additionalPatchRules: PatchRule[] | undefined - Default to undefined.

Alternatives

yatts-typescript is a combination of the alternatives listed below. But instead of maintaining an up-to-date build of typescript we use your locally installed version.

Remove @internal tags

  • byots Bring your own TypeScript with more internal definitions
  • ts-expose-internals Expose TypeScript internal types by simply adding a development dependency

Expose TypeChecker methods

Remove @internal tags and expose TypeChecker methods

  • unleashed-typescript TypeScript with exposed internal definitions and some private methods for type checking.

Scaffolded with @skarab/skaffold

Package Sidebar

Install

npm i yatts-typescript

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

15.3 kB

Total Files

11

Last publish

Collaborators

  • skarab