如何在TypeScript中创建类似类型的枚举? [英] How to create enum like type in TypeScript?

查看:142
本文介绍了如何在TypeScript中创建类似类型的枚举?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为TypeScript的Google maps API定义文件。

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

我需要定义类似的枚举例如。 google.maps.Animation 其中包含两个属性: BOUNCE DROP

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

如何在TypeScript中完成?

How should this be done in TypeScript?

推荐答案

TypeScript 0.9+具有枚举规范:

TypeScript 0.9+ has a specification for enums:

enum AnimationType {
    BOUNCE,
    DROP,
}

最后一个逗号是可选的。

The final comma is optional.

这篇关于如何在TypeScript中创建类似类型的枚举?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