Open Daw588 opened 1 week ago
TL;DR The newer type system expects the more precise literal type, but without an explicit type annotation, it defaults to string
.
It's like that because, in Luau's new type solver, type inference for anonymous functions may not always correctly infer a specific string literal type when it appears in a union like "do-not-register" | (() -> ())
, the type system infers "do-not-register"
as a broader string type; not matching the expected literal type.
This likely occurs because the return type of the anonymous functions is initially inferred as a string
, even though "do-not-register"
is a string literal, that matches the expected "do-not-register
".
Workaround:
This does not happen to code like this: