Skip to content

Fix MemoryStoreService:UpdateAsync types#1395

Open
jackTabsCode wants to merge 1 commit intoroblox-ts:masterfrom
jackTabsCode:fix-sorted-map-update-async
Open

Fix MemoryStoreService:UpdateAsync types#1395
jackTabsCode wants to merge 1 commit intoroblox-ts:masterfrom
jackTabsCode:fix-sorted-map-update-async

Conversation

@jackTabsCode
Copy link
Copy Markdown
Contributor

@jackTabsCode jackTabsCode commented Oct 8, 2025

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.

LuaTuple<[value: T, sortKey?: string | number]> | undefined

Fixes #1394

@Dionysusnu
Copy link
Copy Markdown
Contributor

Dionysusnu commented Oct 9, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MemoryStoreService:UpdateAsync types are wrong

2 participants