TS2345 when using Result with pipe
See original GitHub issueHello,
I’m getting a TS error when using Result
and pipe
and have no idea why!
const processEvent = (
event: MessageEvent<unknown>,
handle: (event: ServerEvent) => void,
error: (error: string) => void
) => {
pipe(
R.fromNullable(event, 'Incoming sse/ws message is null!'),
R.map((event) => event.data), // <--- ERROR HERE
R.flatMap((data: unknown) => {
try {
if (G.isString(data)) return R.Ok(JSON.parse(data));
} catch (_error) {
/* ignored */
}
return R.Error('Invalid incoming sse/ws message format!');
}),
R.flatMap((json: string) => {
try {
return R.Ok(ServerEventSchema.parse(json));
} catch (_error) {
return R.Error('Invalid incoming sse/ws message schema!');
}
}),
R.tapError(error),
R.tap(handle)
);
};
The message I get is the following:
TS2345: Argument of type 'Result<unknown, unknown>' is not assignable to parameter of type '(arg: Result<MessageEvent<unknown>, "Incoming sse/ws message is null!">) => Result<unknown, "Invalid incoming sse/ws message format!">'. Type 'Ok<unknown>' is not assignable to type '(arg: Result<MessageEvent<unknown>, "Incoming sse/ws message is null!">) => Result<unknown, "Invalid incoming sse/ws message format!">'. Type 'Ok<unknown>' provides no match for the signature '(arg: Result<MessageEvent<unknown>, "Incoming sse/ws message is null!">): Result<unknown, "Invalid incoming sse/ws message format!">'.
Any ideas?
Thanks!
Issue Analytics
- State:
- Created 9 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
error TS2345: Argument of type 'OperatorFunction<User, void ...
Why I am getting error from pipe and map from the following code? 416 · Typescript: Type 'string | undefined' is not assignable...
Read more >pipe(catchError()) type issues. #3673 - ReactiveX/rxjs - GitHub
@martinsik My local project is using 2.6.2 . Couldn't find TS version on the StackBlitz.
Read more >Practical Guide to Fp-ts P1: Pipe and Flow - Ryan's Blog
Learn how to use Fp-ts practically. Introduces the pipe and flow operators. No mathematical knowledge required.
Read more >What does the mean of pipe (|) symbol in Typescript
error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. Example 3: Using operations associated with ...
Read more >zodern:relay - Packosphere
1import { add } from '/imports/methods/add' 2 3add([1, 2]).then(result => { 4 ... Instead of defining a single run function, a pipeline allows...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mobily yup that did the trick! thanks!
@ChambreNoire awesome! 🎉 glad I could help 😃