question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to actually use reselect's libdef?

See original GitHub issue

The reselect libdef is complex and I’m not sure how to read it.

Does it give you some way to pass in generics when use use createSelector, e.g. the type of your state object that will be passed into the returned function, so Flow can figure out the types of arguments etc? How exactly should I do this? I’ve tried this but it causes hundreds of confusing errors:

createSelector<State>(selector1, selector2, (one, two) => {...})

More generally, if a libdef does provide types that accept generics, and is complex enough to need to be documented, where should this documentation live?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:24 (17 by maintainers)

github_iconTop GitHub Comments

12reactions
julienwcommented, Feb 19, 2019

I haven’t tried, but wouldn’t the following work:

Instead of

export const testExplicitSelector = createSelector<State, *, *, *>(
  (state: State) => state.x,
  (x) => x + 1
);

do:

export const testExplicitSelector: State => number = createSelector(
  (state: State) => state.x,
  (x) => x + 1
);

Again I haven’t tried (in our project we still use a quite ancient version of flow), but this looks logical.

12reactions
jedwards1211commented, Dec 18, 2018

@samwgoldman it’s extremely unfortunate that the following annotations on the arguments are no longer sufficient for inferring the type parameters:

export const selectStuff = createSelector(
  ({ foo }: State) => foo,
  ({ bar }: State) => bar,
  (foo: number, bar: string): string => repeat(bar, foo)
)

I find it unacceptable to have to explicitly annotate the parameters in this case. This is the first change that’s made me want to rage-quit flow and migrate to TypeScript instead, but sadly I just have too much flow code to have time to migrate my entire codebase. Are there plans to fix this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

II04891: ISPF LIBDEF SERVICE EXPLANATION. - IBM
Reduce the number of search terms. Each term you use focuses the search further. Check your spelling. A single misspelled or incorrectly typed...
Read more >
Refactoring a Legacy Flow Codebase | by Jason Deng - Medium
Without any libdefs, Flow will assume that all library imports default to an any type. Using the any type causes Flow to opt-out...
Read more >
MVS/QuickRef User's Guide - Chicago-Soft, Ltd.
MVS/QuickRef can be used in a variety of ways; some examples are described ... MVS/QuickRef can be accessed either by using the ISPF...
Read more >
CA EPIC for z/VSE Message Reference Guide
your use of the CA software to which the Documentation relates; ... If the drive is still not ready, CA EPIC for z/VSE...
Read more >
SAS/SHARE 9.1: User's Guide
update or use concurrently accessed data in other ways. End users might not even ... Before the first invocation of the LIBDEF macro...
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found