JSPM

  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q66414F
  • License MIT

Common mappings, aliases, and types used in Toreda TypeScript packages.

Package Exports

  • @toreda/types
  • @toreda/types/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@toreda/types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Toreda

CI Coverage Sonar Quality Gate

GitHub package.json version (branch) GitHub Release Date GitHub issues

license

@toreda/types

Improve readability while reducing redundancy. Provides both functional and expressive type definitions commonly used in Toreda

 

Functional Types

Types & aliases provide shorthand to reduce code duplication and simplify statements.

Example

// Simple generic mapping. When used only once, exporting a type is overkill, but when used repeatedly
// using a common definition reduces chances for mistakes and reduces line lengths.
export type Data<T> = Record<string, T | T[] | null>;

Expressive Types

Provides additional context and hints about expected types.

Example

// Expressive Type alias.
export type BigId = string;

// BigId is an expressive alias replacing the use of 'string' for id's type. It makes no
// functional difference, however id types often impose character and length limitations meaning
// the value cannot be an arbitrary string. BigId gives the caller context for what string values
// are actually valid & accepted.
function validateId(id: BigId): void {
    ...
}

 

Contents

 

Install

Yarn

$ yarn add @toreda/types --dev

NPM

$ yarn add @toreda/types --D

 

Legal

License

MIT © Toreda, Inc.

 

Copyright © 2019 - 2022 Toreda, Inc. All Rights Reserved.

https://www.toreda.com