ts-vista

raw JSON →
0.2.3 verified Sat Apr 25 auth: no javascript

A utility to enhance TypeScript by providing additional type utilities and transformations. Current stable version is 0.2.3, with release cadence being sporadic as it is early-stage. It differentiates by offering basic type enhancements with a focus on simplicity and sourcemap support (since 0.2.0). Suitable for small to medium projects that need lightweight type utilities without heavy dependencies.

error Cannot find module 'ts-vista' or its corresponding type declarations.
cause Package may not be installed, or TypeScript is not resolving types correctly.
fix
Run 'npm install ts-vista' and ensure tsconfig.json includes 'node_modules' in typeRoots.
error This expression is not callable. Type 'typeof import("ts-vista")' has no call signatures.
cause Attempting to import the module as a default export using require() in a CommonJS context.
fix
Use proper ESM import syntax: import { ... } from 'ts-vista'.
gotcha package requires TypeScript 4+ due to use of template literal types
fix Upgrade TypeScript to version 4 or higher.
breaking sourcemap support added in v0.2.0; older versions do not emit sourcemaps
fix Update to v0.2.0+ to get sourcemap support.
npm install ts-vista
yarn add ts-vista
pnpm add ts-vista

Import and use the TypeAssertion utility to safely narrow unknown types.

import { TypeAssertion } from 'ts-vista';

// Ensure a value is of a specific type
const assertString = TypeAssertion<string>((v): v is string => typeof v === 'string');
const value: unknown = 'hello';
const result = assertString(value); // type: string, throws if not
console.log(result);