-
| Hi, I am getting following TS linting error: For return type from const [, setScrollPos, stopScroll] = useSpring(() => { if (isBrowser()) { return { immediate: false, from: { y: window.pageYOffset }, onChange: (y: number) => {}, onRest: () => {}, config: config.slow, }; } else { return { from: { y: 0 }, }; } });This discussion is on the issue raised here - #822, which has been closed, but I am still getting the error, even after various tries. Please help me understand if I am doing something wrong. Technical Details:
tsconfig.json{ "compilerOptions": { "allowJs": true, "baseUrl": ".", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, "jsx": "preserve", "lib": [ "dom", "dom.iterable", "es6", "esnext" ], "module": "esnext", "moduleResolution": "node", "noEmit": true, "paths": {}, "resolveJsonModule": true, "skipLibCheck": true, "strict": true, "target": "es6", }, "exclude": [ "node_modules" ], "include": [ "next-env.d.ts", "**/*.ts", "**/*.tsx" ], "typeRoots": [ "./node_modules/@types", "./typings" ] } |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
| This is a bug. You must be returning invalid props, and the overload order makes TypeScript think you're trying to use the |
Beta Was this translation helpful? Give feedback.
-
| I solved this (temporarily) by forcefully passing const [, setScrollPos, stopScroll] = useSpring(() => { if (isBrowser()) { return { immediate: false, from: { y: window.pageYOffset }, onChange: (y: number) => {}, onRest: () => {}, config: config.slow, }; } else { return { from: { y: 0 }, }; } }, []); |
Beta Was this translation helpful? Give feedback.
I solved this (temporarily) by forcefully passing
depsparameters.