jmurphyau / ember-truth-helpers

Ember HTMLBars Helpers for {{if}} & {{unless}}: not, and, or, eq & is-array
MIT License
706 stars 95 forks source link

Incorrect glint return type for `or` helper in 4.0.0-beta.0 #187

Closed Techn1x closed 1 year ago

Techn1x commented 1 year ago

Thanks for cutting a release with the glint types.

I updated my application to use the 4.0.0-beta.0 and its glint types, switching away from the types provided by the gavant package https://github.com/Gavant/glint-template-types/tree/main/types/ember-truth-helpers

This has brought up some issues with the return value of the or helper not being correct. The values that the or helper in this addon returns is always one of the args it was given, as if it were a javascript argA || argB. However, it is typed to return strictly boolean, which is not representative of what is actually returned by the helper. https://github.com/jmurphyau/ember-truth-helpers/blob/00519085b4939b9973687250980636f47695eee1/packages/ember-truth-helpers/src/helpers/or.ts#L9

The gavant package types dealt with this in the following way https://github.com/Gavant/glint-template-types/blob/cd9efb6617d93c28d93800270e3af1963fd792c6/types/ember-truth-helpers/or.d.ts#L21

Return: OrPair<OrPair<OrPair<OrPair<A, B>, C>, D>, E>;

There's some extra details on the behaviour of the or helper in this issue comment https://github.com/jmurphyau/ember-truth-helpers/issues/150#issuecomment-1644930394

SergeAstapov commented 1 year ago

@Techn1x thanks for reporting this. It's a known issue and the only reason why we didn't cut v4 and went with beta instead as described in https://github.com/jmurphyau/ember-truth-helpers/releases/tag/v4.0.0-beta.0

We are working on fixing this in #185 and #188.

Techn1x commented 1 year ago

Ah! Thanks. I did not realise it was known / being worked on. Hopefully this issue shows that to others while we work on it so they don't open issues as well.