Playdate SDK with TypeScript

@Andy Checking in on your reply in Discord that you had some updates to the plugin and types to share. I would love to take a look at those. Perhaps setting up a public repo so others can contribute as well?

Thanks for the reminder!

Here's updated types and the plugin. I don't remember exactly what changed in the plugin, I think it was fixes for super() calls in constructors.

A public repo would be great, I'll look into getting that set up. (17.5 KB)

1 Like

hey @andy, has the repo ever been created? I'd love to play around with this and potentially contribute.

I haven't, no. I'll zip up my latest types and plugin here again, since I've made some changes while developing a game with TypeScript over the past few months :slight_smile:

There's not a great way to bundle this up in a package, so I've just put it in an example project like before.

The same shortcomings still exist:

Arguments to subclasses' constructors always get passed into the super() call. So a class like:

class Sprite extends {
  constructor(x: number, y: number) {
    this.x = x;
    this.y = y;

will incorrectly transpile to Lua that calls Sprite.super.init(self, x, y).

Default class exports don't work. so rather than doing

export default class Sprite extends {}

you need to define

class Sprite extends {}

and then export as

export default Sprite;

If you'd like to put this up anywhere, feel free to!

tstlexport (27.8 KB)

Thanks, I'll have a look at it this week!
(And also check why the previous one barked about missing lua files, despite paths being correct, but I'll reply here again if it happens again)

1 Like