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

Use with Redux toolkit - "Type instantiation is excessively deep and possibly infinite" #19

Open
ssirowy opened this issue Apr 3, 2022 · 8 comments
Labels
Repro Requested Unable to reproduce described behavior

Comments

@ssirowy
Copy link

ssirowy commented Apr 3, 2022

🐛 Potential Bug report

I recently pulled down spectacles-ts into a React/Redux-based application as an alternative to using lodash's get for pulling data from a Redux store.

Unfortunately, I hit a barrier pretty quickly in receiving a "Type instantiation is excessively deep and possibly infinite" error.

My Redux state type is generated using this approach from the Redux toolkit's documentation.

Without getting into details of our Redux store, the structure is fairly flat, with about 9-10 slices defined generated using the Redux toolkit library.

Here is a screenshot of the error:
Screen Shot 2022-04-03 at 2 36 43 PM

I am in general just curious if this error has come up before and If this library is expected to work on more complex objects shown in the examples. Would love to give this library use, but stumbled pretty quickly, and any potential ideas on how I can solve would be greatly appreciated. Thanks!

Your environment

Software Version(s)
spectacles-ts 1.0.3
fp-ts 2.11.8
TypeScript 4.4.3
react 17.0.2
redux 4.1.1
redux-toolkit 1.6.2
@anthonyjoeseph
Copy link
Owner

thanks for this! Could you post the IGlassState type, or something equivalent?

A typescript playground would be great - something like this

@anthonyjoeseph
Copy link
Owner

I've just released a new version of spectacles (1.0.6) with some type optimizations that should help

Also, I noticed that you're using typescript version 4.4.3. Spectacles relies heavily on tail-recursion, which was optimized in typescript v 4.5. If it's possible to upgrade, that might help

@ahrjarrett
Copy link

@anthonyjoeseph you might consider adding 4.5 as an optional peer dependency?

{
  "peerDependencies": { 
    "typescript": "> 4.5.0",
  },
  "peerDependenciesMeta": {
    "typescript": {
      "optional": true
    }
  }
}

@anthonyjoeseph
Copy link
Owner

Thanks for the suggestion! As per the yarn docs

Having a peer dependency means that your package needs a dependency that is the same exact dependency as the person installing your package

They refer to "dependencies", not "devDependencies". Typescript is a "devDependency". Unfortunately, I don't think there is a "peerDevDependencies"

I will however add it to the README. I'm actively investigating how spectacles-ts behaves on lower versions of typescript as well

@anthonyjoeseph
Copy link
Owner

Actually, looks like the Typescript team has a feature for this (sort of) using typeVersions. Going to make a PR

@anthonyjoeseph anthonyjoeseph added the Repro Requested Unable to reproduce described behavior label Apr 7, 2022
@anthonyjoeseph
Copy link
Owner

@ssirowy Closing if lieu of a repro. If you're able to make one, please feel free to post it and we can re-open the issue

Thanks for supporting the library!

@chrisfernandes102
Copy link

chrisfernandes102 commented Jun 23, 2022

@anthonyjoeseph I work with @ssirowy and was looking into this issue. I attempted to update to the latest typescript version but am running into the same problem. I made a TS playground for you here:

Typescrypt Playground

@anthonyjoeseph
Copy link
Owner

Hey @chrisfernandes102 ! sorry for the very late reply. Are you still getting this error locally? I'm not seeing it on my desktop machine. It could just be an issue w/ the typescript playground system - sometimes imports get a bit messed up. For example, fp-ts HKT doesn't work in playgrounds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Repro Requested Unable to reproduce described behavior
Projects
None yet
Development

No branches or pull requests

4 participants