diff --git a/docs/syntax.md b/docs/syntax.md index cbc48f8a..baea0a5c 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -128,7 +128,7 @@ local array: { [number] : string } local object: { x: number, y: string } ``` -Additionally, the type syntax supports type intersections (`(number) -> string & (boolean) -> string`) and unions (`(number | boolean) -> string`). An intersection represents a type with values that conform to both sides at the same time, which is useful for overloaded functions; a union represents a type that can store values of either type - `any` is technically a union of all possible types. +Additionally, the type syntax supports type intersections (`((number) -> string) & ((boolean) -> string)`) and unions (`(number | boolean) -> string`). An intersection represents a type with values that conform to both sides at the same time, which is useful for overloaded functions; a union represents a type that can store values of either type - `any` is technically a union of all possible types. It's common in Lua for function arguments or other values to store either a value of a given type or `nil`; this is represented as a union (`number | nil`), but can be specified using `?` as a shorthand syntax (`number?`). diff --git a/docs/typecheck.md b/docs/typecheck.md index 2f418434..6720ae2c 100644 --- a/docs/typecheck.md +++ b/docs/typecheck.md @@ -227,7 +227,7 @@ local vec3: Vector3 = {x = 1, y = 2, z = 3} -- ok ``` ```lua -type SimpleOverloadedFunction = (string) -> number & (number) -> string +type SimpleOverloadedFunction = ((string) -> number) & ((number) -> string) local f: SimpleOverloadedFunction