From 97f738eaf0762baa9e9927ea7bbe7ab63a93d254 Mon Sep 17 00:00:00 2001 From: witchiest <62822174+gaymeowing@users.noreply.github.com> Date: Fri, 22 Nov 2024 13:19:51 -0500 Subject: [PATCH] Add reasoning for not preferring type-pack union syntax --- docs/result-type-operator.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/result-type-operator.md b/docs/result-type-operator.md index 5ebc316..adda6bb 100644 --- a/docs/result-type-operator.md +++ b/docs/result-type-operator.md @@ -104,18 +104,16 @@ local success, result = pcall(mrow, "cat food", ":3") ## Alternatives Allow for type pack unions to be written by developers, with the syntax probably looking like this: - ```luau local function mrow(meow: string, mrrp: string): (true, string) | (false, nil) -- code here end ``` - With this example breaking backwards compadibility with some types developers may have written already, as today the following is allowed: - ```luau -- inferred as: ((meow: string, mrrp: string) -> (true, string)) | false type mrrp = (meow: string, mrrp: string) -> (true, string) | false ``` +Although it should be mentioned that result types are the only valid usecase for type pack unions, and just having a result type would remove a potential footgun of someone using type pack unions for something thats not a result type. Do nothing, and leave it up to developers if they want to write overloaded functions, or make their own result type.