Last active
September 11, 2025 09:41
-
-
Save finscn/fb1a48ed29610fa285a9c130fc9302e1 to your computer and use it in GitHub Desktop.
a simple type declaration file for `Tiled Map JSON` (.tmj).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'TiledMap' { | |
export namespace TMJ { | |
// cSpell:disable | |
export interface Map { | |
backgroundcolor?: string; | |
class?: string; | |
compressionlevel: number; | |
height: number; | |
hexsidelength?: number; // hexagonal maps only | |
infinite: boolean; | |
layers: Layer[]; | |
nextlayerid: number; | |
nextobjectid: number; | |
orientation: 'orthogonal' | 'isometric' | 'staggered' | 'hexagonal'; | |
parallaxoriginx: number; | |
parallaxoriginy: number; | |
properties: Property[]; | |
renderorder: 'right-down' | 'right-up' | 'left-down' | 'left-up'; | |
staggeraxis?: 'x' | 'y'; // staggered / hexagonal maps only | |
staggerindex?: 'odd' | 'even'; // staggered / hexagonal maps only | |
tiledversion: string; | |
tileheight: number; | |
tilesets: Tileset[]; | |
tilewidth: number; | |
type: 'map'; | |
version: string; | |
width: number; | |
} | |
export interface Layer { | |
chunks?: Chunk[]; // tilelayer only | |
class?: string; | |
compression?: 'zlib' | 'gzip' | 'zstd' | ''; // tilelayer only | |
data?: Uint32Array | number[] | string; // tilelayer only | |
draworder?: 'topdown' | 'index'; // objectgroup only | |
encoding?: 'csv' | 'base64'; // tilelayer only | |
height?: number; // tilelayer only | |
id: number; | |
image?: string; // imagelayer only | |
imageheight?: number; // imagelayer only | |
imagewidth?: number; // imagelayer only | |
layers?: Layer[]; // group only | |
locked: boolean; | |
name: string; | |
objects?: Object[]; // objectgroup only | |
offsetx: number; | |
offsety: number; | |
opacity: number; | |
parallaxx: number; | |
parallaxy: number; | |
properties: Property[]; | |
repeatx?: boolean; // imagelayer only | |
repeaty?: boolean; // imagelayer only | |
startx: number; | |
starty: number; | |
tintcolor?: string; | |
transparentcolor?: string; // imagelayer only | |
type: 'tilelayer' | 'objectgroup' | 'imagelayer' | 'group'; | |
visible: boolean; | |
width: number; // tilelayer only | |
x: number; | |
y: number; | |
} | |
export interface Chunk { | |
data: Uint32Array | number[] | string; | |
height: number; | |
width: number; | |
x: number; | |
y: number; | |
} | |
export interface Object { | |
ellipse: boolean; | |
gid: number; | |
height: number; | |
id: number; | |
name: string; | |
point: boolean; | |
polygon: Point[]; | |
polyline: Point[]; | |
properties: Property[]; | |
rotation: number; | |
template: string; | |
text?: Text; // text objects only | |
type?: string; | |
visible: boolean; | |
width: number; | |
x: number; | |
y: number; | |
} | |
export interface Text { | |
bold: boolean; | |
color: string; | |
fontfamily: string; | |
halign: 'center' | 'right' | 'justify' | 'left'; | |
italic: boolean; | |
kerning: boolean; | |
pixelsize: number; | |
strikeout: boolean; | |
text: string; | |
underline: boolean; | |
valign: 'center' | 'bottom' | 'top'; | |
wrap: boolean; | |
} | |
export interface Tileset { | |
backgroundcolor?: string; | |
class?: string; | |
columns: number; | |
fillmode: 'stretch' | 'preserve-aspect-fit'; | |
firstgid: number; | |
grid?: Grid; | |
image: string; | |
imageheight: number; | |
imagewidth: number; | |
margin: number; | |
name: string; | |
objectalignment: 'unspecified' | 'topleft' | 'top' | 'topright' | 'left' | 'center' | 'right' | 'bottomleft' | 'bottom' | 'bottomright'; | |
properties: Property[]; | |
source: string; | |
spacing: number; | |
terrains?: Terrain[]; | |
tilecount: number; | |
tiledversion: string; | |
tileheight: number; | |
tileoffset?: TileOffset; | |
tilerendersize: 'tile' | 'grid'; | |
tiles?: Tile[]; | |
tilewidth: number; | |
transformations?: Transformation; | |
transparentcolor?: string; | |
type: 'tileset'; | |
version: string; | |
wangsets: WangSet[]; | |
} | |
export interface Grid { | |
height: number; | |
orientation: 'orthogonal' | 'isometric'; | |
width: number; | |
} | |
export interface TileOffset { | |
x: number; | |
y: number; | |
} | |
export interface Transformation { | |
hflip: boolean; | |
vflip: boolean; | |
rotate: boolean; | |
preferuntransformed: boolean; | |
} | |
export interface Tile { | |
animation: Frame[]; | |
id: number; | |
image?: string; | |
imageheight: number; | |
imagewidth: number; | |
x: number; | |
y: number; | |
width: number; | |
height: number; | |
objectgroup?: Layer & { type: 'objectgroup' }; | |
probability?: number; | |
properties: Property[]; | |
terrain?: number[]; | |
type?: string; | |
} | |
export interface Frame { | |
duration: number; | |
tileid: number; | |
} | |
export interface Terrain { | |
name: string; | |
properties: Property[]; | |
tile: number; | |
} | |
export interface WangSet { | |
class?: string; | |
colors: string; | |
name: string; | |
properties: Property[]; | |
tile: number; | |
type: 'corner' | 'edge' | 'mixed'; | |
} | |
export interface WangColor { | |
class?: string; | |
color: string; | |
name: string; | |
probability: number; | |
properties: Property[]; | |
tile: number; | |
} | |
export interface WangTile { | |
tileid: number; | |
wangid: Uint8Array | number[]; | |
} | |
export interface ObjectTemplate { | |
type: 'template'; | |
tileset?: Tileset; | |
object: Object; | |
} | |
export interface Property { | |
name: string; | |
type: 'string' | 'int' | 'float' | 'bool' | 'color' | 'file' | 'object' | 'class'; | |
propertytype: string; | |
value: string | number | boolean | object; | |
} | |
export interface Point { | |
x: number; | |
y: number; | |
} | |
// cSpell:enable | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the
cSpell:....
is used to disable cSpell extention , because the cSpell will report many warings for the keys in these interfaces.