I just came across somebody using "type" in a piece of ES6 code.
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,
};
Couldn't find anything that sheds light on it. Is it a keyword? What does it exactly do?
As mentioned by PitaJ, the type
symbol here is not part of ES6 or any earlier version of JavaScript, but rather part of the Flow static type checker.
Here are the docs for the type
symbol.
As far as I know, the ES6 spec does not list it as a reserved keyword.
The following tokens are ECMAScript keywords and may not be used as Identifiers in ECMAScript programs.
break do in typeof case else instanceof var catch export new void class extends return while const finally super with continue for switch yield debugger function this default if throw delete import try
You can disable it
export interface Body {
a: string
b: string
c: string
// tslint:disable-next-line:no-reserved-keywords
type: string
f: string
e: string
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With