From 5c26c39cf0b966c212da0378cc0bee6305133dfd Mon Sep 17 00:00:00 2001 From: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com> Date: Tue, 3 Dec 2024 04:50:51 -0800 Subject: [PATCH] RFC: Support for thread and buffer Types in User-Defined Type Functions (#77) --- ...er-types-in-user-defined-type-functions.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/support-for-thread-and-buffer-types-in-user-defined-type-functions.md diff --git a/docs/support-for-thread-and-buffer-types-in-user-defined-type-functions.md b/docs/support-for-thread-and-buffer-types-in-user-defined-type-functions.md new file mode 100644 index 00000000..b11d4863 --- /dev/null +++ b/docs/support-for-thread-and-buffer-types-in-user-defined-type-functions.md @@ -0,0 +1,34 @@ +# Support for thread and buffer Types in User-Defined Type Functions + +## Summary + +Add support for 'thread' and 'buffer' primitive types, omitted from original user-defined type function RFC. + +## Motivation + +While more rarely used than 'string' or 'number', 'thread' and 'buffer' are perfectly valid primitive types already supported by Luau typechecking engine, so should be included in user-defined type function API. + +Developers are already hitting this limitation and there's no specific reason to exclude these types. + +## Design + +We propose two new library properties and two new type tags. + +No methods are added for types with these new tags. + +### Update `types` Library + +| Library Properties | Type | Description | +| ------------- | ------------- | ------------- | +| `thread` | `type` | an immutable instance of the built-in type `thread` | +| `buffer` | `type` | an immutable instance of the built-in type `buffer` | + +### Update `type` Instance + +| Instance Properties | Type | Description | +| ------------- | ------------- | ------------- | +| `tag` | `"nil" \| "unknown" \| "never" \| "any" \| "boolean" \| "number" \| "string" \| "singleton" \| "negation" \| "union" \| "intersection" \| "table" \| "function" \| "class" \| "thread" \| "buffer"` | an immutable property holding this type's tag | + +## Drawback + +Unclear if this proposal has any drawbacks.