我刚刚遇到有人在 a piece of ES6 code 中使用“type” 。
export type Action =
{
type: 'todo/complete',
id: string,
} |
{
type: 'todo/create',
text: string,
} |
{
type: 'todo/destroy',
id: string,
} |
{
type: 'todo/destroy-completed',
} |
{
type: 'todo/toggle-complete-all',
} |
{
type: 'todo/undo-complete',
id: string,
} |
{
type: 'todo/update-text',
id: string,
text: string,
};
找不到任何可以阐明这一点的内容。是关键字吗?它到底有什么作用?
最佳答案
正如PitaJ所述,这里的 type
符号不是 ES6 或任何早期版本的 JavaScript 的一部分,而是 Flow static type checker 的一部分。 .
关于javascript - "type"是 JavaScript 中的关键字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33446498/