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.

[ramda_v0.26.x] Cannot call `R.pipe`: string is not compatible with null or undefined

See original GitHub issue

Consider this function:

const setLayout = (callback: (GridItem[]) => void) =>
  R.pipe(
    key => localStorage.getItem(key),
    R.tryCatch(JSON.parse, R.F),
    R.when(isLayoutValid, callback)
  );

setLayout(someCallback)('someKey');

flow will throw an error:

Cannot call `R.pipe`: string is not compatible with null or undefined

JSON.parse expects a string as an input, but first function in the pipe may return either string or undefined.

Should R.tryCatch suppress this sort of error popping up?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
LoganBarnettcommented, Apr 24, 2019

@retyui ugh - I was thinking JSON.stringify. I will sit in silent shame now. Thanks for chiming in!

1reaction
genesstcommented, Mar 19, 2019

Should R.tryCatch suppress this sort of error popping up?

in terms of types, the answer is no

Any way I could wrap R.tryCatch into something that would prevent the error?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TruncatePipe fails with undefined or null input value to truncate
When value to truncate is undefined or null, the TruncatePipe.transform() call throws a TypeError. This error points to line 12 of truncate.pipe.ts where ......
Read more >
Is there a way to check for both `null` and `undefined`?
Using a juggling-check, you can test both null and undefined in one hit: if (x == null) {. If you use a strict-check,...
Read more >
18 Pipes | R for Data Science
18.1 Introduction Pipes are a powerful tool for clearly expressing a sequence of multiple operations. So far, you've been using them without knowing...
Read more >
Pipes in R Tutorial For Beginners | Discover %>% with magrittr
This tutorial will give you an introduction to pipes in R and will cover the following topics: Run and edit the code from...
Read more >
Create Custom Pipe in Angular to Replace Null Value With a ...
Not a good user experience. We will solve that problem by creating our own custom pipe that will replace the null or undefined...
Read more >

github_iconTop Related Medium Post

No results found

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