Socket
Socket
Sign inDemoInstall

subtractiontype.ts

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    subtractiontype.ts

Subtraction types for TypeScript: e.g. Sub<'a' | 'b', 'a'> and Dissoc<{a: number, b: number}, 'a'>


Version published
Weekly downloads
13
decreased by-68.29%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

subtractiontype.ts

Subtraction types for TypeScript: e.g. Sub<'a' | 'b', 'a'> and Dissoc<{a: number, b: number}, 'a'>.

Installation

npm install --save-dev subtractiontype.ts

Usage

// with modules
import {Sub, Dissoc} from 'subtractiontype.ts'

// without modules (yes, it says 'import', but it still doesn't count as a module and you 
// don't have to repeat the type parameters like you would with `type = `)
///<reference path="node_modules/subtractiontype.ts/index.d.ts"/>
import Sub = nla.Sub
import Dissoc = nla.Dissoc 

// string literal unions:
type A = Sub<'X' | 'Y' | 'Z', 'X' | 'Z'> // 'Y'
type B = Sub<'X' | 'Y', 'A'> // 'X' | 'Y'

// object types:
type C = Dissoc<{a: number, b: string}, 'a' | 'c'> // {b: string}

// if you want to subtract two object types, use `keyof`:
type D = Dissoc<{a: number, b: string}, keyof {a: number}> // {b: string}

License

MIT

FAQs

Last updated on 25 Sep 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc