Fix nilable source overload typing#75
Open
haziscool wants to merge 1 commit into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Using Vide sources under the new typesolver currently presents this LSP warning:
This could be a Luau bug, I've opened a PR there to resolve this issue upstream in that case:
luau-lang/luau#2410
However, the Luau team may decide this is intended behaviour and not merge the change.
For now, to unblock Vide users on the new type solver, I've adjusted the sources type.
I modeled the setter side of
Source<T>as a generic intersection withT, which preserves valid writes, includingnilfor nilable sources, while preventing it from competing with the getter overload for zero-argument reads.The returned closure is cast to
Source<T>inside the factory because the runtime implementation is one variadic function that branches onselect("#", ...), while the public type is an overloaded callable intersection.Fixes #71