eNepper eNepper - 18 days ago 4
TypeScript Question

How to create enum like type in TypeScript?

I'm working on a definitions file for the Google maps API for TypeScript.
But I ran in to a small problem.

I'm trying 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

TypeScript 0.9+ has a specification for enums:

enum AnimationType {
    BOUNCE,
    DROP,
}

The final comma is optional.