Skip to content

Fix nilable source overload typing#75

Open
haziscool wants to merge 1 commit into
centau:mainfrom
haziscool:haziscool/source-nilable-overload-type
Open

Fix nilable source overload typing#75
haziscool wants to merge 1 commit into
centau:mainfrom
haziscool:haziscool/source-nilable-overload-type

Conversation

@haziscool
Copy link
Copy Markdown

@haziscool haziscool commented May 22, 2026

Using Vide sources under the new typesolver currently presents this LSP warning:

TypeError: Calling function (() -> string?) & ((string?) -> string?) with argument pack () is ambiguous.

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 with T, which preserves valid writes, including nil for 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 on select("#", ...), while the public type is an overloaded callable intersection.

Fixes #71

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.

Getting a source with a nullable value confuses type checker

1 participant