React-Native + Typescript Error
Hey guys there is an error when I run yarn tsc
node_modules/@types/reach__router/index.d.ts:14:49 - error TS2304: Cannot find name 'Window'.
14 export type WindowLocation<S = LocationState> = Window['location'] & HLocation<S>;
~~~~~~
Found 1 error.
Any suggestion?
Same issue, Window shouldn't be present in react-native
I fixed this with a manual declaration:
declare module 'storybook-router' {
global {
interface Window {
location: any;
}
}
}
@djMax what file did you make the fix in?
I have a third party declaration folder, which I include via tsconfig:
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"outDir": "./build"
},
"include": [
"./src/*",
"../../@types/*"
]
}
I have a monorepo, so my config is more complicated, but the key line is including the @types folder (which I made, and which has this declaration in it)
@djMax sorry, but i'm still confused. Can you outline the steps you did? Based on what you wrote, I see that you created an @types folder and put the declaration
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"outDir": "./build"
},
"include": [
"./src/*",
"../../@types/*"
]
}
in it, but what did you name the file?
And what kind of file did you put this code
declare module 'storybook-router' {
global {
interface Window {
location: any;
}
}
}
did you add a file to .storybook?
These are generic typescript questions... But, it doesn't matter what you name the file, other than ".d.ts" extension, so mine is third-party.d.ts.
This seems like an issue with the reach router types. If you're sure this is related to storybook can you provide more details about your dev environment such as the version you have installed and the reach router version in the lock file. It possible that it can be fixed by an update to the reach router dependency on our side that's why I'm asking.
let me know if you want to reopen but I think this is outdated now