Storybook: TypeScript, router, & react-native produce type error

Created on 16 Sep 2019  路  5Comments  路  Source: storybookjs/storybook

Describe the bug

$ tsc
node_modules/@types/reach__router/index.d.ts:9:37 - error TS2339: Property 'location' does not exist on type 'Window'.

9 export type WindowLocation = Window["location"] & HLocation;
                                      ~~~~~~~~~~


Found 1 error.

To Reproduce
Steps to reproduce the behavior:

  1. Set up a react-native project with [email protected]
  2. Run tsc

Expected behavior
No type errors

Additional context
@storybook/router is pulled in via this chain:

@storybook/react-native -> @storybook/client-api -> @storybook/router -> @types/reach__router

This dep was added in 5.2.0 to @storybook/router. I'm not sure I have an obvious solution here, unfortunately. That said, I'm not sure how @react/router is used in a React Native project w/ Storybook, since it's web-only.

react-native bug has workaround inactive typescript

All 5 comments

Had the same problem, just with React (I'm not using react-native)

As a workaround, you can add location property on the global window type:

declare module 'storybook-router' {
    global {
        interface Window {
            location: any
        }
    }
}

it's still an issue...

Hi @SophieDonut, we are going to separate out react native part of storybook to a separate repo, that should make solving issues like these easier in the future. :)

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rpersaud picture rpersaud  路  3Comments

zvictor picture zvictor  路  3Comments

tomitrescak picture tomitrescak  路  3Comments

MrOrz picture MrOrz  路  3Comments

purplecones picture purplecones  路  3Comments