Skip to content
Myr

fix: recursive T for WritableDraft (#1197)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* chore(__tests__): add vitest globals to tsconfig.json * fix: recursive T for WritableDraft

authored by Homa Wong · committed by GitHub · parent c329ddb · Browse files · 5 files+67 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+67 added−2 removed

  • tests:+21 added−1 removed
  • other:+46 added−1 removed

5 files+67 added−2 removed

modified:__tests__/tsconfig.json+2 added-1 removed
added:__tests__/type-external.ts+19 added
modified:src/types/types-external.ts+13 added-1 removed
28 unmodified lines
29 * Set30 */31type WeakReferences = IfAvailable<WeakMap<any, any>> | IfAvailable<WeakSet<any>>3233export type WritableDraft<T> = {-readonly [K in keyof T]: Draft<T[K]>}33export type WritableDraft<T> = T extends any[]34 ? number extends T["length"]35 ? Draft<T[number]>[]36 : WritableNonArrayDraft<T>37 : WritableNonArrayDraft<T>3839type WritableNonArrayDraft<T> = {40 -readonly [K in keyof T]: T[K] extends infer V41 ? V extends object42 ? Draft<V>43 : V44 : never45}4647/** Convert a readonly type into a mutable type, if possible */48export type Draft<T> = T extends PrimitiveType49 ? T50 : T extends AtomicObject
201 unmodified lines
modified:package.json+1 added
modified:yarn.lock+32 added
1449 unmodified lines
1450 version "6.4.0"1451 resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.0.tgz#b659d2ffbafa24baf5db1cdbb2c94a983ecd2784"1452 integrity sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==14531454acorn@^8.8.2:1455 version "8.15.0"1456 resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.15.0.tgz#a360898bc415edaac46c8241f6383975b930b816"1457 integrity sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==14581459agent-base@6, agent-base@^6.0.2:1460 version "6.0.2"1461 resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"1462 integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==
3288 unmodified lines
4751 version "1.1.6"4752 resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"4753 integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==47544755is-buffer@^2.0.5:4756 version "2.0.5"4757 resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191"4758 integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==47594760is-callable@^1.2.7:4761 version "1.2.7"4762 resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"4763 integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==
3664 unmodified lines
8428 commander "^2.20.0"8429 source-map "~0.6.1"8430 source-map-support "~0.5.12"84318432tersify@^3.11.1:8433 version "3.12.1"8434 resolved "https://registry.yarnpkg.com/tersify/-/tersify-3.12.1.tgz#1aa5a709a02daba24d694f0896fb8a233f482361"8435 integrity sha512-VwzXGHZSOB4T27s4uvh9v8FYrNXyfVz0nBQi28TDwrZoQwT8ZJUp1W2Ff73ekN07stJSb0D+pr6iXeNeFqTI6Q==8436 dependencies:8437 acorn "^8.8.2"8438 is-buffer "^2.0.5"8439 unpartial "^1.0.4"84408441test-exclude@^7.0.1:8442 version "7.0.1"8443 resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-7.0.1.tgz#20b3ba4906ac20994e275bbcafd68d510264c2a2"8444 integrity sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==
255 unmodified lines
8700 version "0.8.1"8701 resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"8702 integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==87038704type-plus@^7.6.2:8705 version "7.6.2"8706 resolved "https://registry.yarnpkg.com/type-plus/-/type-plus-7.6.2.tgz#76edc22b04e803c047df94c54a69ddbed7141b1d"8707 integrity sha512-qUlXv9Y0/W56pg38m275IMD3WA03QbVoqNY16S3kmwtuA4gOT2iheyUdOp8NWrmXWpf7om98hzr7AZD/eW2jLA==8708 dependencies:8709 tersify "^3.11.1"8710 unpartial "^1.0.4"87118712typed-array-buffer@^1.0.3:8713 version "1.0.3"8714 resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536"8715 integrity sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==
86 unmodified lines
8802 version "2.0.0"8803 resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"8804 integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==88058806unpartial@^1.0.4:8807 version "1.0.5"8808 resolved "https://registry.yarnpkg.com/unpartial/-/unpartial-1.0.5.tgz#ade2b97d4fa309dc6a7fdca6a6fdbf76817fdd7e"8809 integrity sha512-yAqaXcachjgZUnM2yIkf+4KJhmyuoj7stBvlnlZpB15OYVbKnLhgJfmLW7qkpzLHCdsm1bEFvhyN9hCmlZ3uuw==88108811unset-value@^1.0.0:8812 version "1.0.0"8813 resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"8814 integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=
399 unmodified lines