It'd be nice if the chained form of class creation in the sdk docs example returned a reference to the class.
.extends(Parent) does not return anything. It'd be sweet if at the end of
Object.lua you could add a
return Child. I've patched my locally copy to do this.
Then I can:
MySprite = class("MySprite").extends("playdate.graphics.sprite")
It would also make private classes a one liner:
local MySprite = class("MySprite", nil, nil).extends("playdate.graphics.sprite")
I came up with a silly one liner partial workaround. Use:
MySprite = class('MySprite').extends(playdate.graphics.sprite) or MySprite
The latter operates implicitly by injecting
A into the global namespace.
The former includes an explicit global assignment.
It's an awkward no-op, but it's enough for static analysis tools to keep track of where MySprite gets created.
Relatedly, I improved
playdate-luacats to have proper type annotations for the APIs provided by object.lua. See: notpeter/playdate-luacats - v2.1.0-luacats7.