question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSR: TS2304: Cannot find name 'ScrollBehavior'.

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jamesknelsoncommented, Dec 26, 2019

Closing, as this appears to be fixed in the latest release.

1reaction
jamesknelsoncommented, Jul 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found