# Custom types from JavaScript

**URL:** <https://discourse.mapeditor.org/t/custom-types-from-javascript/6234>\
**Category:** Questions\
**Created:** [June 26, 2023, 4:22pm UTC](https://discourse.mapeditor.org/t/custom-types-from-javascript/6234 "2023-06-26T16:22:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Morris](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ben_morris/32/2159_2.png) [@Ben\_Morris](https://discourse.mapeditor.org/u/Ben_Morris)\
**Post date:** [June 26, 2023, 4:22pm UTC](https://discourse.mapeditor.org/t/custom-types-from-javascript/6234/1 "2023-06-26T16:22:29Z")

</div>

I have a custom map format exported via a JS plugin, and I’m trying to take advantage of custom types so I can do more editing directly in Tiled.

Currently when I access a property that holds an enum value, I get an object with typeId, typeName, and value. I want to get the string value of the enum, but I can’t find a way to do that yet. “value” is numeric, while I would’ve expected it to be the string value of the enum because I chose “Save as String” under the enum definition.

What does “typeId” map to? Is there somewhere that I can access the enum members or info about the type?

---

<div class="post-metadata">

**Author:** ![eishiya](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/eishiya/32/2534_2.png) [@eishiya](https://discourse.mapeditor.org/u/eishiya)\
**Post date:** [June 26, 2023, 4:35pm UTC](https://discourse.mapeditor.org/t/custom-types-from-javascript/6234/2 "2023-06-26T16:35:36Z")

</div>

It is not currently possible\* to get information about custom types via scripts, as there’s no API for custom types. This is a planned feature.

\* it’s technically possible if you parse the user’s .tiled-project file yourself, but then you’ll have to be very careful to watch for changes to this file.

---

<div class="post-metadata">

**Author:** ![Ben\_Morris](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ben_morris/32/2159_2.png) [@Ben\_Morris](https://discourse.mapeditor.org/u/Ben_Morris)\
**Post date:** [June 26, 2023, 7:30pm UTC](https://discourse.mapeditor.org/t/custom-types-from-javascript/6234/3 "2023-06-26T19:30:18Z")

</div>

It’ll be nice to have an API for this but in the meantime I just realized I can export a JSON file describing the types, and `typeId` corresponds to those. That’s good enough for me.
