Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strong typings #637

Merged
merged 2 commits into from
Dec 19, 2022
Merged

Add strong typings #637

merged 2 commits into from
Dec 19, 2022

Conversation

khrj
Copy link
Member

@khrj khrj commented Dec 16, 2022

This PR adds a global.d.ts file that can be used when developing a Sprig game using TypeScript.
I've covered all of the methods available in the documentation, but perhaps there are some I'm not aware of.
Even though keys, bitmaps, maps, colors and tunes are still strings, I'm using branded types to differenciate them

  • Level Design
    • setLegend
    • setBackground
    • setMap
    • setSolids
    • setPushables
    • width
    • height
  • User Input
    • onInput
    • afterInput
  • Sprites and Tiles
    • getTile
    • tilesWith
    • addSprite
    • getAll
    • getFirst
    • Sprite.remove
  • Text
    • addText
    • clearText
  • Music
    • playTune
    • Playback.end
  • Debugging
    • getState
  • Tagged Template Literals
    • bitmap
    • map
    • color
    • tune

@vercel
Copy link

vercel bot commented Dec 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
sprig ✅ Ready (Inspect) Visit Preview Dec 16, 2022 at 2:24PM (UTC)

Setters for _type, _x, _y exist, dx and dy seem like they shouldn't be accessible. Add chainable remove method on sprite
@leomcelroy
Copy link
Collaborator

Thanks for doing this! Some people have actually requested it.

@LucasHT22
Copy link
Member

@khrj @leomcelroy Sorry, but how would saving files work if they are all saved in .js by default?

@khrj
Copy link
Member Author

khrj commented Dec 20, 2022

@khrj @leomcelroy Sorry, but how would saving files work if they are all saved in .js by default?

This isn't meant to work with the web editor, you can write code locally and then compile it to js to run it on the editor. So the .d.ts file doesn't interface with the editor at all

@LucasHT22
Copy link
Member

ok! thanks.

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.

3 participants