Skip to content

Commit

Permalink
minor TS bump
Browse files Browse the repository at this point in the history
  • Loading branch information
imjordanxd committed Feb 7, 2025
1 parent cf1af2d commit 3cebdda
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"ts-jest": "26.5.6",
"ts-loader": "8.4.0",
"ts-node": "10.9.2",
"typescript": "4.1.5"
"typescript": "4.3.5"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion src/factory/createReducerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const createReducerContext = <R extends React.Reducer<any, any>>(
children?: React.ReactNode;
initialState?: React.ReducerState<R>;
}) => {
const state = useReducer<React.ReducerState<R>, [ReducerAction<R>]>(
const state = useReducer(
reducer,
initialState !== undefined ? initialState : defaultInitialState
);
Expand Down
2 changes: 1 addition & 1 deletion src/misc/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const noop = () => {};
export const noop = () => { };

export function on<T extends Window | Document | HTMLElement | EventTarget>(
obj: T | null,
Expand Down
6 changes: 3 additions & 3 deletions src/useEvent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { isBrowser, off, on } from './misc/util';
import { isBrowser } from './misc/util';

export interface ListenerType1 {
addEventListener(name: string, handler: (event?: any) => void, ...args: any[]);
Expand Down Expand Up @@ -46,13 +46,13 @@ const useEvent = <T extends UseEventTarget>(
return;
}
if (isListenerType1(target)) {
on(target, name, handler, options);
target.addEventListener(name, handler, options);
} else if (isListenerType2(target)) {
target.on(name, handler, options);
}
return () => {
if (isListenerType1(target)) {
off(target, name, handler, options);
target.removeEventListener(name, handler, options);
} else if (isListenerType2(target)) {
target.off(name, handler, options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/useMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const useMethods = <M, T>(
[createMethods]
);

const [state, dispatch] = useReducer<T, [Action]>(reducer, initialState);
const [state, dispatch] = useReducer(reducer, initialState);

const wrappedMethods: WrappedMethods<M> = useMemo(() => {
const actionTypes = Object.keys(createMethods(initialState));
Expand Down
2 changes: 1 addition & 1 deletion src/useMouseWheel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { off, on } from './misc/util';
export default () => {
const [mouseWheelScrolled, setMouseWheelScrolled] = useState(0);
useEffect(() => {
const updateScroll = (e: MouseWheelEvent) => {
const updateScroll = (e: WheelEvent) => {
setMouseWheelScrolled(e.deltaY + mouseWheelScrolled);
};
on(window, 'wheel', updateScroll, false);
Expand Down
8 changes: 4 additions & 4 deletions src/useSize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const useSize = (
const iframe = ref.current;
const size = iframe
? {
width: iframe.offsetWidth,
height: iframe.offsetHeight,
}
width: iframe.offsetWidth,
height: iframe.offsetHeight,
}
: { width, height };

setState(size);
Expand Down Expand Up @@ -73,7 +73,7 @@ const useSize = (
}

return () => {
if (window && window.removeEventListener) {
if (window?.removeEventListener) {
off(window, 'resize', setSize);
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/useToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const toggleReducer = (state: boolean, nextValue?: unknown) =>
typeof nextValue === 'boolean' ? nextValue : !state;

const useToggle = (initialValue: boolean): [boolean, (nextValue?: unknown) => void] => {
return useReducer<boolean, [unknown]>(toggleReducer, initialValue);
return useReducer(toggleReducer, initialValue) as [boolean, (nextValue?: unknown) => void];
};

export default useToggle;
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"noImplicitReturns": true,
"noImplicitAny": false,
"noFallthroughCasesInSwitch": true,
// "useUnknownInCatchVariables": false, // requires a lot of changes/casting
"outDir": "lib",
"lib": [
"es2018",
Expand All @@ -31,4 +32,4 @@
"jest.config.ts",
"jest.config.*.ts"
]
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17804,10 +17804,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@4.1.5:
version "4.1.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.5.tgz#123a3b214aaff3be32926f0d8f1f6e704eb89a72"
integrity sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA==
typescript@4.3.5:
version "4.3.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==

uglify-js@^3.1.4:
version "3.12.5"
Expand Down

0 comments on commit 3cebdda

Please sign in to comment.