Skip to content

Commit 5f62ea6

Browse files
committed
Object.hasOwn
1 parent bfd1cb4 commit 5f62ea6

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

packages/utils/src/store/ReactStore.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useRefWithInit } from '../useRefWithInit';
66

77
type TestState = { value: number; label: string };
88

9-
function useStableStore<State>(
9+
function useStableStore<State extends object>(
1010
initial: State,
1111
writeInterceptors?: Partial<{
1212
[Key in keyof State]: (value: State[Key]) => State[Key];

packages/utils/src/store/ReactStore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { NOOP } from '../empty';
1111
* A Store that supports controlled state keys, non-reactive values and provides utility methods for React.
1212
*/
1313
export class ReactStore<
14-
State,
14+
State extends object,
1515
Context = Record<string, never>,
1616
Selectors extends Record<string, SelectorFunction<State>> = Record<string, never>,
1717
> extends Store<State> {
@@ -192,7 +192,7 @@ export class ReactStore<
192192
public update(values: Partial<State>): void {
193193
const newValues = { ...values };
194194
for (const key in newValues) {
195-
if (!Object.prototype.hasOwnProperty.call(newValues, key)) {
195+
if (!Object.hasOwn(newValues, key)) {
196196
continue;
197197
}
198198

@@ -221,7 +221,7 @@ export class ReactStore<
221221
public setState(newState: State) {
222222
const newValues = { ...newState };
223223
for (const key in newValues) {
224-
if (!Object.prototype.hasOwnProperty.call(newValues, key)) {
224+
if (!Object.hasOwn(newValues, key)) {
225225
continue;
226226
}
227227

packages/utils/tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"moduleResolution": "bundler",
1111
"noEmit": false,
1212
"rootDir": "./src",
13-
"outDir": "build/esm"
13+
"outDir": "build/esm",
14+
"lib": ["ES2022", "DOM"]
1415
},
1516
"include": ["src/**/*.ts*", "src/**/*.tsx"],
1617
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"]

0 commit comments

Comments
 (0)