From 66ea626c3305e011a4b435c8f71331cbdcef5a77 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 09:42:37 -0300 Subject: [PATCH] chore(changesets): bump package version (#5) chore: bump package version Co-authored-by: Luke Morales --- .changeset/orange-pens-jog.md | 26 -------------- .changeset/quick-ants-bathe.md | 34 ------------------ CHANGELOG.md | 66 ++++++++++++++++++++++++++++++++++ package.json | 2 +- 4 files changed, 67 insertions(+), 61 deletions(-) delete mode 100644 .changeset/orange-pens-jog.md delete mode 100644 .changeset/quick-ants-bathe.md diff --git a/.changeset/orange-pens-jog.md b/.changeset/orange-pens-jog.md deleted file mode 100644 index b8d44f2..0000000 --- a/.changeset/orange-pens-jog.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -"exhaustive": minor ---- - -## Add `exhaustive.tag` overload to core function - -The same functionality of `exhaustive.tag` is available in the main function by adding a third argument to `exhaustive` that will trigger the Tagged Union overload. - -```ts -const area = (s: Shape) => { - return exhaustive(s, 'kind', { - square: (shape) => shape.size ** 2, - rectangle: (shape) => shape.width * shape.height, - circle: (shape) => Math.PI * shape.radius ** 2, - }); -}; -``` - -PS: Note that TypeScript has a limitation inferring the Tagged Union overload via argument types because they are generic values. Typescript will only fallback to the Tagged Union overload when you add a third argument. This means autocomplete for the Tagged Union keys will not exist until you declare an empty object as the third argument: - -```ts -exhaustive(shape, 'kind', {}); -// ^ this will trigger the Tagged Union overload -``` - -This feature is being added as a reflect of how the API was originally intended. Use it at your own convenience, but if you prefer the better DX of inferred types from the start, calling `exhaustive.tag` is still preferrable. diff --git a/.changeset/quick-ants-bathe.md b/.changeset/quick-ants-bathe.md deleted file mode 100644 index aaa2d8e..0000000 --- a/.changeset/quick-ants-bathe.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -"exhaustive": major ---- - -## Exposed `Exhaustive` types and added new generic slot in core function for type of output - -The types `ExhaustiveUnion` and `Exhaustiveag` are now exposed for your own convenience if you'd like to override the generic slots of `exhaustive`. The inferred output was also added as a new slot in the function generics, allowing you to also override the output value of `exhaustive`: - -```tsx -import { exhaustive, type ExhaustiveTag } from 'exhaustive'; - -exhaustive, JSX.Element>(request, 'state', { - IDLE: () => null, - LOADING: (value) => , - SUCCESS: (value) => , - ERROR: (value) => , -}); -``` - -### BREAKING CHANGES - -#### Renamed `_tag` method to `tag` -The `_tag` method was exposed as a some sort of secondary method to enhance the experience with Tagged Unions. Since the DX of using it is vastly superior compared to the Tagged Union overload in `exhaustive`, and it seems that we cannot improve the overload inference on the core funcion, the underscore has been removed from the method name and now you should used it as `exhaustive.tag` to make it official as the preferred way to exhaustive check Tagged Unions: - -```diff -const area = (s: Shape) => { -- return exhaustive._tag(s, 'kind', { -+ return exhaustive.tag(s, 'kind', { - square: (shape) => shape.size ** 2, - rectangle: (shape) => shape.width * shape.height, - circle: (shape) => Math.PI * shape.radius ** 2, - }); -}; -``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a3ffa6..27ef465 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,71 @@ # exhaustive +## 1.0.0 + +### Major Changes + +- [#4](https://github.com/lukemorales/exhaustive/pull/4) [`b287bbb`](https://github.com/lukemorales/exhaustive/commit/b287bbbb0fcb7a5f433bff2ff4124d5ae995a8ed) Thanks [@lukemorales](https://github.com/lukemorales)! - ## Exposed `Exhaustive` types and added new generic slot in core function for type of output + + The types `ExhaustiveUnion` and `Exhaustiveag` are now exposed for your own convenience if you'd like to override the generic slots of `exhaustive`. The inferred output was also added as a new slot in the function generics, allowing you to also override the output value of `exhaustive`: + + ```tsx + import { exhaustive, type ExhaustiveTag } from "exhaustive"; + + exhaustive< + RequestState, + "state", + ExhaustiveTag, + JSX.Element + >(request, "state", { + IDLE: () => null, + LOADING: (value) => , + SUCCESS: (value) => , + ERROR: (value) => , + }); + ``` + + ### BREAKING CHANGES + + #### Renamed `_tag` method to `tag` + + The `_tag` method was exposed as a some sort of secondary method to enhance the experience with Tagged Unions. Since the DX of using it is vastly superior compared to the Tagged Union overload in `exhaustive`, and it seems that we cannot improve the overload inference on the core funcion, the underscore has been removed from the method name and now you should used it as `exhaustive.tag` to make it official as the preferred way to exhaustive check Tagged Unions: + + ```diff + const area = (s: Shape) => { + - return exhaustive._tag(s, 'kind', { + + return exhaustive.tag(s, 'kind', { + square: (shape) => shape.size ** 2, + rectangle: (shape) => shape.width * shape.height, + circle: (shape) => Math.PI * shape.radius ** 2, + }); + }; + ``` + +### Minor Changes + +- [#4](https://github.com/lukemorales/exhaustive/pull/4) [`b287bbb`](https://github.com/lukemorales/exhaustive/commit/b287bbbb0fcb7a5f433bff2ff4124d5ae995a8ed) Thanks [@lukemorales](https://github.com/lukemorales)! - ## Add `exhaustive.tag` overload to core function + + The same functionality of `exhaustive.tag` is available in the main function by adding a third argument to `exhaustive` that will trigger the Tagged Union overload. + + ```ts + const area = (s: Shape) => { + return exhaustive(s, "kind", { + square: (shape) => shape.size ** 2, + rectangle: (shape) => shape.width * shape.height, + circle: (shape) => Math.PI * shape.radius ** 2, + }); + }; + ``` + + PS: Note that TypeScript has a limitation inferring the Tagged Union overload via argument types because they are generic values. Typescript will only fallback to the Tagged Union overload when you add a third argument. This means autocomplete for the Tagged Union keys will not exist until you declare an empty object as the third argument: + + ```ts + exhaustive(shape, "kind", {}); + // ^ this will trigger the Tagged Union overload + ``` + + This feature is being added as a reflect of how the API was originally intended. Use it at your own convenience, but if you prefer the better DX of inferred types from the start, calling `exhaustive.tag` is still preferrable. + ## 0.1.0 ### Minor Changes diff --git a/package.json b/package.json index 97676ce..3b9a965 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "exhaustive", - "version": "0.1.0", + "version": "1.0.0", "description": "Exhaustiveness checking in TypeScript", "author": "Luke Morales ", "license": "MIT",