Skip to content

Commit

Permalink
Pushed new version
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Mar 8, 2023
1 parent ce9db42 commit dd14953
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 74 deletions.
5 changes: 0 additions & 5 deletions .changeset/angry-hotels-remember.md

This file was deleted.

25 changes: 0 additions & 25 deletions .changeset/empty-elephants-tell.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/nine-lies-mix.md

This file was deleted.

38 changes: 0 additions & 38 deletions .changeset/olive-pets-exist.md

This file was deleted.

66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
# @total-typescript/ts-reset

## 0.4.0

### Minor Changes

- ce9db42: Added support for widening in `Array.lastIndexOf`, `Array.indexOf`, `ReadonlyArray.lastIndexOf` and `ReadonlyArray.indexOf`.
- 107dfc2: Changed the array.includes on readonly arrays to NOT be a type predicate. Before this change, this perfectly valid code would not behave correctly.

```ts
type Code = 0 | 1 | 2;
type SpecificCode = 0 | 1;

const currentCode: Code = 0;

// Create an empty list of subset type
const specificCodeList: ReadonlyArray<SpecificCode> = [];

// This will be false, since 0 is not in []
if (specificCodeList.includes(currentCode)) {
currentCode; // -> SpecificCode
} else {
// This branch will be entered, and ts will think z is 2, when it is actually 0
currentCode; // -> 2
}
```

Removing the type predicate brings ts-reset closer towards correctness.

- 4765413: author: @mefechoel

Added the `Map.has` rule.

Similar to `.includes` or `Set.has()`, `Map.has()` doesn't let you pass members that don't exist in the map's keys:

```ts
// BEFORE
const userMap = new Map([
["matt", 0],
["sofia", 1],
[2, "waqas"],
] as const);

// Argument of type '"bryan"' is not assignable to
// parameter of type '"matt" | "sofia" | "waqas"'.
userMap.has("bryan");
```

With the rule enabled, `Map` follows the same semantics as `Set`.

```ts
// AFTER
import "@total-typescript/ts-reset/map-has";

const userMap = new Map([
["matt", 0],
["sofia", 1],
[2, "waqas"],
] as const);

// .has now takes a string as the argument!
userMap.has("bryan");
```

### Patch Changes

- b15aaa4: Fixed an oversight with the initial `set-has` implementation by adding support to `ReadonlySet`.

## 0.3.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@total-typescript/ts-reset",
"version": "0.3.7",
"version": "0.4.0",
"description": "A CSS reset for TypeScript, improving types for common JavaScript API's",
"private": false,
"repository": "https://github.com/total-typescript/ts-reset",
Expand Down

0 comments on commit dd14953

Please sign in to comment.