Skip to content

(Typescript) Allow ReadonlyArrays as valid classNames parameters#307

Merged
dcousens merged 3 commits into
JedWatson:mainfrom
BenGearset:ts-readonlyarray
Apr 27, 2023
Merged

(Typescript) Allow ReadonlyArrays as valid classNames parameters#307
dcousens merged 3 commits into
JedWatson:mainfrom
BenGearset:ts-readonlyarray

Conversation

@BenGearset

@BenGearset BenGearset commented Apr 27, 2023

Copy link
Copy Markdown
Contributor

Simple reproduction:

const array = ['a', 'b', 'c'] as const;
classNames(array);

Error:

TS2345: Argument of type '[readonly ["a", "b", "c"]]' is not assignable to parameter of type 'ArgumentArray'.   Type 'readonly ["a", "b", "c"]' is not assignable to type 'Argument'.     Type 'readonly ["a", "b", "c"]' is not assignable to type 'Mapping'.       Index signature for type 'string' is missing in type 'readonly ["a", "b", "c"]'.

This PR adds a ReadonlyArray<Argument> to the Argument union type allowing ReadonlyArrays to be used with classNames

@dcousens dcousens left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @BenGearset

@dcousens dcousens added the types label Apr 27, 2023
@dcousens dcousens merged commit 0251060 into JedWatson:main Apr 27, 2023
CrispyBaguette pushed a commit to CrispyBaguette/wasm-palette-converter that referenced this pull request Nov 8, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [classnames](https://github.com/JedWatson/classnames) | dependencies | minor | [`2.3.1` -> `2.5.1`](https://renovatebot.com/diffs/npm/classnames/2.3.1/2.5.1) |

---

### Release Notes

<details>
<summary>JedWatson/classnames (classnames)</summary>

### [`v2.5.1`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v251--2023-12-29)

[Compare Source](JedWatson/classnames@v2.5.0...v2.5.1)

-   Remove `workspaces` field from package ([#&#8203;350](JedWatson/classnames#350))

### [`v2.5.0`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v250--2023-12-27)

[Compare Source](JedWatson/classnames@v2.4.0...v2.5.0)

-   Restore ability to pass a TypeScript `interface` ([#&#8203;341](JedWatson/classnames#341))
-   Add `exports` field to package ([#&#8203;342](JedWatson/classnames#342))

### [`v2.4.0`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v240--2023-12-26)

[Compare Source](JedWatson/classnames@v2.3.3...v2.4.0)

-   Use string concatenation to increase performance thanks [Jon Koops](https://github.com/jonkoops) ([#&#8203;336](JedWatson/classnames#336))

### [`v2.3.3`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v233--2023-12-21)

[Compare Source](JedWatson/classnames@v2.3.2...v2.3.3)

-   Fix default export, thanks [Remco Haszing](https://github.com/remcohaszing) ([#&#8203;301](JedWatson/classnames#301))
-   Fix types for read-only arrays, thanks [Ben Thompson](https://github.com/BenGearset) ([#&#8203;307](JedWatson/classnames#307))
-   Replace README examples with functional-style components, thanks [JoeDGit](https://github.com/JoeDGit) ([#&#8203;303](JedWatson/classnames#303))

### [`v2.3.2`](https://github.com/JedWatson/classnames/blob/HEAD/HISTORY.md#v232--2022-09-13)

[Compare Source](JedWatson/classnames@v2.3.1...v2.3.2)

-   Fix TypeScript types when using require, thanks [Mark Dalgleish](https://github.com/markdalgleish) ([#&#8203;276](JedWatson/classnames#276))
-   Fix toString as `[Object object]` in a vm, thanks [Remco Haszing](https://github.com/remcohaszing) ([#&#8203;281](JedWatson/classnames#281))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xNDIuNSIsInVwZGF0ZWRJblZlciI6IjM4LjE0Mi41IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: https://gitea.bruyant.xyz/alexandre/PaletteSwitcher/pulls/48
Co-authored-by: Renovate <renovate@bruyant.xyz>
Co-committed-by: Renovate <renovate@bruyant.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants