ts-gems 3.5.1 → 3.7.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/lib/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { IfAny, IfClass, IfTuple } from './type-check';
2
- import { Builtin } from './types';
1
+ import { IfAny, IfClass, IfTuple } from './type-check.js';
2
+ import { Builtin } from './types.js';
3
3
 
4
4
  /**
5
5
  * Returns true if T is excluded from deep operations
package/lib/index.d.ts CHANGED
@@ -1,25 +1,26 @@
1
1
  // noinspection JSUnusedGlobalSymbols
2
2
 
3
- import { DeeperMutable, DeepMutable, Mutable } from './mutable';
4
- import { DeeperPartial, DeepPartial } from './partial';
5
- import { DeeperReadonly, DeepReadonly } from './readonly';
6
- import { DeeperRequired, DeepRequired } from './required';
7
-
8
- export * from './combine';
9
- export * from './dto';
10
- export * from './helpers';
11
- export * from './logical';
12
- export * from './mutable';
13
- export * from './nullish';
14
- export * from './omit';
15
- export * from './omit-never';
16
- export * from './opaque';
17
- export * from './partial';
18
- export * from './pick';
19
- export * from './readonly';
20
- export * from './required';
21
- export * from './type-check';
22
- export * from './types';
3
+ import type { DeeperMutable, DeepMutable, Mutable } from './mutable';
4
+ import type { DeeperPartial, DeepPartial } from './partial';
5
+ import type { DeeperReadonly, DeepReadonly } from './readonly';
6
+ import type { DeeperRequired, DeepRequired } from './required';
7
+
8
+ export type * from './combine';
9
+ export type * from './dto';
10
+ export type * from './helpers';
11
+ export type * from './logical';
12
+ export type * from './mutable';
13
+ export type * from './non-nullable';
14
+ export type * from './nullish';
15
+ export type * from './omit';
16
+ export type * from './omit-never';
17
+ export type * from './opaque';
18
+ export type * from './partial';
19
+ export type * from './pick';
20
+ export type * from './readonly';
21
+ export type * from './required';
22
+ export type * from './type-check';
23
+ export type * from './types';
23
24
 
24
25
  declare function asMutable<T>(x: T): Mutable<T>;
25
26
 
package/lib/logical.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IfNever } from './type-check';
1
+ import { IfNever } from './type-check.js';
2
2
 
3
3
  export type And<T1, T2, T3 = true, T4 = true, T5 = true, T6 = true> =
4
4
  IfNever<Exclude<T1, undefined | null | false>> extends true
package/lib/mutable.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IfNoDeepValue } from './helpers';
1
+ import { IfNoDeepValue } from './helpers.js';
2
2
  import {
3
3
  DeeperOmitReadonly,
4
4
  DeeperPickReadonly,
@@ -6,8 +6,8 @@ import {
6
6
  DeepPickReadonly,
7
7
  OmitReadonly,
8
8
  PickReadonly,
9
- } from './readonly';
10
- import { IfNever } from './type-check';
9
+ } from './readonly.js';
10
+ import { IfNever } from './type-check.js';
11
11
 
12
12
  /**
13
13
  * Make all properties in T mutable
@@ -0,0 +1,36 @@
1
+ import { IfNoDeepValue } from './helpers.js';
2
+ import { IfNever, IfNull } from './type-check.js';
3
+
4
+ /**
5
+ * Exclude null and undefined from T deeply
6
+ */
7
+ export type DeepNonNullable<T> = {
8
+ [K in keyof T as IfNever<
9
+ Exclude<T[K], undefined>,
10
+ never,
11
+ IfNull<Exclude<T[K], undefined>, never, K>
12
+ >]: IfNoDeepValue<
13
+ // Do not deep process No-Deep values
14
+ Exclude<T[K], undefined>
15
+ > extends true
16
+ ? NonNullable<T[K]>
17
+ : // Deep process objects
18
+ DeepNonNullable<NonNullable<T[K]>>;
19
+ };
20
+
21
+ /**
22
+ * Exclude null and undefined from T deeply including arrays
23
+ */
24
+ export type DeeperNonNullable<T> = {
25
+ [K in keyof T as IfNever<
26
+ Exclude<T[K], undefined>,
27
+ never,
28
+ IfNull<Exclude<T[K], undefined>, never, K>
29
+ >]: NonNullable<Exclude<T[K], undefined>> extends (infer U)[]
30
+ ? DeeperNonNullable<U>[]
31
+ : // Do not deep process No-Deep values
32
+ IfNoDeepValue<Exclude<T[K], undefined>> extends true
33
+ ? NonNullable<T[K]>
34
+ : // Deep process objects
35
+ DeeperNonNullable<NonNullable<T[K]>>;
36
+ };
package/lib/nullish.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { IfNoDeepValue } from './helpers';
2
- import { IfNever } from './type-check';
1
+ import { IfNoDeepValue } from './helpers.js';
2
+ import { IfNever } from './type-check.js';
3
3
 
