Skip to Content
ReferenceType Utilities

Type Utilities

TypeScript ships utility types like Omit or Pick to reshape types. When testing types of expressions, use the omit() or pick() utilities to get the same results.

The utilities only reshape types. At runtime they return the same object that was passed as an argument.

omit()

The omit() type utility reshapes the type of the given object by removing the specified keys:

import { , , } from "tstyche"; class <> { : <> = []; get (): number { return this..; } (: ): void { this..(); } } ((new (), "enqueue", "entries"))..<{ readonly : number; }>(); // Equivalent to the 'Omit' utility type <<<string>, "enqueue" | "entries">>()..<{ readonly : number; }>();

pick()

The pick() type utility reshapes the type of the given object by keeping only the specified keys:

import { , , } from "tstyche"; class <> { : <> = []; get (): number { return this..; } (: ): void { this..(); } } ((new (), "size"))..<{ readonly : number }>(); // Equivalent to the 'Pick' utility type <<<string>, "size">>()..<{ readonly : number }>();
Last updated on