Socket
Book a DemoInstallSign in
Socket

@density/lib-common-types

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@density/lib-common-types

Common types and enums

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
6
Created
Source

lib-common-types

Common types and enums used by Density TypeScript projects.

Setup

Common types can be used in any TypeScript file with a standard import:

import { DayOfWeek } from '@density/lib-common-types';

Recommended ambient/global types are also provided in the global.d.ts file. We provide three special Any<T> types which should be used in place of explicit any declarations (as the normal rule). Implicit any should be disallowed by the typescript compiler if possible. To use the global Any<T> types, add this triple-slash directive to an index file in your project:

/// <reference path="../node_modules/@density/lib-common-types/global.d.ts" />

The three generic parameters compatible with this Any<T> type are as follows:

// When you don't have time to think about types, or intend to come back before review, use Any<InAHurry>
const foo: Any<InAHurry> = 123;

// When you intend to define a type before shipping, or would like the reviewer to do so, use Any<FixInReview>
const bar: Any<FixInReview> = 123;

// All above types that are not replaced in review should be converted to Any<FixInRefactor>
const baz: Any<FixInRefactor> = 123;

// The true `any` type should only be used in exceptional cases, and is discouraged
// This ejects from type analysis indefinitely and leaves a mini-booby-trap that we intend to live with
const quux: any = someLibrary().unpredictableFactoryWhatnot();

FAQs

Package last updated on 08 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts