Skip to content

declare LuaThread and LuaUserdata as interfaces - #89

Open
king8fisher wants to merge 1 commit into
TypeScriptToLua:masterfrom
king8fisher:interface-thread-userdata
Open

king8fisher wants to merge 1 commit into
TypeScriptToLua:masterfrom
king8fisher:interface-thread-userdata

Conversation

@king8fisher

Copy link
Copy Markdown

Closes #88

This changes LuaThread and LuaUserdata from type aliases to interfaces, in both core/global.d.ts and core/5.0/global.d.ts, so they can be extended with declaration merging.

I added a test to test/global.spec.ts that adds a property to both types. Without the change it fails with "Duplicate identifier".

One thing to be aware of: a type alias of an object literal gets an implicit index signature, and an interface doesn't. So a thread or userdata can no longer be passed where a type with a string index signature is expected, like Record<string, unknown> or { [key: string]: symbol }. Record<string, any> and object still accept them. Since neither one is a table I think that's fine, but code that relied on it would need a cast.

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.

Declare LuaThread and LuaUserdata as interfaces so they can be extended

1 participant