You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a little uncertain about the LuaTuple types here. I don't know if there's precedent in the types for how to handle "nullable" multi-returns.
I think that this type is fine for the transform function return because it tells the user that they need to return nothing at all, or the value, or the value and the sortKey, not just the sortKey.
The preferred way of writing a nullable LuaTuple is LuaTuple<[content] | []>. This avoids issues where LuaTuples might not always be detected if they're nullable in the classic way.
In this case, it seems like the type should be | [undefined], since UpdateAsync expects an explicit nil rather than simply returning nothing. I'm not sure that would be a nice workflow though (requiring $tuple(undefined)), so maybe sticking with LuaTuple<> | undefined is more sensible.
Your issue mentions:
Additionally the return value of the method is supposed to reflect the return of the transform function, which includes the sort key, and should also be nullable.
This suggests we should apply the LuaTuple as a generic (rather than just the value), so that if the transform function narrows, the return type of UpdateAsync will match that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm a little uncertain about the
LuaTupletypes here. I don't know if there's precedent in the types for how to handle "nullable" multi-returns.I think that this type is fine for the transform function return because it tells the user that they need to return nothing at all, or the value, or the value and the sortKey, not just the sortKey.
Fixes #1394