From 8ba1561374e30e0c2a7861a19087876ea1076262 Mon Sep 17 00:00:00 2001 From: Cameron Campbell Date: Fri, 16 May 2025 23:04:17 +0100 Subject: [PATCH 1/4] Update init.luau --- src/init.luau | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/init.luau b/src/init.luau index 8bc018f..495cfe0 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1454,24 +1454,7 @@ end -- type Result = "hello" & string ]=] export type function OmitIntersection(input: type, to_omit: type) - return handle_negation(input, function(input: type, input_tag: string) - if input_tag == "union" then - return union_from_components(components_map(input:components(), OmitIntersection, to_omit)) - end - - if to_omit.tag == "union" then - local hashset, non_hashsettable = hashset_from_components(FlattenUnion(to_omit):components()) - - return intersection_filter(input, input_tag, function(component): boolean - return hashset_has_type(hashset, non_hashsettable, component, component.tag) - end) or types.never - - else - return intersection_filter(input, input_tag, function(component) - return component == to_omit - end) or types.never - end - end) + -- i broke this teehee >:) end --[=[ @@ -2427,4 +2410,4 @@ return nil LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] \ No newline at end of file +]] From 21d0f5aeee5509611e8e6e4f358de443897eb42e Mon Sep 17 00:00:00 2001 From: Cameron Campbell Date: Fri, 16 May 2025 23:21:49 +0100 Subject: [PATCH 2/4] Update init.luau --- src/init.luau | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/init.luau b/src/init.luau index 495cfe0..9f83e97 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1454,7 +1454,24 @@ end -- type Result = "hello" & string ]=] export type function OmitIntersection(input: type, to_omit: type) - -- i broke this teehee >:) + return handle_negation(input, function(input: type, input_tag: string) + if input_tag == "union" then + return union_from_components(components_map(input:components(), OmitIntersection, to_omit)) + end + + if to_omit.tag == "union" then + local hashset, non_hashsettable = hashset_from_components(FlattenUnion(to_omit):components()) + + return intersection_filter(input, input_tag, function(component): boolean + return hashset_has_type(hashset, non_hashsettable, component, component.tag) + end) or types.never + + else + return intersection_filter(input, input_tag, function(component) + return component == to_omit + end) or types.never + end + end) end --[=[ From 54f885a8757db82d68d882b7daa7287ed23a37e0 Mon Sep 17 00:00:00 2001 From: Cameron Campbell Date: Fri, 16 May 2025 23:40:00 +0100 Subject: [PATCH 3/4] Update init.luau --- src/init.luau | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/init.luau b/src/init.luau index 9f83e97..968d4f9 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1393,17 +1393,7 @@ end -- type Result = "foo" | "hello" | "lol" | "world" ]=] export type function FlattenUnion(input: type) - return handle_negation(input, function(input: type, input_tag: string) - if input_tag == "intersection" then - return intersection_from_components(components_map(input:components(), FlattenUnion)) - end - if input_tag == "union" then - return union_from_components(components_flatten(input:components(), "union", union_from_components)) or types.never - else - return input - end - end) end --[=[ From 9cbbb814ab37881401b3a78722e9da0d753c5553 Mon Sep 17 00:00:00 2001 From: Cameron Campbell Date: Fri, 16 May 2025 23:46:06 +0100 Subject: [PATCH 4/4] Update init.luau --- src/init.luau | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/init.luau b/src/init.luau index 968d4f9..9f83e97 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1393,7 +1393,17 @@ end -- type Result = "foo" | "hello" | "lol" | "world" ]=] export type function FlattenUnion(input: type) + return handle_negation(input, function(input: type, input_tag: string) + if input_tag == "intersection" then + return intersection_from_components(components_map(input:components(), FlattenUnion)) + end + if input_tag == "union" then + return union_from_components(components_flatten(input:components(), "union", union_from_components)) or types.never + else + return input + end + end) end --[=[