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

1.0.3 • Public • Published


First, run npm install --save @cw-types/ambient-types

Then, you must add node_modules/@cw-types to your tsconifg.json file, like so:

    "typeRoots": [

This will enable the Typescript compiler to find and use this typing since it is not installed under node_modules/@types.

Please note the order is important of the entries in typeRoots. If you want node_modules/@types to resolve first then move it up top.


Typings library for common ambient (global) types.

Here are some examples:

// All primitive types
type TPrimitive = boolean | number | string | symbol;

type TNullOrUndefined = null | undefined;

type TPrimitiveAll = TPrimitive | TNullOrUndefined;

type TNotVoid = object | TPrimitiveAll;

type ReadonlyRecurse<T> = {readonly [P in keyof T]: ReadonlyRecurse<T>; }
type PartialRecurse<T> = {[P in keyof T]?: PartialRecurse<T[P]>; }

 * Cycle all properties in T to make them a flat type from
 * a union of many types.
type Cycle<T> = {
  [P in keyof T]: T[P];

 * Make all properties in T Required
type Required<T> = {
  [P in keyof T]: T[P];

type TEmptyObject = {};

type RecordOf<TObj, TValue> = {[P in keyof TObj]: TValue; };

type TIndexerTo<T> = { [key: string]: T; };
type TIndexerToAny = TIndexerTo<any>;
type TIndexerToString = TIndexerTo<string>;
type TIndexerToBoolean = TIndexerTo<boolean>;
type TIndexerToNumber = TIndexerTo<number>;
type TIndexerToObject = TIndexerTo<object>;


This project is mainted by Kavan J. Shaban at Cycloware

Package Sidebar


npm i @cw-types/ambient-types

Weekly Downloads






Last publish