Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
Types for things likeClassProperty
/MethodDefinition
/Property
, etc are pretty ugly.
If the property name is computed, then anyExpression
is valid, otherwise onlyIdentifier | Literal
is valid.
However we don't represent this in the types, we just have a single object withkey: Expression
.
It'll be a bit of extra work, but we can improve upon this by doing something like:
typePropertyNameNonComputed=Identifier|Literal;typePropertyNameComputed=Expression;interfaceClassPropertyBaseextendsBaseNode{type:AST_NODE_TYPES.ClassProperty;key:PropertyNameNonComputed|PropertyNameComputed;computed:boolean;// ... other props}interfaceClassPropertyNonComputedKeyextendsClassPropertyBase{key:PropertyNameNonComputed;computed:false;}interfaceClassPropertyComputedKeyextendsClassPropertyBase{key:PropertyNameComputed;computed:true;}typeClassProperty=ClassPropertyNonComputedKey|ClassPropertyComputedKey;
Nodes we should do this for:
ClassProperty
TSAbstractClassProperty
MethodDefinition
TSAbstractMethodDefinition
Property
TSPropertySignature
TSMethodSignature
MemberExpression
OptionalMemberExpression