foxts 5.2.1 → 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.
@@ -0,0 +1,19 @@
1
+ type DeepMutable<T> = {
2
+ -readonly [P in keyof T]: DeepMutable<T[P]>;
3
+ };
4
+ /**
5
+ * When you are returning some object/array literal from a function,
6
+ * TypeScript automatically widens the array to be more general, like
7
+ * ['sukka'] becomes string[].
8
+ *
9
+ * TypeScript does this to allow returned arrays to be extensible,
10
+ * but it may break the type inference.
11
+ *
12
+ * You can use `foxts/literal` to wrap your array to prevent TypeScript
13
+ * from widening the type in function return values.
14
+ *
15
+ * Playground Link: https://www.typescriptlang.org/play/?declaration=false&jsx=0#code/C4TwDgpgBAIhFgLIFdgEMBGAbCAeAKgHxQC8UA3gFBRQC0AThGgCYD2AdliFANoAKUAJbsoAawghWAMyj4AugC5Y8JKkw4C-OYQDclAL56IADzCt6wKAGMOAZ0tZBwCPTRZSUXDfb3ZhABQAbkr4AJRKcAgo6Nh4RKTEgXqUoJBQAMrowMi2APIYAFYQVpZk5FD2aNm2SgCC9K4guADkrKLNUAA+UK2sYLbNxIaUUsjsJYIc1gAWxaL+wmCoSplVOflFJaEU1nasOAB0WKwA5gvsS8Dbw5RWs1bz5ZXVSjyt7XJQ+qHJ3r4YHn82xIxH8TyyOVe72an2+egA9PCoMBpoJbFAONAAO6CLDuKRoXG3e7zDBAn6UW52SxWQHA0HgtY1KCOZyuLD+N5tGHXCl3Ob+KzkvRAA
16
+ */
17
+ declare const literal: <const T>(v: T) => DeepMutable<T>;
18
+
19
+ export { literal };
@@ -0,0 +1 @@
1
+ "use strict";exports.literal=t=>t;
@@ -0,0 +1 @@
1
+ const t=t=>t;export{t as literal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foxts",
3
- "version": "5.2.1",
3
+ "version": "5.3.0",
4
4
  "description": "Opinionated collection of common TypeScript utils by @SukkaW",
5
5
  "repository": {
6
6
  "url": "https://github.com/SukkaW/foxts"
@@ -220,6 +220,12 @@
220
220
  "require": "./dist/lazy-value/index.js",
221
221
  "default": "./dist/lazy-value/index.js"
222
222
  },
223
+ "./literal": {
224
+ "types": "./dist/literal/index.d.ts",
225
+ "import": "./dist/literal/index.mjs",
226
+ "require": "./dist/literal/index.js",
227
+ "default": "./dist/literal/index.js"
228
+ },
223
229
  "./merge-headers": {
224
230
  "types": "./dist/merge-headers/index.d.ts",
225
231
  "import": "./dist/merge-headers/index.mjs",
@@ -338,10 +344,10 @@
338
344
  "@types/node": "^22.19.7",
339
345
  "@types/sinon": "^21.0.0",
340
346
  "bumpp": "^10.4.0",
347
+ "earl": "^2.0.0",
341
348
  "eslint": "^9.39.2",
342
349
  "eslint-config-sukka": "^8.3.0",
343
350
  "eslint-formatter-sukka": "^8.3.0",
344
- "expect": "^30.2.0",
345
351
  "fastscan": "^1.0.6",
346
352
  "happy-dom": "^20.3.7",
347
353
  "is-ci": "^4.1.0",