@naturalcycles/js-lib 15.72.0 → 15.72.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.
package/dist/types.d.ts CHANGED
@@ -298,15 +298,22 @@ export declare const _stringMapEntries: <T>(map: StringMap<T>) => [k: string, v:
298
298
  /**
299
299
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
300
300
  * This is how TypeScript should work, actually.
301
+ *
302
+ * Object.keys always returns strings, so numeric keys are stringified via `${K}`.
303
+ * Symbol keys are excluded (Object.keys does not return symbols).
301
304
  */
302
- export declare const _objectKeys: <K extends PropertyKey>(obj: Partial<Record<K, any>>) => K[];
305
+ export declare const _objectKeys: <K extends PropertyKey>(obj: Partial<Record<K, any>>) => (K extends string ? K : K extends number | bigint ? `${K}` : never)[];
303
306
  /**
304
307
  * Alias of `Object.entries`, but returns better-typed output.
305
308
  *
309
+ * Difference with _stringMapEntries?
310
+ * Use _stringMapEntries when the object is a StringMap<T> - it'll correctly infer T being not undefined.
311
+ * If the object is not a StringMap - use _objectEntries - it'll correctly infer object keys, which can be typed as Enum.
312
+ *
306
313
  * So e.g you can use _objectEntries(obj).map([k, v] => {})
307
314
  * and `k` will be `keyof obj` instead of generic `string`.
308
315
  */
309
- export declare const _objectEntries: <K extends PropertyKey, V>(obj: Partial<Record<K, V>>) => [k: K, v: V][];
316
+ export declare const _objectEntries: <K extends PropertyKey, V>(obj: Partial<Record<K, V>>) => [k: K extends string ? K : K extends number | bigint ? `${K}` : never, v: V][];
310
317
  export type NullishValue = null | undefined;
311
318
  export type FalsyValue = false | '' | 0 | null | undefined;
312
319
  /**
package/dist/types.js CHANGED
@@ -33,11 +33,18 @@ export const _stringMapEntries = Object.entries;
33
33
  /**
34
34
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
35
35
  * This is how TypeScript should work, actually.
36
+ *
37
+ * Object.keys always returns strings, so numeric keys are stringified via `${K}`.
38
+ * Symbol keys are excluded (Object.keys does not return symbols).
36
39
  */
37
40
  export const _objectKeys = Object.keys;
38
41
  /**
39
42
  * Alias of `Object.entries`, but returns better-typed output.
40
43
  *
44
+ * Difference with _stringMapEntries?
45
+ * Use _stringMapEntries when the object is a StringMap<T> - it'll correctly infer T being not undefined.
46
+ * If the object is not a StringMap - use _objectEntries - it'll correctly infer object keys, which can be typed as Enum.
47
+ *
41
48
  * So e.g you can use _objectEntries(obj).map([k, v] => {})
42
49
  * and `k` will be `keyof obj` instead of generic `string`.
43
50
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.72.0",
4
+ "version": "15.72.1",
5
5
  "dependencies": {
6
6
  "tslib": "^2"
7
7
  },
@@ -20,7 +20,7 @@
20
20
  "@typescript/native-preview": "7.0.0-dev.20260401.1",
21
21
  "crypto-js": "^4",
22
22
  "dayjs": "^1",
23
- "@naturalcycles/dev-lib": "20.42.0"
23
+ "@naturalcycles/dev-lib": "18.4.2"
24
24
  },
25
25
  "exports": {
26
26
  ".": "./dist/index.js",
package/src/types.ts CHANGED
@@ -373,20 +373,27 @@ export const _stringMapEntries = Object.entries as <T>(map: StringMap<T>) => [k:
373
373
  /**
374
374
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
375
375
  * This is how TypeScript should work, actually.
376
+ *
377
+ * Object.keys always returns strings, so numeric keys are stringified via `${K}`.
378
+ * Symbol keys are excluded (Object.keys does not return symbols).
376
379
  */
377
380
  export const _objectKeys = Object.keys as <K extends PropertyKey>(
378
381
  obj: Partial<Record<K, any>>,
379
- ) => K[]
382
+ ) => (K extends string ? K : K extends number | bigint ? `${K}` : never)[]
380
383
 
381
384
  /**
382
385
  * Alias of `Object.entries`, but returns better-typed output.
383
386
  *
387
+ * Difference with _stringMapEntries?
388
+ * Use _stringMapEntries when the object is a StringMap<T> - it'll correctly infer T being not undefined.
389
+ * If the object is not a StringMap - use _objectEntries - it'll correctly infer object keys, which can be typed as Enum.
390
+ *
384
391
  * So e.g you can use _objectEntries(obj).map([k, v] => {})
385
392
  * and `k` will be `keyof obj` instead of generic `string`.
386
393
  */
387
394
  export const _objectEntries = Object.entries as <K extends PropertyKey, V>(
388
395
  obj: Partial<Record<K, V>>,
389
- ) => [k: K, v: V][]
396
+ ) => [k: K extends string ? K : K extends number | bigint ? `${K}` : never, v: V][]
390
397
 
391
398
  export type NullishValue = null | undefined
392
399
  export type FalsyValue = false | '' | 0 | null | undefined