Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed Jan 31, 2025
1 parent e573eb7 commit 87dd0e1
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 124 deletions.
5 changes: 3 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ const compileModules = [
const ignoreList = [];

// cnpm use `_` as prefix
['', '_'].forEach((prefix) => {
compileModules.forEach((module) => {
['', '_'].forEach(prefix => {
compileModules.forEach(module => {
ignoreList.push(`${prefix}${module}`);
});
});

module.exports = {
transformIgnorePatterns: [`/node_modules/(?!${ignoreList.join('|')})[^/]+?/(?!(es)/)`],
setupFiles: ['./tests/setup.ts'],
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
"@types/enzyme": "^3.10.5",
"@types/jest": "^29.4.0",
"@types/keyv": "4.2.0",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.0.11",
"@types/node": "^22.12.0",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@umijs/fabric": "^4.0.1",
"coveralls": "^3.0.6",
"cross-env": "^7.0.2",
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useIndicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const useIndicator = (options: UseIndicatorOptions) => {
const { size, align = 'center' } = indicator;

const [inkStyle, setInkStyle] = useState<React.CSSProperties>();
const inkBarRafRef = useRef<number>();

const inkBarRafRef = useRef<number>(undefined);

const getLength = React.useCallback(
(origin: number) => {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTouchMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function useTouchMove(
const [lastTimestamp, setLastTimestamp] = useState<number>(0);
const [lastTimeDiff, setLastTimeDiff] = useState<number>(0);
const [lastOffset, setLastOffset] = useState<{ x: number; y: number }>();
const motionRef = useRef<number>();
const motionRef = useRef<number>(undefined);

// ========================= Events =========================
// >>> Touch events
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function useTouchMove(
}

// >>> Wheel event
const lastWheelDirectionRef = useRef<'x' | 'y'>();
const lastWheelDirectionRef = useRef<'x' | 'y'>(undefined);

function onWheel(e: WheelEvent) {
const { deltaX, deltaY } = e;
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/useUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { useRef, useState } from 'react';
* Help to merge callback with `useLayoutEffect`.
* One time will only trigger once.
*/
export default function useUpdate(callback: VoidFunction): () => void {
function useUpdate(callback: VoidFunction): () => void {
const [count, setCount] = useState(0);
const effectRef = useRef(0);
const callbackRef = useRef<VoidFunction>();
const callbackRef = useRef<VoidFunction>(undefined);
callbackRef.current = callback;

// Trigger on `useLayoutEffect`
Expand Down Expand Up @@ -56,3 +56,5 @@ export function useUpdateState<T>(

return [state.current, updater];
}

export default useUpdate;
6 changes: 6 additions & 0 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Mock ResizeObserver
global.ResizeObserver = class ResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
};
96 changes: 0 additions & 96 deletions tests/swipe.js

This file was deleted.

25 changes: 6 additions & 19 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,16 @@
"target": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"lib": [
"dom",
"es2017"
],
"lib": ["dom", "es2017"],
"jsx": "react",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
"@/*": [
"src/*"
],
"@@/*": [
".dumi/tmp/*"
],
"rc-tabs": [
"src/"
]
"@/*": ["src/*"],
"@@/*": [".dumi/tmp/*"],
"rc-tabs": ["src/"]
}
},
"include": [
".dumirc.ts",
"**/*.ts",
"**/*.tsx"
]
}
"include": [".dumirc.ts", "**/*.ts", "**/*.tsx", "tests/swipe.js"]
}

0 comments on commit 87dd0e1

Please sign in to comment.