Skip to content

Add type annotations to the Luau variant of module#2

Open
Dekkonot wants to merge 1 commit intoRiskoZS:mainfrom
Dekkonot:luau-typechecking
Open

Add type annotations to the Luau variant of module#2
Dekkonot wants to merge 1 commit intoRiskoZS:mainfrom
Dekkonot:luau-typechecking

Conversation

@Dekkonot
Copy link
Copy Markdown

Luau has a type system which is used for both intellisense and in some cases native codegen instructions. This PR adds type annotations.

This omits adding return-type annotations to expandBuffer. This is because this function actually can't really be represented by Luau's type type at the moment -- I believe this is a bug with Luau, but I will check with the maintainers. Regardless though, it's internal facing only so I think it's fine to leave without type annotations at the moment.

@RiskoZS
Copy link
Copy Markdown
Owner

RiskoZS commented Aug 18, 2025

I can see Luau having a hard time with expandBuffer as that function's return signature is effectively something like (nil, string) | (buffer, number) and Luau simply has no way to annotate something like that (sounds more like a limitation of the type system than a bug to me). However, for consistency's sake, I would prefer to not keep the function's return value unannotated. Even Luau complains about it in strict mode.

Annotating the return type as (buffer?, any) seems to appease the linter and is probably good enough; could you please amend the PR to include that?

@RiskoZS
Copy link
Copy Markdown
Owner

RiskoZS commented Aug 18, 2025

It also looks like Luau needs a bit of help on line 71 with determining that acceleration is non-nil

Copy link
Copy Markdown
Owner

@RiskoZS RiskoZS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also looks like Luau needs a bit of help on line 71 with determining that acceleration is non-nil



local function expandBuffer(out, maxLen)
local function expandBuffer(out: buffer, maxLen: number)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotating the return type as (buffer?, any) seems to appease the linter and is probably good enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants