type-plus 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/cjs/array/PadLeft.spec.js.map +1 -1
- package/cjs/array/UnionOfValues.d.ts +1 -1
- package/cjs/array/UnionOfValues.d.ts.map +1 -1
- package/cjs/array/UnionOfValues.spec.js +10 -0
- package/cjs/array/UnionOfValues.spec.js.map +1 -1
- package/cjs/array/index.d.ts +3 -3
- package/cjs/array/index.d.ts.map +1 -1
- package/cjs/array/index.js.map +1 -1
- package/cjs/assertion/assertType.d.ts +3 -3
- package/cjs/assertion/assertType.spec.js +226 -131
- package/cjs/assertion/assertType.spec.js.map +1 -1
- package/cjs/function/ExtractFunction.d.ts +8 -2
- package/cjs/function/ExtractFunction.d.ts.map +1 -1
- package/cjs/function/ExtractFunction.js +5 -0
- package/cjs/function/ExtractFunction.js.map +1 -1
- package/cjs/function/ExtractFunction.spec.js +18 -6
- package/cjs/function/ExtractFunction.spec.js.map +1 -1
- package/cjs/functional/compose.d.ts +5 -1
- package/cjs/functional/compose.d.ts.map +1 -1
- package/cjs/functional/compose.js +5 -1
- package/cjs/functional/compose.js.map +1 -1
- package/cjs/predicates/CanAssign.spec.js +4 -3
- package/cjs/predicates/CanAssign.spec.js.map +1 -1
- package/cjs/predicates/Equal.d.ts +14 -18
- package/cjs/predicates/Equal.d.ts.map +1 -1
- package/cjs/predicates/Equal.js +0 -8
- package/cjs/predicates/Equal.js.map +1 -1
- package/cjs/predicates/Equal.spec.js +18 -0
- package/cjs/predicates/Equal.spec.js.map +1 -1
- package/cjs/predicates/IsAny.d.ts +3 -0
- package/cjs/predicates/IsAny.d.ts.map +1 -0
- package/cjs/predicates/IsAny.js +3 -0
- package/cjs/predicates/IsAny.js.map +1 -0
- package/cjs/predicates/index.d.ts +2 -3
- package/cjs/predicates/index.d.ts.map +1 -1
- package/cjs/predicates/index.js.map +1 -1
- package/cjs/predicates/isType.d.ts +1 -1
- package/cjs/predicates/isType.js +1 -1
- package/cjs/predicates/isType.spec.js +16 -12
- package/cjs/predicates/isType.spec.js.map +1 -1
- package/cjs/predicates/logical.d.ts +4 -4
- package/cjs/predicates/logical.d.ts.map +1 -1
- package/esm/array/PadLeft.spec.js.map +1 -1
- package/esm/array/UnionOfValues.d.ts +1 -1
- package/esm/array/UnionOfValues.d.ts.map +1 -1
- package/esm/array/UnionOfValues.spec.js +11 -1
- package/esm/array/UnionOfValues.spec.js.map +1 -1
- package/esm/array/index.d.ts +3 -3
- package/esm/array/index.d.ts.map +1 -1
- package/esm/array/index.js.map +1 -1
- package/esm/assertion/assertType.d.ts +3 -3
- package/esm/assertion/assertType.spec.js +226 -131
- package/esm/assertion/assertType.spec.js.map +1 -1
- package/esm/function/ExtractFunction.d.ts +8 -2
- package/esm/function/ExtractFunction.d.ts.map +1 -1
- package/esm/function/ExtractFunction.js +5 -0
- package/esm/function/ExtractFunction.js.map +1 -1
- package/esm/function/ExtractFunction.spec.js +18 -6
- package/esm/function/ExtractFunction.spec.js.map +1 -1
- package/esm/functional/compose.d.ts +5 -1
- package/esm/functional/compose.d.ts.map +1 -1
- package/esm/functional/compose.js +5 -1
- package/esm/functional/compose.js.map +1 -1
- package/esm/predicates/CanAssign.spec.js +4 -3
- package/esm/predicates/CanAssign.spec.js.map +1 -1
- package/esm/predicates/Equal.d.ts +14 -18
- package/esm/predicates/Equal.d.ts.map +1 -1
- package/esm/predicates/Equal.js +0 -8
- package/esm/predicates/Equal.js.map +1 -1
- package/esm/predicates/Equal.spec.js +18 -0
- package/esm/predicates/Equal.spec.js.map +1 -1
- package/esm/predicates/IsAny.d.ts +3 -0
- package/esm/predicates/IsAny.d.ts.map +1 -0
- package/esm/predicates/IsAny.js +2 -0
- package/esm/predicates/IsAny.js.map +1 -0
- package/esm/predicates/index.d.ts +2 -3
- package/esm/predicates/index.d.ts.map +1 -1
- package/esm/predicates/index.js.map +1 -1
- package/esm/predicates/isType.d.ts +1 -1
- package/esm/predicates/isType.js +1 -1
- package/esm/predicates/isType.spec.js +16 -12
- package/esm/predicates/isType.spec.js.map +1 -1
- package/esm/predicates/logical.d.ts +4 -4
- package/esm/predicates/logical.d.ts.map +1 -1
- package/package.json +2 -2
- package/ts/array/UnionOfValues.ts +14 -10
- package/ts/array/index.ts +3 -4
- package/ts/function/ExtractFunction.ts +8 -2
- package/ts/functional/compose.ts +5 -1
- package/ts/predicates/Equal.ts +19 -23
- package/ts/predicates/IsAny.ts +3 -0
- package/ts/predicates/index.ts +2 -5
- package/ts/predicates/isType.ts +1 -1
- package/ts/predicates/logical.ts +26 -4
package/README.md
CHANGED
|
@@ -425,10 +425,10 @@ They can be used to compose complex types.
|
|
|
425
425
|
#### Logical
|
|
426
426
|
|
|
427
427
|
- `If<Condition, Then = true, Else = false>`: if statement.
|
|
428
|
-
- `And<A, B>`: logical `AND`.
|
|
429
|
-
- `Or<A, B>`: logical `OR`.
|
|
430
|
-
- `Xor<A, B>`: logical `XOR`.
|
|
431
|
-
- `Not<X>`: logical `NOT`.
|
|
428
|
+
- `And<A, B, Then = true, Else = false>`: logical `AND`.
|
|
429
|
+
- `Or<A, B, Then = true, Else = false>`: logical `OR`.
|
|
430
|
+
- `Xor<A, B, Then = true, Else = false>`: logical `XOR`.
|
|
431
|
+
- `Not<X, Then = true, Else = false>`: logical `NOT`.
|
|
432
432
|
|
|
433
433
|
Note that these types work correctly with the `boolean` type.
|
|
434
434
|
e.g.:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PadLeft.spec.js","sourceRoot":"","sources":["../../ts/array/PadLeft.spec.ts"],"names":[],"mappings":";;AAAA,wCAA6C;AAE7C,IAAI,CAAC,8BAA8B,EAAE;IACnC,iBAAM,CAAC,KAAK,EAA4B,CAAA;AAC1C,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,yBAAyB,EAAE;IAC9B,iBAAM,CAAC,KAAK,EAAoC,CAAA;IAChD,iBAAM,CAAC,KAAK,EAAoD,CAAA;AAClE,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,8CAA8C,EAAE;IACnD,iBAAM,CAAC,KAAK,EAA0C,CAAA;AACxD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,2BAA2B,EAAE;
|
|
1
|
+
{"version":3,"file":"PadLeft.spec.js","sourceRoot":"","sources":["../../ts/array/PadLeft.spec.ts"],"names":[],"mappings":";;AAAA,wCAA6C;AAE7C,IAAI,CAAC,8BAA8B,EAAE;IACnC,iBAAM,CAAC,KAAK,EAA4B,CAAA;AAC1C,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,yBAAyB,EAAE;IAC9B,iBAAM,CAAC,KAAK,EAAoC,CAAA;IAChD,iBAAM,CAAC,KAAK,EAAoD,CAAA;AAClE,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,8CAA8C,EAAE;IACnD,iBAAM,CAAC,KAAK,EAA0C,CAAA;AACxD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,2BAA2B,EAAE;IAEhC,iBAAM,CAAC,KAAK,EAAyC,CAAA;AACvD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,kBAAkB,EAAE;IACvB,iBAAM,CAAC,KAAK,EAAwE,CAAA;AACtF,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,oDAAoD,EAAE;IACzD,iBAAM,CAAC,KAAK,EAAgD,CAAA;AAC9D,CAAC,CAAC,CAAA"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export type UnionOfValues<A extends Array<any>> = A extends Array<infer E> ? E : never;
|
|
5
5
|
/**
|
|
6
6
|
* Gets the union of value types in `A`
|
|
7
|
-
*
|
|
7
|
+
* @deprecated Please use `UnionOfValues` instead.
|
|
8
8
|
*/
|
|
9
9
|
export type ArrayValue<A extends any[]> = UnionOfValues<A>;
|
|
10
10
|
//# sourceMappingURL=UnionOfValues.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnionOfValues.d.ts","sourceRoot":"","sources":["../../ts/array/UnionOfValues.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"UnionOfValues.d.ts","sourceRoot":"","sources":["../../ts/array/UnionOfValues.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAMtF;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -7,4 +7,14 @@ test('get value of generic array', function () {
|
|
|
7
7
|
test('tuple get union type of values', function () {
|
|
8
8
|
index_js_1.assertType.isTrue(true);
|
|
9
9
|
});
|
|
10
|
+
it('extracts literal types from a tuple', function () {
|
|
11
|
+
index_js_1.isType.equal();
|
|
12
|
+
});
|
|
13
|
+
it('extracts mixed types from tuple', function () {
|
|
14
|
+
index_js_1.isType.equal();
|
|
15
|
+
});
|
|
16
|
+
it('preserves union types', function () {
|
|
17
|
+
var t = ['a', 1, true];
|
|
18
|
+
index_js_1.isType.equal();
|
|
19
|
+
});
|
|
10
20
|
//# sourceMappingURL=UnionOfValues.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnionOfValues.spec.js","sourceRoot":"","sources":["../../ts/array/UnionOfValues.spec.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"UnionOfValues.spec.js","sourceRoot":"","sources":["../../ts/array/UnionOfValues.spec.ts"],"names":[],"mappings":";;AAAA,wCAAsE;AAEtE,IAAI,CAAC,4BAA4B,EAAE;IAEjC,qBAAU,CAAC,MAAM,CAAC,IAA6B,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,gCAAgC,EAAE;IAErC,qBAAU,CAAC,MAAM,CAAC,IAAuC,CAAC,CAAA;AAC5D,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,qCAAqC,EAAE;IAGxC,iBAAM,CAAC,KAAK,EAA4B,CAAA;AAC1C,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,iCAAiC,EAAE;IAGpC,iBAAM,CAAC,KAAK,EAA2B,CAAA;AACzC,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,uBAAuB,EAAE;IAC1B,IAAM,CAAC,GAAiC,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IAGtD,iBAAM,CAAC,KAAK,EAAyC,CAAA;AACvD,CAAC,CAAC,CAAA"}
|
package/cjs/array/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export type { CommonKeys, CommonPropKeys } from './CommonPropKeys.js';
|
|
2
2
|
export type { Concat } from './Concat.js';
|
|
3
3
|
export type { CreateTuple } from './CreateTuple.js';
|
|
4
|
-
export * from './drop.js';
|
|
5
4
|
export type { Filter, KeepMatch } from './Filter.js';
|
|
6
5
|
export type { FindFirst, First } from './FindFirst.js';
|
|
7
6
|
export type { FindLast } from './FindLast.js';
|
|
@@ -9,12 +8,13 @@ export type { Head } from './Head.js';
|
|
|
9
8
|
export type { IntersectOfProps, MapToProp } from './IntersectOfProps.js';
|
|
10
9
|
export type { IsArray } from './IsArray.js';
|
|
11
10
|
export type { Last } from './Last.js';
|
|
12
|
-
export * from './literalArray.js';
|
|
13
11
|
export type { PadLeft } from './PadLeft.js';
|
|
14
|
-
export * from './reduceWhile.js';
|
|
15
12
|
export type { Reverse } from './Reverse.js';
|
|
16
13
|
export type { Some } from './Some.js';
|
|
17
14
|
export type { Tail } from './Tail.js';
|
|
18
15
|
export type { PropUnion, UnionOfProps } from './UnionOfProps.js';
|
|
19
16
|
export type { ArrayValue, UnionOfValues } from './UnionOfValues.js';
|
|
17
|
+
export * from './drop.js';
|
|
18
|
+
export * from './literalArray.js';
|
|
19
|
+
export * from './reduceWhile.js';
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
package/cjs/array/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACrE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACrE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpD,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtD,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACxE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnE,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA"}
|
package/cjs/array/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgBA,4CAAyB;AACzB,oDAAiC;AACjC,mDAAgC"}
|
|
@@ -22,9 +22,9 @@ export declare namespace assertType {
|
|
|
22
22
|
var noFalse: <S>(subject: Exclude<S, false>) => void;
|
|
23
23
|
var isString: (subject: string) => asserts subject is string;
|
|
24
24
|
var noString: <S>(subject: Exclude<S, string>) => void;
|
|
25
|
-
var isFunction: (subject: AnyFunction
|
|
26
|
-
var noFunction: <S>(subject: Exclude<S, AnyFunction
|
|
27
|
-
var isConstructor: (subject: AnyConstructor
|
|
25
|
+
var isFunction: (subject: AnyFunction) => asserts subject is AnyFunction;
|
|
26
|
+
var noFunction: <S>(subject: Exclude<S, AnyFunction>) => void;
|
|
27
|
+
var isConstructor: (subject: AnyConstructor) => asserts subject is AnyConstructor;
|
|
28
28
|
var isError: (subject: Error) => asserts subject is Error;
|
|
29
29
|
var noError: <S>(subject: Exclude<S, Error>) => void;
|
|
30
30
|
var isNever: (subject: never) => asserts subject is never;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
3
4
|
var assertron_1 = require("assertron");
|
|
4
5
|
var index_js_1 = require("../index.js");
|
|
5
6
|
describe('assertType()', function () {
|
|
@@ -44,15 +45,22 @@ describe('assertType()', function () {
|
|
|
44
45
|
describe('assertType.isUndefined()', function () {
|
|
45
46
|
test('ensure the input type is undefined and nothing else', function () {
|
|
46
47
|
index_js_1.assertType.isUndefined(undefined);
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
//
|
|
48
|
+
// @ts-expect-error
|
|
49
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
50
|
+
// @ts-expect-error
|
|
51
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
54
|
+
// @ts-expect-error
|
|
55
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
56
|
+
// @ts-expect-error
|
|
57
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
58
|
+
// @ts-expect-error
|
|
59
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
60
|
+
// @ts-expect-error
|
|
61
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
62
|
+
// @ts-expect-error
|
|
63
|
+
index_js_1.assertType.isUndefined(undefined);
|
|
56
64
|
});
|
|
57
65
|
test('not undefined throws TypeError', function () {
|
|
58
66
|
assertron_1.a.throws(function () { return index_js_1.assertType.isUndefined(1); }, TypeError);
|
|
@@ -71,9 +79,10 @@ describe('assertType.noUndefined()', function () {
|
|
|
71
79
|
index_js_1.assertType.noUndefined('a');
|
|
72
80
|
index_js_1.assertType.noUndefined([]);
|
|
73
81
|
index_js_1.assertType.noUndefined({});
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
82
|
+
index_js_1.assertType.noUndefined(1);
|
|
83
|
+
// @ts-expect-error
|
|
84
|
+
index_js_1.assertType.noUndefined(1);
|
|
85
|
+
// @ts-expect-error
|
|
77
86
|
index_js_1.assertType.noUndefined(1);
|
|
78
87
|
});
|
|
79
88
|
test('undefined throws TypeError', function () {
|
|
@@ -88,15 +97,22 @@ describe('assertType.isNull()', function () {
|
|
|
88
97
|
index_js_1.assertType.isNull(x);
|
|
89
98
|
// `x` is narrowed to `null` here
|
|
90
99
|
index_js_1.assertType.isNull(x);
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
//
|
|
100
|
+
// @ts-expect-error
|
|
101
|
+
index_js_1.assertType.isNull(null);
|
|
102
|
+
// @ts-expect-error
|
|
103
|
+
index_js_1.assertType.isNull(null);
|
|
104
|
+
// @ts-expect-error
|
|
105
|
+
index_js_1.assertType.isNull(null);
|
|
106
|
+
// @ts-expect-error
|
|
107
|
+
index_js_1.assertType.isNull(null);
|
|
108
|
+
// @ts-expect-error
|
|
109
|
+
index_js_1.assertType.isNull(null);
|
|
110
|
+
// @ts-expect-error
|
|
111
|
+
index_js_1.assertType.isNull(null);
|
|
112
|
+
// @ts-expect-error
|
|
113
|
+
index_js_1.assertType.isNull(null);
|
|
114
|
+
// @ts-expect-error
|
|
115
|
+
index_js_1.assertType.isNull(null);
|
|
100
116
|
});
|
|
101
117
|
test('not null throws TypeError', function () {
|
|
102
118
|
assertron_1.a.throws(function () { return index_js_1.assertType.isNull(1); }, TypeError);
|
|
@@ -115,9 +131,10 @@ describe('assertType.noNull()', function () {
|
|
|
115
131
|
index_js_1.assertType.noNull('a');
|
|
116
132
|
index_js_1.assertType.noNull([]);
|
|
117
133
|
index_js_1.assertType.noNull({});
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
//
|
|
134
|
+
// @ts-expect-error
|
|
135
|
+
index_js_1.assertType.noNull(1);
|
|
136
|
+
// @ts-expect-error
|
|
137
|
+
index_js_1.assertType.noNull(undefined);
|
|
121
138
|
});
|
|
122
139
|
test('null throws TypeError', function () {
|
|
123
140
|
assertron_1.a.throws(function () { return index_js_1.assertType.noNull(null); }, TypeError);
|
|
@@ -126,15 +143,22 @@ describe('assertType.noNull()', function () {
|
|
|
126
143
|
describe('assertType.isNumber()', function () {
|
|
127
144
|
test('ensure the input type is number and nothing else', function () {
|
|
128
145
|
index_js_1.assertType.isNumber(0);
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
//
|
|
146
|
+
// @ts-expect-error
|
|
147
|
+
index_js_1.assertType.isNumber(1);
|
|
148
|
+
// @ts-expect-error
|
|
149
|
+
index_js_1.assertType.isNumber(1);
|
|
150
|
+
// @ts-expect-error
|
|
151
|
+
index_js_1.assertType.isNumber(1);
|
|
152
|
+
// @ts-expect-error
|
|
153
|
+
index_js_1.assertType.isNumber(1);
|
|
154
|
+
// @ts-expect-error
|
|
155
|
+
index_js_1.assertType.isNumber(1);
|
|
156
|
+
// @ts-expect-error
|
|
157
|
+
index_js_1.assertType.isNumber(1);
|
|
158
|
+
// @ts-expect-error
|
|
159
|
+
index_js_1.assertType.isNumber(1);
|
|
160
|
+
// @ts-expect-error
|
|
161
|
+
index_js_1.assertType.isNumber(1);
|
|
138
162
|
});
|
|
139
163
|
test('not number throws TypeError', function () {
|
|
140
164
|
assertron_1.a.throws(function () { return index_js_1.assertType.isNumber(undefined); }, TypeError);
|
|
@@ -153,9 +177,10 @@ describe('assertType.noNumber()', function () {
|
|
|
153
177
|
index_js_1.assertType.noNumber('a');
|
|
154
178
|
index_js_1.assertType.noNumber([]);
|
|
155
179
|
index_js_1.assertType.noNumber({});
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
//
|
|
180
|
+
// @ts-expect-error
|
|
181
|
+
index_js_1.assertType.noNumber('');
|
|
182
|
+
// @ts-expect-error
|
|
183
|
+
index_js_1.assertType.noNumber('');
|
|
159
184
|
});
|
|
160
185
|
test('number throws TypeError', function () {
|
|
161
186
|
assertron_1.a.throws(function () { return index_js_1.assertType.noNumber(1); }, TypeError);
|
|
@@ -165,14 +190,20 @@ describe('assertType.isBoolean()', function () {
|
|
|
165
190
|
test('ensure the input type is boolean and nothing else', function () {
|
|
166
191
|
index_js_1.assertType.isBoolean(true);
|
|
167
192
|
index_js_1.assertType.isBoolean(false);
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
//
|
|
175
|
-
|
|
193
|
+
// @ts-expect-error
|
|
194
|
+
index_js_1.assertType.isBoolean(false);
|
|
195
|
+
// @ts-expect-error
|
|
196
|
+
index_js_1.assertType.isBoolean(false);
|
|
197
|
+
// @ts-expect-error
|
|
198
|
+
index_js_1.assertType.isBoolean(false);
|
|
199
|
+
// @ts-expect-error
|
|
200
|
+
index_js_1.assertType.isBoolean(false);
|
|
201
|
+
// @ts-expect-error
|
|
202
|
+
index_js_1.assertType.isBoolean(false);
|
|
203
|
+
// @ts-expect-error
|
|
204
|
+
index_js_1.assertType.isBoolean(false);
|
|
205
|
+
// @ts-expect-error
|
|
206
|
+
index_js_1.assertType.isBoolean(true);
|
|
176
207
|
});
|
|
177
208
|
test('not boolean throws TypeError', function () {
|
|
178
209
|
assertron_1.a.throws(function () { return index_js_1.assertType.isBoolean(undefined); }, TypeError);
|
|
@@ -191,9 +222,10 @@ describe('assertType.noBoolean()', function () {
|
|
|
191
222
|
index_js_1.assertType.noBoolean('a');
|
|
192
223
|
index_js_1.assertType.noBoolean([]);
|
|
193
224
|
index_js_1.assertType.noBoolean({});
|
|
194
|
-
//
|
|
195
|
-
|
|
196
|
-
//
|
|
225
|
+
// @ts-expect-error
|
|
226
|
+
index_js_1.assertType.noBoolean(1);
|
|
227
|
+
// @ts-expect-error
|
|
228
|
+
index_js_1.assertType.noBoolean(1);
|
|
197
229
|
});
|
|
198
230
|
test('boolean throws TypeError', function () {
|
|
199
231
|
assertron_1.a.throws(function () { return index_js_1.assertType.noBoolean(true); }, TypeError);
|
|
@@ -202,16 +234,24 @@ describe('assertType.noBoolean()', function () {
|
|
|
202
234
|
describe('assertType.isTrue()', function () {
|
|
203
235
|
test('ensure the input type is true and nothing else', function () {
|
|
204
236
|
index_js_1.assertType.isTrue(true);
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
//
|
|
214
|
-
|
|
237
|
+
// @ts-expect-error
|
|
238
|
+
index_js_1.assertType.isTrue(true);
|
|
239
|
+
// @ts-expect-error
|
|
240
|
+
index_js_1.assertType.isTrue(true);
|
|
241
|
+
// @ts-expect-error
|
|
242
|
+
index_js_1.assertType.isTrue(true);
|
|
243
|
+
// @ts-expect-error
|
|
244
|
+
index_js_1.assertType.isTrue(true);
|
|
245
|
+
// @ts-expect-error
|
|
246
|
+
index_js_1.assertType.isTrue(true);
|
|
247
|
+
// @ts-expect-error
|
|
248
|
+
index_js_1.assertType.isTrue(true);
|
|
249
|
+
// @ts-expect-error
|
|
250
|
+
index_js_1.assertType.isTrue(true);
|
|
251
|
+
// @ts-expect-error
|
|
252
|
+
index_js_1.assertType.isTrue(true);
|
|
253
|
+
// @ts-expect-error
|
|
254
|
+
index_js_1.assertType.isTrue(true);
|
|
215
255
|
});
|
|
216
256
|
test('not true throws TypeError', function () {
|
|
217
257
|
assertron_1.a.throws(function () { return index_js_1.assertType.isTrue(undefined); }, TypeError);
|
|
@@ -231,10 +271,12 @@ describe('assertType.noTrue()', function () {
|
|
|
231
271
|
index_js_1.assertType.noTrue('a');
|
|
232
272
|
index_js_1.assertType.noTrue([]);
|
|
233
273
|
index_js_1.assertType.noTrue({});
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
//
|
|
237
|
-
|
|
274
|
+
// @ts-expect-error
|
|
275
|
+
index_js_1.assertType.noTrue(1);
|
|
276
|
+
// @ts-expect-error
|
|
277
|
+
index_js_1.assertType.noTrue(1);
|
|
278
|
+
// @ts-expect-error
|
|
279
|
+
index_js_1.assertType.noTrue(1);
|
|
238
280
|
});
|
|
239
281
|
test('true throws TypeError', function () {
|
|
240
282
|
assertron_1.a.throws(function () { return index_js_1.assertType.noTrue(true); }, TypeError);
|
|
@@ -248,16 +290,25 @@ describe('assertType.isFalse()', function () {
|
|
|
248
290
|
index_js_1.assertType.isFalse(x);
|
|
249
291
|
// `x` is narrowed to `true` here
|
|
250
292
|
index_js_1.assertType.isFalse(x);
|
|
251
|
-
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
//
|
|
255
|
-
|
|
256
|
-
//
|
|
257
|
-
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
//
|
|
293
|
+
index_js_1.assertType.isFalse(false);
|
|
294
|
+
// @ts-expect-error
|
|
295
|
+
index_js_1.assertType.isFalse(false);
|
|
296
|
+
// @ts-expect-error
|
|
297
|
+
index_js_1.assertType.isFalse(false);
|
|
298
|
+
// @ts-expect-error
|
|
299
|
+
index_js_1.assertType.isFalse(false);
|
|
300
|
+
// @ts-expect-error
|
|
301
|
+
index_js_1.assertType.isFalse(false);
|
|
302
|
+
// @ts-expect-error
|
|
303
|
+
index_js_1.assertType.isFalse(false);
|
|
304
|
+
// @ts-expect-error
|
|
305
|
+
index_js_1.assertType.isFalse(false);
|
|
306
|
+
// @ts-expect-error
|
|
307
|
+
index_js_1.assertType.isFalse(false);
|
|
308
|
+
// @ts-expect-error
|
|
309
|
+
index_js_1.assertType.isFalse(false);
|
|
310
|
+
// @ts-expect-error
|
|
311
|
+
index_js_1.assertType.isFalse(false);
|
|
261
312
|
});
|
|
262
313
|
test('boolean throws TypeError', function () {
|
|
263
314
|
assertron_1.a.throws(function () { return index_js_1.assertType.noBoolean(true); }, TypeError);
|
|
@@ -272,10 +323,12 @@ describe('assertType.noFalse()', function () {
|
|
|
272
323
|
index_js_1.assertType.noFalse('a');
|
|
273
324
|
index_js_1.assertType.noFalse([]);
|
|
274
325
|
index_js_1.assertType.noFalse({});
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
//
|
|
278
|
-
|
|
326
|
+
// @ts-expect-error
|
|
327
|
+
index_js_1.assertType.noFalse(1);
|
|
328
|
+
// @ts-expect-error
|
|
329
|
+
index_js_1.assertType.noFalse(1);
|
|
330
|
+
// @ts-expect-error
|
|
331
|
+
index_js_1.assertType.noFalse(1);
|
|
279
332
|
});
|
|
280
333
|
test('false throws TypeError', function () {
|
|
281
334
|
assertron_1.a.throws(function () { return index_js_1.assertType.noFalse(false); }, TypeError);
|
|
@@ -284,15 +337,22 @@ describe('assertType.noFalse()', function () {
|
|
|
284
337
|
describe('assertType.isString()', function () {
|
|
285
338
|
test('ensure the input type is string and nothing else', function () {
|
|
286
339
|
index_js_1.assertType.isString('a');
|
|
287
|
-
//
|
|
288
|
-
|
|
289
|
-
//
|
|
290
|
-
|
|
291
|
-
//
|
|
292
|
-
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
//
|
|
340
|
+
// @ts-expect-error
|
|
341
|
+
index_js_1.assertType.isString('a');
|
|
342
|
+
// @ts-expect-error
|
|
343
|
+
index_js_1.assertType.isString('a');
|
|
344
|
+
// @ts-expect-error
|
|
345
|
+
index_js_1.assertType.isString('a');
|
|
346
|
+
// @ts-expect-error
|
|
347
|
+
index_js_1.assertType.isString('a');
|
|
348
|
+
// @ts-expect-error
|
|
349
|
+
index_js_1.assertType.isString('a');
|
|
350
|
+
// @ts-expect-error
|
|
351
|
+
index_js_1.assertType.isString('a');
|
|
352
|
+
// @ts-expect-error
|
|
353
|
+
index_js_1.assertType.isString('a');
|
|
354
|
+
// @ts-expect-error
|
|
355
|
+
index_js_1.assertType.isString('a');
|
|
296
356
|
});
|
|
297
357
|
test('not string throws TypeError', function () {
|
|
298
358
|
assertron_1.a.throws(function () { return index_js_1.assertType.isString(undefined); }, TypeError);
|
|
@@ -311,9 +371,10 @@ describe('assertType.noString()', function () {
|
|
|
311
371
|
index_js_1.assertType.noString(true);
|
|
312
372
|
index_js_1.assertType.noString([]);
|
|
313
373
|
index_js_1.assertType.noString({});
|
|
314
|
-
//
|
|
315
|
-
|
|
316
|
-
//
|
|
374
|
+
// @ts-expect-error
|
|
375
|
+
index_js_1.assertType.noString(1);
|
|
376
|
+
// @ts-expect-error
|
|
377
|
+
index_js_1.assertType.noString(1);
|
|
317
378
|
});
|
|
318
379
|
test('string throws TypeError', function () {
|
|
319
380
|
assertron_1.a.throws(function () { return index_js_1.assertType.noString(''); }, TypeError);
|
|
@@ -323,14 +384,21 @@ describe('assertType.isFunction()', function () {
|
|
|
323
384
|
test('ensure the input type is function and nothing else', function () {
|
|
324
385
|
index_js_1.assertType.isFunction(function () { });
|
|
325
386
|
index_js_1.assertType.isFunction(function () { });
|
|
326
|
-
|
|
327
|
-
//
|
|
328
|
-
|
|
329
|
-
//
|
|
330
|
-
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
//
|
|
387
|
+
var f = function () { };
|
|
388
|
+
// @ts-expect-error
|
|
389
|
+
index_js_1.assertType.isFunction(f);
|
|
390
|
+
// @ts-expect-error
|
|
391
|
+
index_js_1.assertType.isFunction(f);
|
|
392
|
+
// @ts-expect-error
|
|
393
|
+
index_js_1.assertType.isFunction(f);
|
|
394
|
+
// @ts-expect-error
|
|
395
|
+
index_js_1.assertType.isFunction(f);
|
|
396
|
+
// @ts-expect-error
|
|
397
|
+
index_js_1.assertType.isFunction(f);
|
|
398
|
+
// @ts-expect-error
|
|
399
|
+
index_js_1.assertType.isFunction(f);
|
|
400
|
+
// @ts-expect-error
|
|
401
|
+
index_js_1.assertType.isFunction(f);
|
|
334
402
|
});
|
|
335
403
|
test('not function throws TypeError', function () {
|
|
336
404
|
assertron_1.a.throws(function () { return index_js_1.assertType.isFunction(undefined); }, TypeError);
|
|
@@ -349,9 +417,10 @@ describe('assertType.noFunction()', function () {
|
|
|
349
417
|
index_js_1.assertType.noFunction('a');
|
|
350
418
|
index_js_1.assertType.noFunction([]);
|
|
351
419
|
index_js_1.assertType.noFunction({});
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
//
|
|
420
|
+
// @ts-expect-error
|
|
421
|
+
index_js_1.assertType.noFunction(1);
|
|
422
|
+
// @ts-expect-error
|
|
423
|
+
index_js_1.assertType.noFunction(1);
|
|
355
424
|
});
|
|
356
425
|
test('function throws TypeError', function () {
|
|
357
426
|
assertron_1.a.throws(function () { return index_js_1.assertType.noFunction((function () { })); }, TypeError);
|
|
@@ -365,15 +434,22 @@ describe('assertType.isConstructor()', function () {
|
|
|
365
434
|
return Foo;
|
|
366
435
|
}());
|
|
367
436
|
index_js_1.assertType.isConstructor(Foo);
|
|
368
|
-
//
|
|
369
|
-
|
|
370
|
-
//
|
|
371
|
-
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
//
|
|
375
|
-
|
|
376
|
-
//
|
|
437
|
+
// @ts-expect-error
|
|
438
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
439
|
+
// @ts-expect-error
|
|
440
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
441
|
+
// @ts-expect-error
|
|
442
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
443
|
+
// @ts-expect-error
|
|
444
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
445
|
+
// @ts-expect-error
|
|
446
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
447
|
+
// @ts-expect-error
|
|
448
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
449
|
+
// @ts-expect-error
|
|
450
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
451
|
+
// @ts-expect-error
|
|
452
|
+
index_js_1.assertType.isConstructor(Foo);
|
|
377
453
|
});
|
|
378
454
|
test('not constructor throws TypeError', function () {
|
|
379
455
|
assertron_1.a.throws(function () { return index_js_1.assertType.isConstructor(undefined); }, TypeError);
|
|
@@ -397,16 +473,24 @@ describe('assertType.isError()', function () {
|
|
|
397
473
|
index_js_1.assertType.isError(x);
|
|
398
474
|
// `x` is narrowed to `true` here
|
|
399
475
|
index_js_1.assertType.isError(x);
|
|
400
|
-
//
|
|
401
|
-
|
|
402
|
-
//
|
|
403
|
-
|
|
404
|
-
//
|
|
405
|
-
|
|
406
|
-
//
|
|
407
|
-
|
|
408
|
-
//
|
|
409
|
-
|
|
476
|
+
// @ts-expect-error
|
|
477
|
+
index_js_1.assertType.isError(x);
|
|
478
|
+
// @ts-expect-error
|
|
479
|
+
index_js_1.assertType.isError(x);
|
|
480
|
+
// @ts-expect-error
|
|
481
|
+
index_js_1.assertType.isError(x);
|
|
482
|
+
// @ts-expect-error
|
|
483
|
+
index_js_1.assertType.isError(x);
|
|
484
|
+
// @ts-expect-error
|
|
485
|
+
index_js_1.assertType.isError(x);
|
|
486
|
+
// @ts-expect-error
|
|
487
|
+
index_js_1.assertType.isError(x);
|
|
488
|
+
// @ts-expect-error
|
|
489
|
+
index_js_1.assertType.isError(x);
|
|
490
|
+
// @ts-expect-error
|
|
491
|
+
index_js_1.assertType.isError(x);
|
|
492
|
+
// @ts-expect-error
|
|
493
|
+
index_js_1.assertType.isError(x);
|
|
410
494
|
});
|
|
411
495
|
test('not error throws TypeError', function () {
|
|
412
496
|
assertron_1.a.throws(function () { return index_js_1.assertType.isError(undefined); }, TypeError);
|
|
@@ -425,9 +509,10 @@ describe('assertType.noError()', function () {
|
|
|
425
509
|
index_js_1.assertType.noError('a');
|
|
426
510
|
index_js_1.assertType.noError([]);
|
|
427
511
|
index_js_1.assertType.noError({});
|
|
428
|
-
//
|
|
429
|
-
|
|
430
|
-
//
|
|
512
|
+
// @ts-expect-error
|
|
513
|
+
index_js_1.assertType.noError({});
|
|
514
|
+
// @ts-expect-error
|
|
515
|
+
index_js_1.assertType.noError({});
|
|
431
516
|
});
|
|
432
517
|
test('error instance throws TypeError', function () {
|
|
433
518
|
assertron_1.a.throws(function () { return index_js_1.assertType.noError(new Error('a')); }, TypeError);
|
|
@@ -437,17 +522,26 @@ describe('assertType.isNever()', function () {
|
|
|
437
522
|
test('ensure the input type is never and nothing else', function () {
|
|
438
523
|
var s = 0;
|
|
439
524
|
index_js_1.assertType.isNever(s);
|
|
440
|
-
//
|
|
441
|
-
|
|
442
|
-
//
|
|
443
|
-
|
|
444
|
-
//
|
|
445
|
-
|
|
446
|
-
//
|
|
447
|
-
|
|
448
|
-
//
|
|
449
|
-
|
|
450
|
-
//
|
|
525
|
+
// @ts-expect-error
|
|
526
|
+
index_js_1.assertType.isNever(undefined);
|
|
527
|
+
// @ts-expect-error
|
|
528
|
+
index_js_1.assertType.isNever(null);
|
|
529
|
+
// @ts-expect-error
|
|
530
|
+
index_js_1.assertType.isNever(1);
|
|
531
|
+
// @ts-expect-error
|
|
532
|
+
index_js_1.assertType.isNever('a');
|
|
533
|
+
// @ts-expect-error
|
|
534
|
+
index_js_1.assertType.isNever(false);
|
|
535
|
+
// @ts-expect-error
|
|
536
|
+
index_js_1.assertType.isNever([]);
|
|
537
|
+
// @ts-expect-error
|
|
538
|
+
index_js_1.assertType.isNever({});
|
|
539
|
+
// @ts-expect-error
|
|
540
|
+
index_js_1.assertType.isNever(1);
|
|
541
|
+
// @ts-expect-error
|
|
542
|
+
index_js_1.assertType.isNever(false);
|
|
543
|
+
// @ts-expect-error
|
|
544
|
+
index_js_1.assertType.isNever(false);
|
|
451
545
|
});
|
|
452
546
|
test('boolean throws TypeError', function () {
|
|
453
547
|
assertron_1.a.throws(function () { return index_js_1.assertType.noBoolean(true); }, TypeError);
|
|
@@ -482,4 +576,5 @@ describe('assertType.as<T>()', function () {
|
|
|
482
576
|
index_js_1.isType.equal();
|
|
483
577
|
});
|
|
484
578
|
});
|
|
579
|
+
/* eslint-enable @typescript-eslint/ban-types */
|
|
485
580
|
//# sourceMappingURL=assertType.spec.js.map
|