Skip to content

Can't use implements as an object key #829

@sebmck

Description

@sebmck

Not sure if it's related to just a library file but I'm currently unable to use reserved words as property names. I have the following declare class:

declare class BabelNodeClassDeclaration extends BabelNode {
  type: "ClassDeclaration";
  id: BabelNodeIdentifier;
  body: BabelNodeClassBody;
  superClass?: void | BabelNodeExpression;
  decorators: any;
  typeParameters: any;
  superTypeParameters: any;
  implements: any;
}

Note the implements property name. This causes the parser to fail with:

[LIB] types.js:365:3,12: Library parse error:
[LIB] types.js:365:3,12: Use of future reserved word in strict mode

However if I wrap implements in quotes like:

"implements": any;

then I get a different error, this time not from the parser of:

[LIB] types.js:522:3,11: Library type error:
[LIB] types.js:522:3,11:
illegal name

Is there anyway around this? I'm unable to change the name of that property and need to annotate it.

Any help is appreciated, thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions