We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following produces a runtime exception with no type errors.
import { getShow } from '@unsplash/sum-types-fp-ts'; import * as Sum from '@unsplash/sum-types'; type S = Sum.Member<'A'> | Sum.Member<'B'>; const S = Sum.create<S>(); const show = getShow<S>({ A: 'Custom', }); console.log(show.show(S.mk.A));
https://stackblitz.com/edit/typescript-5afkt4?file=index.ts
I believe if supplied, A must be an instance of Show but TS doesn't check for it.
A
Show
Side note, I find it a little confusing prepending the sum member key in the show output here https://github.com/unsplash/sum-types-fp-ts/blob/master/src/index.ts#L153 . In the following code I'm expecting the show output to be CustomA but instead I get A CustomerA
CustomA
A CustomerA
const show = getShow<S>({ A: { show: () => "CustomA" } });
The text was updated successfully, but these errors were encountered:
This appears to only be an issue with nullary sums. Add any non-nullary member and A will be flagged as an unknown property.
Looks like an issue with {} as well:
{}
// no error const x: {} = { B: 123, } // unknown property error on `B` const y: { A: string } = { B: 123, }
That looks like expected (questionable) TS behaviour: microsoft/TypeScript#47486 (comment)
This bug very likely applies to the other exports as well, both here and in other libraries.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
The following produces a runtime exception with no type errors.
https://stackblitz.com/edit/typescript-5afkt4?file=index.ts
I believe if supplied,
A
must be an instance ofShow
but TS doesn't check for it.Side note, I find it a little confusing prepending the sum member key in the show output here https://github.com/unsplash/sum-types-fp-ts/blob/master/src/index.ts#L153 . In the following code I'm expecting the show output to be
CustomA
but instead I getA CustomerA
The text was updated successfully, but these errors were encountered: