Skip to content

nyaomaru/variance-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

variance-check

This repository contains the sample code used in the variance article.
You can verify TypeScript’s behavior under different variance-related compiler settings.

covariant.ts and invariant.ts intentionally contain type errors for variance testing.

Setup

pnpm install

How to run the checks

Run the following commands to compare strict (theoretical) variance checks with TypeScript’s more permissive behavior:

pnpm exec tsc -p tsconfig.json
pnpm exec tsc -p tsconfig.strict.json
  • tsconfig.json: strictFunctionTypes: false — shows TypeScript’s bivariant function parameter behavior
  • tsconfig.strict.json: strictFunctionTypes: true — closer to the theoretical, sound variance rules

Use these two modes to observe how arrays, function parameters, and generic types behave differently under each configuration.

About

This repository is for variance article to check the correct type prediction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published