Skip to content

Commit

Permalink
style(lib): replace keyof never with PropertyKey (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerAberbach authored Dec 1, 2024
1 parent cd1ac32 commit 14f2425
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/operations/collections.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const toWeakSet: <Value extends object>() => Reducer<
* @category Collections
* @since v0.0.1
*/
export const toObject: <Key extends keyof never, Value>() => RawKeyedReducer<
export const toObject: <Key extends PropertyKey, Value>() => RawKeyedReducer<
Key,
Value,
Record<Key, Value>
Expand Down Expand Up @@ -322,7 +322,7 @@ export const toMultiple: {
Reducers extends
| readonly [RawReducerWithoutFinish<Value, any>]
| readonly RawReducerWithoutFinish<Value, any>[]
| Readonly<Record<keyof never, RawReducerWithoutFinish<Value, any>>>,
| Readonly<Record<PropertyKey, RawReducerWithoutFinish<Value, any>>>,
>(
reducers: Reducers,
): Reducer<
Expand Down Expand Up @@ -363,7 +363,7 @@ export const toMultiple: {
)[]
| Readonly<
Record<
keyof never,
PropertyKey,
| RawReducerWithoutFinish<Value, any>
| RawOptionalReducerWithoutFinish<Value>
| FunctionReducer<Value>
Expand Down
6 changes: 3 additions & 3 deletions src/operations/generators.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import type {
*/
export const keys: {
<Key>(object: ReadonlyMap<Key, unknown>): Iterable<Key>
<Key extends keyof never>(
<Key extends PropertyKey>(
object: Readonly<Record<Key, unknown>>,
): Iterable<Key>
}
Expand Down Expand Up @@ -121,7 +121,7 @@ export const values: <Value>(
object:
| ReadonlyMap<unknown, Value>
| ReadonlySet<Value>
| Readonly<Record<keyof never, Value>>,
| Readonly<Record<PropertyKey, Value>>,
) => Iterable<Value>

/**
Expand Down Expand Up @@ -189,7 +189,7 @@ export const entries: {
<Key, Value>(object: {
entries: () => Iterable<[Key, Value]>
}): Iterable<[Key, Value]>
<Key extends keyof never, Value>(
<Key extends PropertyKey, Value>(
object: Readonly<Record<Key, Value>>,
): Iterable<[Key, Value]>
}
Expand Down
10 changes: 5 additions & 5 deletions test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ expect.extend({
let pass =
typeof received === `object` &&
received != null &&
typeof (received as Record<keyof never, unknown>)[Symbol.iterator] ===
typeof (received as Record<PropertyKey, unknown>)[Symbol.iterator] ===
`function`

let values1
Expand Down Expand Up @@ -49,7 +49,7 @@ expect.extend({
let pass =
typeof received === `object` &&
received != null &&
typeof (received as Record<keyof never, unknown>)[
typeof (received as Record<PropertyKey, unknown>)[
Symbol.asyncIterator
] === `function`

Expand Down Expand Up @@ -141,10 +141,10 @@ expect.extend({
received != null &&
[`add`, `finish`].every(
methodName =>
typeof (received as Record<keyof never, unknown>)[methodName] ===
typeof (received as Record<PropertyKey, unknown>)[methodName] ===
`function`,
) &&
!(received as Record<keyof never, unknown>).create
!(received as Record<PropertyKey, unknown>).create

return {
pass,
Expand All @@ -160,7 +160,7 @@ expect.extend({
[`create`, `add`, `finish`, keyed && `get`].filter(Boolean).every(
methodName =>
// eslint-disable-next-line typescript/no-unsafe-member-access
typeof (received as Record<keyof never, unknown>)[methodName] ===
typeof (received as Record<PropertyKey, unknown>)[methodName] ===
`function`,
)

Expand Down

0 comments on commit 14f2425

Please sign in to comment.