ts-toolbelt
Advanced tools
Comparing version 9.5.3-test.1614727682067 to 9.5.3-test.1614866301683
import { Boolean } from '../Boolean/_Internal'; | ||
export declare type If<B extends Boolean, Then, Else = never> = { | ||
0: Else; | ||
1: Then; | ||
}[B]; | ||
export declare type If<B extends Boolean, Then, Else = never> = B extends 1 ? Then : Else; |
@@ -16,2 +16,2 @@ /** | ||
*/ | ||
export declare type Narrowable = string | number | bigint | boolean; | ||
export declare type Narrowable = string | number | bigint | boolean | []; |
@@ -1,16 +0,11 @@ | ||
import { Cast } from '../Any/Cast'; | ||
import { Extends } from '../Any/Extends'; | ||
import { If } from '../Any/If'; | ||
import { Narrowable } from './_Internal'; | ||
/** | ||
* Basic type helper | ||
* @hidden | ||
*/ | ||
declare type NarrowRaw<A> = [] | (A extends Narrowable ? A : never) | ({ | ||
declare type NarrowRaw<A> = (A extends Narrowable ? A : never) | ({ | ||
[K in keyof A]: NarrowRaw<A[K]>; | ||
}); | ||
/** | ||
* Enforce proper variance | ||
* @hidden | ||
*/ | ||
declare type NarrowVar<A, N = NarrowRaw<A>> = N | Cast<A, N>; | ||
/** | ||
* Prevent type widening on generic function parameters | ||
@@ -23,3 +18,3 @@ * @param A to narrow | ||
* | ||
* declare function foo<A extends any[]>(x: F.Narrow<A>): A; | ||
* declare function foo<A extends any[]>(x: F.Narrow<A | []>): A; | ||
* declare function bar<A extends object>(x: F.Narrow<A>): A; | ||
@@ -34,3 +29,3 @@ * | ||
*/ | ||
declare type Narrow<A extends any> = NarrowVar<A>; | ||
declare type Narrow<A extends any> = NarrowRaw<If<Extends<A, any[]>, A | [], A>>; | ||
export { Narrow }; |
{ | ||
"name": "ts-toolbelt", | ||
"version": "9.5.3-test.1614727682067", | ||
"version": "9.5.3-test.1614866301683", | ||
"description": "TypeScript's largest utility library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
248534
6028