Giter Site home page Giter Site logo

Comments (4)

markerikson avatar markerikson commented on June 13, 2024 1

You must provide correctly typed arguments for all of the input functions. As of Reselect 4.1, Reselect infers everything from those arguments.

Define (_state: RootState) => 5 (and similarly for any other arguments), and it will all work correctly!

from reselect.

yndx-madfriend avatar yndx-madfriend commented on June 13, 2024

You must provide correctly typed arguments for all of the input functions. As of Reselect 4.1, Reselect infers everything from those arguments.

Define (_state: RootState) => 5 (and similarly for any other arguments), and it will all work correctly!

I do not understand why, with the new typings of createSelector, it makes such a difference (whether to have a function inlined or defined separately). Also, as I said, it all used to work in v3, and this new requirement of having separate definitions is not explicitly stated neither in changelog nor in readme.

from reselect.

markerikson avatar markerikson commented on June 13, 2024

It's not about the "inline" or "defined separately".

It's literally that you must tell Reselect what the types of the arguments are.

// ❌ FAILS - no type for `state`
createSelector(
  (state) => state.x,
  output
)

// ✅ WORKS - TS knows the type of `state`
createSelector(
  (state: RootState) => state.x,
  output
)

Reselect's types now infer everything from those arguments, and tbh I'm not sure how this ever would have worked even with the old types if you don't provide any argument types at all.

from reselect.

yndx-madfriend avatar yndx-madfriend commented on June 13, 2024

Thank you for clarifications @markerikson , it seems to work correctly now with declared types of arguments. 🎉

from reselect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.