[Bug] Typing mistake in scope.run #10080
matthew-dean
started this conversation in
General Discussions
Replies: 1 comment 2 replies
-
It's explained in a code comment here: interface EffectScope {
run<T>(fn: () => T): T | undefined // undefined if scope is inactive
stop(): void
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note: I would classify this as a bug, but there's no clear way to submit repros of TypeScript errors, so I'm placing this here.
In the scope documentation it says this:
However, in the TypeScript types, it has this:
This sets the type to return the type of the return function OR
undefined
, regardless of whether or not the return value includesundefined
. When using this in my code, that meant that returningscope.run()
causes a mis-match to the expected return type of the function.However, what I don't know is if, in actuality,
scope.run()
can returnundefined
and the documentation is wrong? So either this is a typing error, or a documentation error.Beta Was this translation helpful? Give feedback.
All reactions