Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History v5 types error + back and forward actions are not exported #99

Open
MustonenMishka opened this issue Oct 4, 2022 · 7 comments

Comments

@MustonenMishka
Copy link

  • goBack and goForward methods are no longer exist in history v5 types. Build process is crashing
  • new back and forward actions are not exported from index.ts
@MustonenMishka
Copy link
Author

I think the possible solution is to leave history v4 behind and fully switch to v5. It will get rid of type errors and use appropriate methods

@connorcook-shippo
Copy link

connorcook-shippo commented Oct 12, 2022

Getting these errors too, currently transitioning from react-router v5 to v6 and it's tripping me up. At present, my app won't compile, but it's not clear if it's from this specific issue or from something else.

Update- the issue blocking actual building of the app was something else, but the warning persists in an otherwise successful app execution now that I'm fully on v6 for react-router-dom. I'll need to give the below suggestion a shot in the meantime.

@MustonenMishka
Copy link
Author

MustonenMishka commented Oct 13, 2022 via email

@baileyandy
Copy link

I am seeing the same incompatibility with this and the latest history v5.3.0.

> tsc --noEmit
node_modules/redux-first-history/src/actions.ts:48:71 - error TS2339: Property 'goBack' does not exist on type 'History'.
48 export const goBack: () => CallHistoryMethodAction<Parameters<History['goBack']>> =
node_modules/redux-first-history/src/actions.ts:50:74 - error TS2339: Property 'goForward' does not exist on type 'History'.
50 export const goForward: () => CallHistoryMethodAction<Parameters<History['goForward']>> =

I think it was missed because this project's dev dependency is still on history v4 when these properties still existed. It was an undocumented breaking change in history v4 -> v5, see remix-run/history#811

@connorcook-shippo
Copy link

I will be the first to admit I'm not familiar with the best way to solve this issue, nor have I made many contributions to package development- but if we know it'll have either back OR goBack, and forward OR goForward, could do we an approach that uses one or the other based on what's available? The change mentioned by baileyandy states that they are functionally equivalent, it's just the name that's changed.

If that isn't possible, then the original suggestion to abandon history v4 altogether- potentially with a minor, or even major, version change- is probably the next best option here. It feels like potential overkill for just this issue, so if we have an easier way to solve it that would probably be preferred, but... it's gotta happen at some point anyway, right?

@apricoder
Copy link

as a workaround for the compilation error you can add this somewhere in your code:

declare module 'history' {
  interface History {
    goBack(): void;
    goForward(): void;
  }
}

and then just use history.back() / history.forward()

@GunseiKPaseri
Copy link

I have placed the following file history.d.ts under @types directory.

// eslint-disable-next-line @typescript-eslint/no-unused-vars
import Histroy from 'history';
declare module 'history' {
  interface History{
    goBack(): void;
    goForward(): void;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants