Skip to content

jon-bell/tiled-map-type-guard

 
 

Repository files navigation

Tiled map type guards

Github Actions codecov

When working with Tiled maps, it can be useful to have property defined types in Typescript.

This package contains a set of interfaces that map the Tiled map JSON format.

Moreover, this package comes with Zod type guards that will allow you to actually check that the JSON file ou are reading is actually a well-formed Tiled map.

Available interfaces:

  • ITiledMap
  • ITiledMapLayer
    • ITiledMapGroupLayer
    • ITiledMapImageLayer
    • ITiledMapObjectLayer
      • ITiledMapObject
        • ITiledMapText
        • ITiledMapPoint
    • ITiledMapTileLayer
  • ITiledMapTileset
    • ITiledMapTile
      • ITiledMapWangColor
      • ITiledMapWangSet
      • ITiledMapWangTile
  • ITiledMapChunk
  • ITiledMapFrame
  • ITiledMapGrid
  • ITiledMapOffset
  • ITiledMapProperty
  • ITiledMapTerrain
  • ITiledMapTransformations

Usage:

// This will throw an error if "data" is not matching the type ITiledMap
const map: ITiledMap = ITiledMap.parse(data);

About

A Typescript package containing types for loading a Tiled JSON map, along appropriate type guards

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.2%
  • JavaScript 2.8%