Installation
Install and set up typist in your TypeScript project
Get started with typist by installing it in your TypeScript project. Typist requires TypeScript 4.5 or later for optimal type inference and error reporting.
Install using your preferred package manager:
Prerequisites
Before installing typist, ensure your development environment meets these requirements:
- TypeScript 4.5+ - Required for optimal type inference and error reporting
- Node.js 14+ - For development and build tooling
- A TypeScript-compatible editor - VS Code, WebStorm, or similar with TypeScript support
Package Installation
Install typist using your preferred package manager:
# npm
npm install @type-first/typist
# yarn
yarn add @type-first/typist
# pnpm
pnpm add @type-first/typist
# Verify installation
npx tsc --noEmit
npm testTypeScript Configuration
Typist works best with strict TypeScript settings. Add these recommended settings to your tsconfig.json:
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
}
}Verification
Verify your installation by creating a simple test file:
// test-typist.ts
import { t_, $Equal, yes_ } from '@type-first/typist';
// Create a phantom value
const stringValue = t_<string>();
// Test type equality
type StringsAreEqual = $Equal<string, string>;
yes_<StringsAreEqual>(); // ✅ Should compile without errors
console.log('Typist is working correctly!');Run the verification:
npx tsc test-typist.ts --noEmit
node test-typist.jsIDE Setup
VS Code
For the best experience with typist in VS Code, install these recommended extensions:
- TypeScript Importer - Auto-imports typist utilities
- Error Lens - Inline type error display
- TypeScript Hero - Enhanced TypeScript tooling
Settings
Add these settings to your VS Code workspace:
{
"typescript.preferences.strictNullChecks": "on",
"typescript.preferences.noImplicitAny": "on",
"typescript.displayPartsForJSDoc": true,
"typescript.suggest.autoImports": "on"
}Project Integration
Build Integration
Typist works seamlessly with all major build tools:
- Webpack - Works out of the box with ts-loader
- Vite - Native TypeScript support includes typist
- esbuild - TypeScript transformation handles typist utilities
- Rollup - Use with @rollup/plugin-typescript
Testing
Typist type assertions work great with testing frameworks:
// In your test files
import { $Equal, yes_, no_ } from '@type-first/typist';
describe('Type Tests', () => {
it('should validate user type structure', () => {
type User = { id: string; name: string };
type ValidUser = { id: string; name: string };
// This will cause a compile error if types don't match
yes_<$Equal<User, ValidUser>>();
});
});Troubleshooting
Common Issues
Module not found
If you see Cannot find module '@type-first/typist', ensure:
- The package is installed in your project
- Your
node_modulesdirectory is not corrupted - TypeScript can resolve the module path
Type errors in strict mode
Typist is designed for strict TypeScript. If you're seeing unexpected type errors:
- Enable strict mode in your tsconfig.json
- Update to TypeScript 4.5 or later
- Check our Troubleshooting Guide
✅ Next Steps
Installation complete! Head over to the Quick Start Guide to begin using typist in your project.