SSR: TS2304: Cannot find name 'ScrollBehavior'.
See original GitHub issueWhen I have the next SSR setup:
import { createMemoryNavigation } from 'navi'
import { Router, View } from 'react-navi'
// ...
const navigation = createMemoryNavigation({
routes,
url: request.url,
})
const route = await navigation.getRoute()
const clientMarkup = renderToString(
<Router navigation={navigation}>
<View />
</Router>,
)
The server build via webpack produces the next TypeScript (awesome-typescript-loader) exception:
ERROR in [at-loader] ./node_modules/react-navi/dist/types/HashScroll.d.ts:3:55
TS2304: Cannot find name 'ScrollBehavior'.
The error concerns this reference:
// react-navi/dist/types/HashScroll.d.ts:3:55
export declare const HashScrollContext: React.Context<ScrollBehavior>;
export interface HashScrollProps {
behavior?: HashScrollBehavior;
children: React.ReactNode;
}
ScrollBehavior
type itself is a built-in type from the dom
TypeScript library.
Current behavior
That type is required during the server build.
Expected behavior
Static (SSR) rendering does not reference client-side types.
I may dig deeper into this issue, but can’t promise any deadlines. If you have any out-of-head insights it would be very appreciated. Thank you.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
TypeScript getting error TS2304: cannot find name ' require'
I am getting the error "TS2304: Cannot find name 'require' " when I attempt to transpile a simple TypeScript Node.js page. I have...
Read more >ScrollBehavior definition is missing 'instant' for scrollTo #46654
Actual behavior. The value of 'instant' cannot be assigned to behavior when using element.
Read more >vue-router - npm
Since the library is still unstable and because we want feedback on bugs and missing features, it will probably go through a few...
Read more >override scrollbehavior vue Code Example - Code Grepper
The type or namespace name 'IEnumerator' could not be found (are you missing a using directive or an assembly reference?) latex image textwidth...
Read more >Migrating from Vue 2 - Vue Router
On SSR, you need to manually pass the appropriate history: ... component: UserDetails }] // Missing the `id` param will fail router.push({ name:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing, as this appears to be fixed in the latest release.
Wow, that’s odd. It must be a compilation issue, because the types are compiled on every release.
I can see if I can find a workaround for this, but before I do, could you try changing it in your node_modules directory and see if that’s enough to make TypeScript compile on the server? There’s also some
window
references in that file that I imagine may cause issues on the server.