fix: revert earlier fix (#990) for recursive types (#1014)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Add failing test * Revert #990
authored by Nathan Bierema · committed by GitHub · parent a810960 · Browse files · 5 files·+15 added−45 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+15 added−45 removed
- tests:+14 added−9 removed
- other:+1 added−36 removed
Provenance
- Commit
3eeb331- Tree
59ef721- Author
Nathan Bierema <nbierema@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
a810960
5 files changed+15 added−45 removed
deleted:__tests__/types/type-externals.ts-9 removed
123456789import {isType, JSONTypes} from "type-plus"import {Draft} from "../../src/types/types-external"
describe("Draft<T>", () => { test("can use JSONTypes as T", () => { type A = Draft<JSONTypes> isType.equal<true, JSONTypes, A>() })})modified:__tests__/produce.ts+14 added
767 unmodified lines768 const n = f(base as ROState)769 assert(n, _ as ROState) // yay!770 }771 }772+773+it("allows for mixed property value types", () => {774+ type TestReadonlyObject = {775+ readonly testObjectOrNull: {readonly testProperty: number} | null776+ }777+778+ const input: TestReadonlyObject = {testObjectOrNull: null}779+780+ produce(input, draft => {781+ if (draft.testObjectOrNull) {782+ draft.testObjectOrNull.testProperty = 5783+ }784+ })785+})modified:src/types/types-external.ts+1 added-3 removed
28 unmodified lines29 * Set30 */31 type WeakReferences = IfAvailable<WeakMap<any, any>> | IfAvailable<WeakSet<any>>32 33-export type WritableDraft<T> = {34- -readonly [K in keyof T]: T[K] extends object ? Draft<T[K]> : T[K]35-}33+export type WritableDraft<T> = {-readonly [K in keyof T]: Draft<T[K]>}34 35 /** Convert a readonly type into a mutable type, if possible */36 export type Draft<T> = T extends PrimitiveType37 ? T225 unmodified linesmodified:package.json-1 removed
97 unmodified lines989910010110210210310497 unmodified lines "semantic-release": "^17.0.2", "spec.ts": "^1.1.0", "ts-jest": "^25.2.0", "tsdx": "^0.12.3", "type-plus": "^4.15.2", "typescript": "^4.2.3" }}modified:yarn.lock-32 removed
1789 unmodified lines1790 version "7.1.0"1791 resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c"1792 integrity sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==1793 1794-acorn@^8.8.0:1795- version "8.8.1"1796- resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73"1797- integrity sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==1798-1794 agent-base@4, agent-base@^4.3.0:1795 version "4.3.0"1796 resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"1797 integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==4055 unmodified lines5853 version "1.1.6"5854 resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"5855 integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==5856 5862-is-buffer@^2.0.5:5863- version "2.0.5"5864- resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191"5865- integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==5866-5857 is-callable@^1.1.4, is-callable@^1.2.0:5858 version "1.2.0"5859 resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb"5860 integrity sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==5393 unmodified lines11254 commander "^2.20.0"11255 source-map "~0.6.1"11256 source-map-support "~0.5.12"11257 11268-tersify@^3.10.2:11269- version "3.10.5"11270- resolved "https://registry.yarnpkg.com/tersify/-/tersify-3.10.5.tgz#eb2b230e7725481129b7fa349f2ce2683bd8a9ec"11271- integrity sha512-dLgsTbGVH/6Z+KU4d+NqMmsMFRwRmTFNxsl5vKGkUmaSQ0TTAwnv+Hck5S8Pdn5bcZSyjR3aTvvetJ7ZUs+ZYg==11272- dependencies:11273- acorn "^8.8.0"11274- is-buffer "^2.0.5"11275- unpartial "^1.0.0"11276-11258 test-exclude@^5.2.3:11259 version "5.2.3"11260 resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0"11261 integrity sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g==344 unmodified lines11606 version "0.8.1"11607 resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"11608 integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==11609 11629-type-plus@^4.15.2:11630- version "4.15.2"11631- resolved "https://registry.yarnpkg.com/type-plus/-/type-plus-4.15.2.tgz#2d97273bde0c921845ae70a0d1cef075a7c0cfc1"11632- integrity sha512-5hEzFXMHOK/p5hVhNmgy7CIxUjTIK9a/NOw0pDbc4tb7LXm9JLwLEH0QdGWU5fGPp5l05rtPZfjdSOPqfAyX9w==11633- dependencies:11634- tersify "^3.10.2"11635- unpartial "^1.0.3"11636-11610 typedarray-to-buffer@^3.1.5:11611 version "3.1.5"11612 resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"11613 integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==110 unmodified lines11724 version "2.0.0"11725 resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"11726 integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==11727 11755-unpartial@^1.0.0, unpartial@^1.0.3:11756- version "1.0.4"11757- resolved "https://registry.yarnpkg.com/unpartial/-/unpartial-1.0.4.tgz#56490ed475105110cee61890a80c5da394741833"11758- integrity sha512-xY8319WOQcRDRVFWvTty2YJXKvM8XRPehqWZUd7k/BatpbuitI4Jd+2xlwjTZbZScSvT75TnUsUmy5uwFa3o0g==11759-11728 unpipe@~1.0.0:11729 version "1.0.0"11730 resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"11731 integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=618 unmodified lines