4
4
  /**
5
5
  * Make all properties in T nullish
@@ -1,5 +1,5 @@
1
- import { IfNoDeepValue } from './helpers';
2
- import { IfNever } from './type-check';
1
+ import { IfNoDeepValue } from './helpers.js';
2
+ import { IfNever } from './type-check.js';
3
3
 
4
4
  /**
5
5
  * OmitNever<T> is a type that omits all properties with a value of type "never".
package/lib/omit.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IfNoDeepValue } from './helpers';
1
+ import { IfNoDeepValue } from './helpers.js';
2
2
  import { Or } from './logical.js';
3
- import { IfFunction, IfNever } from './type-check';
3
+ import { IfFunction, IfNever } from './type-check.js';
4
4
 
5
5
  /**
6
6
  * Construct a type with the properties of T except for those in type K,
package/lib/partial.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IfNoDeepValue } from './helpers';
1
+ import { IfNoDeepValue } from './helpers.js';
2
2
  import {
3
3
  DeeperOmitRequired,
4
4
  DeeperPickRequired,
@@ -6,8 +6,8 @@ import {
6
6
  DeepPickRequired,
7
7
  OmitRequired,
8
8
  PickRequired,
9
- } from './required';
10
- import { IfNever } from './type-check';
9
+ } from './required.js';
10
+ import { IfNever } from './type-check.js';
11
11
 
12
12
  /**
13
13
  * Marks given keys as optional
package/lib/pick.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Or } from './logical.js';
2
- import { OmitFunctions } from './omit';
2
+ import { OmitFunctions } from './omit.js';
3
3
  import {
4
4
  IfAny,
5
5
  IfEmptyObject,
6
6
  IfFunction,
7
7
  IfNever,
8
8
  IfUnknown,
9
- } from './type-check';
9
+ } from './type-check.js';
10
10
 
11
11
  /**
12
12
  * From T, pick a set of properties whose keys are in the union K,
package/lib/readonly.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IfNoDeepValue } from './helpers';
1
+ import { IfNoDeepValue } from './helpers.js';
2
2
  import { Or } from './logical.js';
3
- import { IfEquals, IfNever } from './type-check';
3
+ import { IfEquals, IfNever } from './type-check.js';
4
4
 
5
5
  /**
6
6
  * Marks given keys as readonly
package/lib/required.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { IfNoDeepValue } from './helpers';
1
+ import { IfNoDeepValue } from './helpers.js';
2
2
  import { Or } from './logical.js';
3
3
  import { OmitTypes } from './omit.js';
4
- import { IfEquals, IfNever } from './type-check';
4
+ import { IfEquals, IfNever } from './type-check.js';
5
5
 
6
6
  /**
7
7
  * Marks given keys as required
@@ -1,4 +1,4 @@
1
- import { Primitive, Type } from './types';
1
+ import { Primitive, Type } from './types.js';
2
2
 
3
3
  type NonObj = Primitive | Function;
4
4
 
package/lib/types.d.ts CHANGED
@@ -1,35 +1,4 @@
1
- /**
2
- * Declare ReadableStream and WritableStream in case dom.d.ts is not added to the tsconfig
3
- * lib causing ReadableStream or WritableStream interface is not defined.
4
- * For developers with dom.d.ts added, the ReadableStream and WritableStream
5
- * interface will be merged correctly.
6
- *
7
- * This is also required for any clients with streaming interface where ReadableStream
8
- * or WritableStream type is also referred.
9
- */
10
- declare global {
11
- export interface ReadableStream<R = any> {
12
- readonly locked: boolean;
13
-
14
- cancel(reason?: any): Promise<void>;
15
-
16
- getReader(options: { mode: 'byob' }): ReadableStreamBYOBReader;
17
-
18
- getReader(): ReadableStreamDefaultReader<R>;
19
-
20
- getReader(
21
- options?: ReadableStreamGetReaderOptions,
22
- ): ReadableStreamReader<R>;
23
- }
24
-
25
- export interface WritableStream<W = any> {
26
- readonly locked: boolean;
27
-
28
- abort(reason?: any): Promise<void>;
29
-
30
- getWriter(): WritableStreamDefaultWriter<W>;
31
- }
32
- }
1
+ /// <reference lib="dom" />
33
2
 
34
3
  /**
35
4
  * BasicPrimitive
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ts-gems",
3
3
  "description": "Valuable typing extensions for TypeScript",
4
- "version": "3.5.1",
4
+ "version": "3.7.0",
5
5
  "license": "MIT",
6
6
  "module": "./lib/index.mjs",
7
7
  "main": "./lib/index.cjs",
@@ -25,15 +25,15 @@
25
25
  "test": "npm run test:common && npm run test:nostrict"
26
26
  },
27
27
  "devDependencies": {
28
- "@panates/eslint-config": "^1.0.13",
29
- "@panates/eslint-config-ts": "^1.0.13",
30
- "@panates/tsconfig": "^1.0.13",
31
- "@types/jest": "^29.5.12",
32
- "husky": "^9.1.4",
28
+ "@panates/eslint-config": "^1.0.21",
29
+ "@panates/eslint-config-ts": "^1.0.21",
30
+ "@panates/tsconfig": "^1.0.21",
31
+ "@types/jest": "^29.5.14",
32
+ "husky": "^9.1.7",
33
33
  "jest": "^29.7.0",
34
- "prettier": "^3.3.3",
35
- "ts-jest": "^29.2.4",
36
- "typescript": "^5.5.4"
34
+ "prettier": "^3.4.0",
35
+ "ts-jest": "^29.2.5",
36
+ "typescript": "^5.7.2"
37
37
  },
38
38
  "files": [
39
39
  "LICENSE",