Skip to main content
Module

x/ts_toolbelt_unofficial/mod.ts>N.Sub

👷 TypeScript's largest type utility library, now on Deno
Latest
type alias N.Sub
import { type N } from "https://deno.land/x/ts_toolbelt_unofficial@1.1.0/mod.ts";
const { Sub } = N;

Subtract a [[Number]] from another one

Examples

Example 1

import {N} from 'ts-toolbelt.ts'

type test0 = N.Sub<'2', '10'>        // '-8'
type test1 = N.Sub<'0', '40'>        // '-40'
type test2 = N.Sub<'0', '40', 's'>   // '-40'
type test3 = N.Sub<'0', '40', 'n'>   //  -40
type test4 = N.Sub<'-20', '40', 's'> // string
type test5 = N.Sub<'-20', '40', 'n'> // number

Type Parameters

N1 extends number
N2 extends number
definition: N1 extends unknown ? N2 extends unknown ? _Sub<IterationOf<N1>, IterationOf<N2>>[0] : never : never