shared types prototyping

metatables
This commit is contained in:
2023-12-26 00:30:57 -05:00
parent d1f9efce89
commit fbc72eb8cb

View File

@@ -0,0 +1,11 @@
-- type AccountImpl = {
-- __index: AccountImpl,
-- new: (name: string, balance: number) -> Account,
-- deposit: (self: Account, credit: number) -> (),
-- withdraw: (self: Account, debit: number) -> (),
-- }
-- type Account = typeof(setmetatable({} :: { name: string, balance: number }, {} :: AccountImpl))
type hself<T,U> = {__index: T} & U
export type constructor<T,U> = typeof(setmetatable({} :: T & hself<T,U>, {} :: U))