How to create enum like type in TypeScript?

eNepper picture eNepper · Oct 2, 2012 · Viewed 111.2k times · Source

I'm working on a definitions file for the Google maps API for TypeScript.

And I need to define an enum like type eg. google.maps.Animation which contains two properties: BOUNCE and DROP.

How should this be done in TypeScript?

Answer

Steve Lucco picture Steve Lucco · Oct 2, 2012

TypeScript 0.9+ has a specification for enums:

enum AnimationType {
    BOUNCE,
    DROP,
}

The final comma is optional.