Inspect
Returns the inputted type but with unions, intersections and negations turned into tables so they can be inspected / debugged better.
Params
| Name | Type | Description |
|---|---|---|
| input | any | The type to be inspected. |
Example
luau
type Result = Inspect<"hello" | ("world" & string)>
--[[
type Result = {
1: "hello",
2: {
1: "world",
2: string,
kind: "intersection"
},
kind: "union"
}
]]Expect
Throws a type error if the first type does not equal the second.
Params
| Name | Type | Description |
|---|---|---|
| expect | any | The type to be compared. |
| toBe | any | The type you want to compare expect to. |
Example
luau
type test = Expect<
{ foo: "bar" } & { hello: "world" },
(string, boolean) -> ...any
>
--[[
TypeError: 'Expect' type function errored at runtime: [string "Expect"]:2295:
Expected the function type below:
> (string, boolean) -> (...any)
But Got this intersection type instead:
> {
> foo: "bar"
> } & {
> hello: "world"
> }
]]Negate
Negates a type.
TEMPORARY
This type function will be removed once luau gets negation syntax (see the negation-types RFC).
Params
| Name | Type | Description |
|---|---|---|
| input | any | The type to stringify. |
Example
luau
type Result = Negate<string>
-- type Result = ~string