#Is there any way I can make these two types related?

1 messages · Page 1 of 1 (latest)

wooden trench
#
local EntityModule = {} 
EntityModule.__index = EntityModule

export type Entity = typeof(setmetatable({} :: {
    AbilityModules:{Instance}?, Module:ModuleScript, Model:Model
}, EntityModule))


local KillerBase = setmetatable({}, EntityModule)
KillerBase.__index = KillerBase

export type Killer = typeof(setmetatable({} :: {
    AttackCD:number, ChaseTheme:{Sound}, AttackActiveWindow:{number},
}, KillerBase))

Killer is supposed to inherit from Entity but idk how to do that and make it play nice with the typechecker

#

the typechecker just dosent rlly like to play nice with metatables i've noticed

drifting mica
#

type king

wooden trench
#

NEVERMIND I (KINDA) FIGURED IT OUT

#
local EntityModule = {} 
export type Entity = typeof(setmetatable({} :: {
    AbilityModules:{Instance}?, Module:ModuleScript, Model:Model
}, {__index = EntityModule}))


local KillerBase = setmetatable({}, {__index = EntityModule})
export type Killer = typeof(setmetatable({} :: {
    AttackCD:number, ChaseTheme:{Sound}, AttackActiveWindow:{number},
}, {__index = KillerBase}))
#

You just make a new table for the metatable and have __index point to the base class