ts-data-forge 14.6.0 → 14.6.1

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.
@@ -1,5 +1,6 @@
1
1
  import { expectType } from '../expect-type.mjs';
2
2
  import { Num } from '../number/index.mjs';
3
+ import { unknownToString } from '../others/index.mjs';
3
4
  import { type None, type Some } from '../types.mjs';
4
5
  import { Optional, type UnknownOptional } from './optional/index.mjs';
5
6
  import { pipe } from './pipe.mjs';
@@ -872,7 +873,7 @@ describe('Optional test', () => {
872
873
  const makeOptional = (): Optional<undefined> => Optional.some(undefined);
873
874
 
874
875
  const result = Optional.match(makeOptional(), {
875
- some: (value) => `some: ${String(value)}`,
876
+ some: (value) => `some: ${unknownToString(value)}`,
876
877
  none: () => 'none',
877
878
  });
878
879
 
@@ -963,14 +963,12 @@ describe('Result test', () => {
963
963
 
964
964
  const invalidJson = '{invalid json}';
965
965
 
966
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
967
966
  const validResult = Result.fromThrowable(() => JSON.parse(validJson));
968
967
 
969
968
  assert.isTrue(Result.isOk(validResult));
970
969
 
971
970
  assert.deepStrictEqual(Result.unwrapOk(validResult), { key: 'value' });
972
971
 
973
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
974
972
  const invalidResult = Result.fromThrowable(() => JSON.parse(invalidJson));
975
973
 
976
974
  assert.isTrue(Result.isErr(invalidResult));
@@ -61,7 +61,7 @@ describe(isNonEmptyString, () => {
61
61
  // TypeScript knows it's a string
62
62
  expect(value.length).toBeGreaterThan(0);
63
63
 
64
- expect(value.charAt(0)).toBe('t');
64
+ expect(value.at(0)).toBe('t');
65
65
  }
66
66
  });
67
67
 
@@ -109,7 +109,7 @@ describe(isNonEmptyString, () => {
109
109
 
110
110
  test('should not accept String objects', () => {
111
111
  // @ts-expect-error Testing non-string types
112
- // eslint-disable-next-line unicorn/new-for-builtins
112
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
113
113
  assert.isFalse(isNonEmptyString(new String('hello') as unknown));
114
114
  });
115
115
  });
@@ -43,13 +43,13 @@ describe(isNonNullObject, () => {
43
43
  });
44
44
 
45
45
  test('should return true for boxed primitives', () => {
46
- // eslint-disable-next-line unicorn/new-for-builtins
46
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
47
47
  assert.isTrue(isNonNullObject(new String('hello')));
48
48
 
49
- // eslint-disable-next-line unicorn/new-for-builtins
49
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
50
50
  assert.isTrue(isNonNullObject(new Number(42)));
51
51
 
52
- // eslint-disable-next-line unicorn/new-for-builtins
52
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
53
53
  assert.isTrue(isNonNullObject(new Boolean(true)));
54
54
  });
55
55
 
@@ -82,13 +82,13 @@ describe(isPrimitive, () => {
82
82
  });
83
83
 
84
84
  test('should return false for boxed primitives', () => {
85
- // eslint-disable-next-line unicorn/new-for-builtins
85
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
86
86
  assert.isFalse(isPrimitive(new String('hello')));
87
87
 
88
- // eslint-disable-next-line unicorn/new-for-builtins
88
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
89
89
  assert.isFalse(isPrimitive(new Number(42)));
90
90
 
91
- // eslint-disable-next-line unicorn/new-for-builtins
91
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
92
92
  assert.isFalse(isPrimitive(new Boolean(true)));
93
93
  });
94
94
 
@@ -136,7 +136,7 @@ describe(isString, () => {
136
136
 
137
137
  assert.isFalse(isString(undefined));
138
138
 
139
- // eslint-disable-next-line unicorn/new-for-builtins
139
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
140
140
  assert.isFalse(isString(new String('hello')));
141
141
  });
142
142
 
@@ -175,7 +175,7 @@ describe(isNumber, () => {
175
175
 
176
176
  assert.isFalse(isNumber(123n));
177
177
 
178
- // eslint-disable-next-line unicorn/new-for-builtins
178
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
179
179
  assert.isFalse(isNumber(new Number(42)));
180
180
  });
181
181
 
@@ -236,7 +236,7 @@ describe(isBoolean, () => {
236
236
 
237
237
  assert.isFalse(isBoolean(null));
238
238
 
239
- // eslint-disable-next-line unicorn/new-for-builtins
239
+ // eslint-disable-next-line unicorn/new-for-builtins, @typescript-eslint/no-deprecated
240
240
  assert.isFalse(isBoolean(new Boolean(true)));
241
241
  });
242
242
 
@@ -123,7 +123,7 @@ describe('parse', () => {
123
123
 
124
124
  expect(() => Json.parse('null null')).not.toThrow();
125
125
 
126
- expect(() => Json.parse(String(undefined))).not.toThrow();
126
+ expect(() => Json.parse('undefined')).not.toThrow();
127
127
  });
128
128
 
129
129
  test('should use reviver function to transform values', () => {
@@ -38,7 +38,7 @@ const castType = (x: number): Int8 =>
38
38
  const fromNumber = (a: number): Int8 => castType(fromNumberImpl(a));
39
39
 
40
40
  const abs = <N extends Int8>(x: N): AbsoluteValue<N> =>
41
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
41
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion, @typescript-eslint/no-unnecessary-type-assertion -- unnecessary only under the strict standard library; the stock one types `Math.abs` as returning `number`
42
42
  Math.abs(x) as unknown as AbsoluteValue<N>;
43
43
 
44
44
  const min_ = (...values: readonly Int8[]): Int8 =>