-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
false type-error for a custom type definition #629
Comments
it looks like a valid error to me, if |
so it CAN be indexed if it returns a table, it should return a table when Argument 3 is set to true |
Yeah, the point is that it could return either of those 3 things, but Luau doesn't know which one gets returned. If it returned any of the other parts of the union type, then it would lead to a runtime error. So you get a type error here.
Luau doesn't know that, you haven't encoded it in your type. You could use a function overload that checks if the 3rd argument is true and then only return the table type: type GetProto = ((f: Function | number | ProtoProxy, index: number?, activated: true) -> { [number]: (() -> any) })
& ((f: Function | number | ProtoProxy, index: number?, activated: boolean?) -> { [number]: (() -> any) } | (() -> any) | ProtoProxy) In any case, this is not a Luau LSP issue. It is a valid type error. If you have incorrect type errors, I would recommend reporting them to Luau directly - this repository is only a language server implementation. |
the type definition:
the type error:
the type error prevention:
is this supposed to be that way?
The text was updated successfully, but these errors were encountered: