Skip to content

Commit 66ea626

Browse files
chore(changesets): bump package version (#5)
chore: bump package version Co-authored-by: Luke Morales <lukemorales@live.com>
1 parent b287bbb commit 66ea626

File tree

4 files changed

+67
-61
lines changed

4 files changed

+67
-61
lines changed

.changeset/orange-pens-jog.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

.changeset/quick-ants-bathe.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
11
# exhaustive
22

3+
## 1.0.0
4+
5+
### Major Changes
6+
7+
- [#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
8+
9+
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`:
10+
11+
```tsx
12+
import { exhaustive, type ExhaustiveTag } from "exhaustive";
13+
14+
exhaustive<
15+
RequestState,
16+
"state",
17+
ExhaustiveTag<RequestState, "state">,
18+
JSX.Element
19+
>(request, "state", {
20+
IDLE: () => null,
21+
LOADING: (value) => <Loading />,
22+
SUCCESS: (value) => <List data={value.data} />,
23+
ERROR: (value) => <Error message={value.error} />,
24+
});
25+
```
26+
27+
### BREAKING CHANGES
28+
29+
#### Renamed `_tag` method to `tag`
30+
31+
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:
32+
33+
```diff
34+
const area = (s: Shape) => {
35+
- return exhaustive._tag(s, 'kind', {
36+
+ return exhaustive.tag(s, 'kind', {
37+
square: (shape) => shape.size ** 2,
38+
rectangle: (shape) => shape.width * shape.height,
39+
circle: (shape) => Math.PI * shape.radius ** 2,
40+
});
41+
};
42+
```
43+
44+
### Minor Changes
45+
46+
- [#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
47+
48+
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.
49+
50+
```ts
51+
const area = (s: Shape) => {
52+
return exhaustive(s, "kind", {
53+
square: (shape) => shape.size ** 2,
54+
rectangle: (shape) => shape.width * shape.height,
55+
circle: (shape) => Math.PI * shape.radius ** 2,
56+
});
57+
};
58+
```
59+
60+
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:
61+
62+
```ts
63+
exhaustive(shape, "kind", {});
64+
// ^ this will trigger the Tagged Union overload
65+
```
66+
67+
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.
68+
369
## 0.1.0
470

571
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "exhaustive",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "Exhaustiveness checking in TypeScript",
55
"author": "Luke Morales <lukemorales@live.com>",
66
"license": "MIT",

0 commit comments

Comments
 (0)