Skip to content

Commit

Permalink
RFC: Support for thread and buffer Types in User-Defined Type Functio…
Browse files Browse the repository at this point in the history
…ns (#77)
  • Loading branch information
vegorov-rbx authored Dec 3, 2024
1 parent 03608c7 commit 5c26c39
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 5c26c39

Please sign in to comment.