mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(ast): add explicit enum discriminants. (#4689)
Related to #4622 but doesn't close it.
This commit is contained in:
parent
75f22072be
commit
83b6ca93d9
4 changed files with 110 additions and 109 deletions
|
|
@ -365,9 +365,9 @@ pub struct ObjectExpression<'a> {
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum ObjectPropertyKind<'a> {
|
pub enum ObjectPropertyKind<'a> {
|
||||||
/// `a: 1` in `const obj = { a: 1 };`
|
/// `a: 1` in `const obj = { a: 1 };`
|
||||||
ObjectProperty(Box<'a, ObjectProperty<'a>>),
|
ObjectProperty(Box<'a, ObjectProperty<'a>>) = 0,
|
||||||
/// `...{ a: 1 }` in `const obj = { ...{ a: 1 } };`
|
/// `...{ a: 1 }` in `const obj = { ...{ a: 1 } };`
|
||||||
SpreadProperty(Box<'a, SpreadElement<'a>>),
|
SpreadProperty(Box<'a, SpreadElement<'a>>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `a: 1` in `const obj = { a: 1 };`
|
/// `a: 1` in `const obj = { a: 1 };`
|
||||||
|
|
@ -416,11 +416,11 @@ pub enum PropertyKey<'a> {
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum PropertyKind {
|
pub enum PropertyKind {
|
||||||
/// `a: 1` in `const obj = { a: 1 };`
|
/// `a: 1` in `const obj = { a: 1 };`
|
||||||
Init,
|
Init = 0,
|
||||||
/// `get a() { return 1; }` in `const obj = { get a() { return 1; } };`
|
/// `get a() { return 1; }` in `const obj = { get a() { return 1; } };`
|
||||||
Get,
|
Get = 1,
|
||||||
/// `set a(value) { this._a = value; }` in `const obj = { set a(value) { this._a = value; } };`
|
/// `set a(value) { this._a = value; }` in `const obj = { set a(value) { this._a = value; } };`
|
||||||
Set,
|
Set = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `` `Hello, ${name}` `` in `` const foo = `Hello, ${name}` ``
|
/// `` `Hello, ${name}` `` in `` const foo = `Hello, ${name}` ``
|
||||||
|
|
@ -935,8 +935,8 @@ pub struct AssignmentTargetWithDefault<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum AssignmentTargetProperty<'a> {
|
pub enum AssignmentTargetProperty<'a> {
|
||||||
AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>),
|
AssignmentTargetPropertyIdentifier(Box<'a, AssignmentTargetPropertyIdentifier<'a>>) = 0,
|
||||||
AssignmentTargetPropertyProperty(Box<'a, AssignmentTargetPropertyProperty<'a>>),
|
AssignmentTargetPropertyProperty(Box<'a, AssignmentTargetPropertyProperty<'a>>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `foo` in `({ foo } = obj);`
|
/// `foo` in `({ foo } = obj);`
|
||||||
|
|
@ -1186,9 +1186,9 @@ pub struct VariableDeclaration<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum VariableDeclarationKind {
|
pub enum VariableDeclarationKind {
|
||||||
Var,
|
Var = 0,
|
||||||
Const,
|
Const = 1,
|
||||||
Let,
|
Let = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -1522,16 +1522,16 @@ pub struct BindingPattern<'a> {
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum BindingPatternKind<'a> {
|
pub enum BindingPatternKind<'a> {
|
||||||
/// `const a = 1`
|
/// `const a = 1`
|
||||||
BindingIdentifier(Box<'a, BindingIdentifier<'a>>),
|
BindingIdentifier(Box<'a, BindingIdentifier<'a>>) = 0,
|
||||||
/// `const {a} = 1`
|
/// `const {a} = 1`
|
||||||
ObjectPattern(Box<'a, ObjectPattern<'a>>),
|
ObjectPattern(Box<'a, ObjectPattern<'a>>) = 1,
|
||||||
/// `const [a] = 1`
|
/// `const [a] = 1`
|
||||||
ArrayPattern(Box<'a, ArrayPattern<'a>>),
|
ArrayPattern(Box<'a, ArrayPattern<'a>>) = 2,
|
||||||
/// A defaulted binding pattern, i.e.:
|
/// A defaulted binding pattern, i.e.:
|
||||||
/// `const {a = 1} = 1`
|
/// `const {a = 1} = 1`
|
||||||
/// the assignment pattern is `a = 1`
|
/// the assignment pattern is `a = 1`
|
||||||
/// it has an inner left that has a BindingIdentifier
|
/// it has an inner left that has a BindingIdentifier
|
||||||
AssignmentPattern(Box<'a, AssignmentPattern<'a>>),
|
AssignmentPattern(Box<'a, AssignmentPattern<'a>>) = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -1641,11 +1641,11 @@ pub struct Function<'a> {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
pub enum FunctionType {
|
pub enum FunctionType {
|
||||||
FunctionDeclaration,
|
FunctionDeclaration = 0,
|
||||||
FunctionExpression,
|
FunctionExpression = 1,
|
||||||
TSDeclareFunction,
|
TSDeclareFunction = 2,
|
||||||
/// <https://github.com/typescript-eslint/typescript-eslint/pull/1289>
|
/// <https://github.com/typescript-eslint/typescript-eslint/pull/1289>
|
||||||
TSEmptyBodyFunctionExpression,
|
TSEmptyBodyFunctionExpression = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://tc39.es/ecma262/#prod-FormalParameters>
|
/// <https://tc39.es/ecma262/#prod-FormalParameters>
|
||||||
|
|
@ -1683,13 +1683,13 @@ pub struct FormalParameter<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
pub enum FormalParameterKind {
|
pub enum FormalParameterKind {
|
||||||
/// <https://tc39.es/ecma262/#prod-FormalParameters>
|
/// <https://tc39.es/ecma262/#prod-FormalParameters>
|
||||||
FormalParameter,
|
FormalParameter = 0,
|
||||||
/// <https://tc39.es/ecma262/#prod-UniqueFormalParameters>
|
/// <https://tc39.es/ecma262/#prod-UniqueFormalParameters>
|
||||||
UniqueFormalParameters,
|
UniqueFormalParameters = 1,
|
||||||
/// <https://tc39.es/ecma262/#prod-ArrowFormalParameters>
|
/// <https://tc39.es/ecma262/#prod-ArrowFormalParameters>
|
||||||
ArrowFormalParameters,
|
ArrowFormalParameters = 2,
|
||||||
/// Part of TypeScript type signatures
|
/// Part of TypeScript type signatures
|
||||||
Signature,
|
Signature = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://tc39.es/ecma262/#prod-FunctionBody>
|
/// <https://tc39.es/ecma262/#prod-FunctionBody>
|
||||||
|
|
@ -1819,13 +1819,13 @@ pub enum ClassType {
|
||||||
/// ```ts
|
/// ```ts
|
||||||
/// class Foo { }
|
/// class Foo { }
|
||||||
/// ```
|
/// ```
|
||||||
ClassDeclaration,
|
ClassDeclaration = 0,
|
||||||
/// Class expression
|
/// Class expression
|
||||||
///
|
///
|
||||||
/// ```ts
|
/// ```ts
|
||||||
/// const Foo = class {}
|
/// const Foo = class {}
|
||||||
/// ```
|
/// ```
|
||||||
ClassExpression,
|
ClassExpression = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -1861,13 +1861,13 @@ pub struct ClassBody<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum ClassElement<'a> {
|
pub enum ClassElement<'a> {
|
||||||
StaticBlock(Box<'a, StaticBlock<'a>>),
|
StaticBlock(Box<'a, StaticBlock<'a>>) = 0,
|
||||||
/// Class Methods
|
/// Class Methods
|
||||||
///
|
///
|
||||||
/// Includes static and non-static methods, constructors, getters, and setters.
|
/// Includes static and non-static methods, constructors, getters, and setters.
|
||||||
MethodDefinition(Box<'a, MethodDefinition<'a>>),
|
MethodDefinition(Box<'a, MethodDefinition<'a>>) = 1,
|
||||||
PropertyDefinition(Box<'a, PropertyDefinition<'a>>),
|
PropertyDefinition(Box<'a, PropertyDefinition<'a>>) = 2,
|
||||||
AccessorProperty(Box<'a, AccessorProperty<'a>>),
|
AccessorProperty(Box<'a, AccessorProperty<'a>>) = 3,
|
||||||
/// Index Signature
|
/// Index Signature
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
|
|
@ -1876,7 +1876,7 @@ pub enum ClassElement<'a> {
|
||||||
/// [keys: string]: string
|
/// [keys: string]: string
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
TSIndexSignature(Box<'a, TSIndexSignature<'a>>),
|
TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -1911,8 +1911,8 @@ pub struct MethodDefinition<'a> {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
pub enum MethodDefinitionType {
|
pub enum MethodDefinitionType {
|
||||||
MethodDefinition,
|
MethodDefinition = 0,
|
||||||
TSAbstractMethodDefinition,
|
TSAbstractMethodDefinition = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -2000,8 +2000,8 @@ pub struct PropertyDefinition<'a> {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
pub enum PropertyDefinitionType {
|
pub enum PropertyDefinitionType {
|
||||||
PropertyDefinition,
|
PropertyDefinition = 0,
|
||||||
TSAbstractPropertyDefinition,
|
TSAbstractPropertyDefinition = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast]
|
#[ast]
|
||||||
|
|
@ -2010,13 +2010,13 @@ pub enum PropertyDefinitionType {
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum MethodDefinitionKind {
|
pub enum MethodDefinitionKind {
|
||||||
/// Class constructor
|
/// Class constructor
|
||||||
Constructor,
|
Constructor = 0,
|
||||||
/// Static or instance method
|
/// Static or instance method
|
||||||
Method,
|
Method = 1,
|
||||||
/// Getter method
|
/// Getter method
|
||||||
Get,
|
Get = 2,
|
||||||
/// Setter method
|
/// Setter method
|
||||||
Set,
|
Set = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An identifier for a private class member.
|
/// An identifier for a private class member.
|
||||||
|
|
@ -2120,8 +2120,8 @@ pub use match_module_declaration;
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
pub enum AccessorPropertyType {
|
pub enum AccessorPropertyType {
|
||||||
AccessorProperty,
|
AccessorProperty = 0,
|
||||||
TSAbstractAccessorProperty,
|
TSAbstractAccessorProperty = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Class Accessor Property
|
/// Class Accessor Property
|
||||||
|
|
@ -2185,11 +2185,11 @@ pub struct ImportDeclaration<'a> {
|
||||||
pub enum ImportDeclarationSpecifier<'a> {
|
pub enum ImportDeclarationSpecifier<'a> {
|
||||||
/// import {imported} from "source"
|
/// import {imported} from "source"
|
||||||
/// import {imported as local} from "source"
|
/// import {imported as local} from "source"
|
||||||
ImportSpecifier(Box<'a, ImportSpecifier<'a>>),
|
ImportSpecifier(Box<'a, ImportSpecifier<'a>>) = 0,
|
||||||
/// import local from "source"
|
/// import local from "source"
|
||||||
ImportDefaultSpecifier(Box<'a, ImportDefaultSpecifier<'a>>),
|
ImportDefaultSpecifier(Box<'a, ImportDefaultSpecifier<'a>>) = 1,
|
||||||
/// import * as local from "source"
|
/// import * as local from "source"
|
||||||
ImportNamespaceSpecifier(Box<'a, ImportNamespaceSpecifier<'a>>),
|
ImportNamespaceSpecifier(Box<'a, ImportNamespaceSpecifier<'a>>) = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
// import {imported} from "source"
|
// import {imported} from "source"
|
||||||
|
|
@ -2278,8 +2278,8 @@ pub struct ImportAttribute<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum ImportAttributeKey<'a> {
|
pub enum ImportAttributeKey<'a> {
|
||||||
Identifier(IdentifierName<'a>),
|
Identifier(IdentifierName<'a>) = 0,
|
||||||
StringLiteral(StringLiteral<'a>),
|
StringLiteral(StringLiteral<'a>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Named Export Declaration
|
/// Named Export Declaration
|
||||||
|
|
@ -2410,8 +2410,8 @@ pub enum ExportDefaultDeclarationKind<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum ModuleExportName<'a> {
|
pub enum ModuleExportName<'a> {
|
||||||
IdentifierName(IdentifierName<'a>),
|
IdentifierName(IdentifierName<'a>) = 0,
|
||||||
/// For `local` in `ExportSpecifier`: `foo` in `export { foo }`
|
/// For `local` in `ExportSpecifier`: `foo` in `export { foo }`
|
||||||
IdentifierReference(IdentifierReference<'a>),
|
IdentifierReference(IdentifierReference<'a>) = 1,
|
||||||
StringLiteral(StringLiteral<'a>),
|
StringLiteral(StringLiteral<'a>) = 2,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,11 +145,11 @@ pub struct JSXClosingFragment {
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum JSXElementName<'a> {
|
pub enum JSXElementName<'a> {
|
||||||
/// `<Apple />`
|
/// `<Apple />`
|
||||||
Identifier(Box<'a, JSXIdentifier<'a>>),
|
Identifier(Box<'a, JSXIdentifier<'a>>) = 0,
|
||||||
/// `<Apple:Orange />`
|
/// `<Apple:Orange />`
|
||||||
NamespacedName(Box<'a, JSXNamespacedName<'a>>),
|
NamespacedName(Box<'a, JSXNamespacedName<'a>>) = 1,
|
||||||
/// `<Apple.Orange />`
|
/// `<Apple.Orange />`
|
||||||
MemberExpression(Box<'a, JSXMemberExpression<'a>>),
|
MemberExpression(Box<'a, JSXMemberExpression<'a>>) = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// JSX Namespaced Name
|
/// JSX Namespaced Name
|
||||||
|
|
@ -205,8 +205,8 @@ pub struct JSXMemberExpression<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum JSXMemberExpressionObject<'a> {
|
pub enum JSXMemberExpressionObject<'a> {
|
||||||
Identifier(Box<'a, JSXIdentifier<'a>>),
|
Identifier(Box<'a, JSXIdentifier<'a>>) = 0,
|
||||||
MemberExpression(Box<'a, JSXMemberExpression<'a>>),
|
MemberExpression(Box<'a, JSXMemberExpression<'a>>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// JSX Expression Container
|
/// JSX Expression Container
|
||||||
|
|
@ -268,8 +268,8 @@ pub struct JSXEmptyExpression {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum JSXAttributeItem<'a> {
|
pub enum JSXAttributeItem<'a> {
|
||||||
Attribute(Box<'a, JSXAttribute<'a>>),
|
Attribute(Box<'a, JSXAttribute<'a>>) = 0,
|
||||||
SpreadAttribute(Box<'a, JSXSpreadAttribute<'a>>),
|
SpreadAttribute(Box<'a, JSXSpreadAttribute<'a>>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// JSX Attribute
|
/// JSX Attribute
|
||||||
|
|
@ -315,8 +315,8 @@ pub struct JSXSpreadAttribute<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum JSXAttributeName<'a> {
|
pub enum JSXAttributeName<'a> {
|
||||||
Identifier(Box<'a, JSXIdentifier<'a>>),
|
Identifier(Box<'a, JSXIdentifier<'a>>) = 0,
|
||||||
NamespacedName(Box<'a, JSXNamespacedName<'a>>),
|
NamespacedName(Box<'a, JSXNamespacedName<'a>>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// JSX Attribute Value
|
/// JSX Attribute Value
|
||||||
|
|
@ -327,10 +327,10 @@ pub enum JSXAttributeName<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum JSXAttributeValue<'a> {
|
pub enum JSXAttributeValue<'a> {
|
||||||
StringLiteral(Box<'a, StringLiteral<'a>>),
|
StringLiteral(Box<'a, StringLiteral<'a>>) = 0,
|
||||||
ExpressionContainer(Box<'a, JSXExpressionContainer<'a>>),
|
ExpressionContainer(Box<'a, JSXExpressionContainer<'a>>) = 1,
|
||||||
Element(Box<'a, JSXElement<'a>>),
|
Element(Box<'a, JSXElement<'a>>) = 2,
|
||||||
Fragment(Box<'a, JSXFragment<'a>>),
|
Fragment(Box<'a, JSXFragment<'a>>) = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// JSX Identifier
|
/// JSX Identifier
|
||||||
|
|
@ -359,20 +359,15 @@ pub struct JSXIdentifier<'a> {
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum JSXChild<'a> {
|
pub enum JSXChild<'a> {
|
||||||
/// `<Foo>Some Text</Foo>`
|
/// `<Foo>Some Text</Foo>`
|
||||||
Text(Box<'a, JSXText<'a>>),
|
Text(Box<'a, JSXText<'a>>) = 0,
|
||||||
/// `<Foo><Child /></Foo>`
|
/// `<Foo><Child /></Foo>`
|
||||||
Element(Box<'a, JSXElement<'a>>),
|
Element(Box<'a, JSXElement<'a>>) = 1,
|
||||||
/// `<Foo><></></Foo>`
|
/// `<Foo><></></Foo>`
|
||||||
Fragment(Box<'a, JSXFragment<'a>>),
|
Fragment(Box<'a, JSXFragment<'a>>) = 2,
|
||||||
/// `<Foo>{expression}</Foo>`
|
/// `<Foo>{expression}</Foo>`
|
||||||
ExpressionContainer(Box<'a, JSXExpressionContainer<'a>>),
|
ExpressionContainer(Box<'a, JSXExpressionContainer<'a>>) = 3,
|
||||||
/// `<Foo>{...spread}</Foo>`
|
/// `<Foo>{...spread}</Foo>`
|
||||||
Spread(Box<'a, JSXSpreadChild<'a>>),
|
Spread(Box<'a, JSXSpreadChild<'a>>) = 4,
|
||||||
}
|
|
||||||
impl<'a> JSXChild<'a> {
|
|
||||||
pub const fn is_expression_container(&self) -> bool {
|
|
||||||
matches!(self, Self::ExpressionContainer(_))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// JSX Spread Child.
|
/// JSX Spread Child.
|
||||||
|
|
|
||||||
|
|
@ -175,14 +175,14 @@ pub struct TSLiteralType<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged, rename_all = "camelCase")]
|
#[serde(untagged, rename_all = "camelCase")]
|
||||||
pub enum TSLiteral<'a> {
|
pub enum TSLiteral<'a> {
|
||||||
BooleanLiteral(Box<'a, BooleanLiteral>),
|
BooleanLiteral(Box<'a, BooleanLiteral>) = 0,
|
||||||
NullLiteral(Box<'a, NullLiteral>),
|
NullLiteral(Box<'a, NullLiteral>) = 1,
|
||||||
NumericLiteral(Box<'a, NumericLiteral<'a>>),
|
NumericLiteral(Box<'a, NumericLiteral<'a>>) = 2,
|
||||||
BigIntLiteral(Box<'a, BigIntLiteral<'a>>),
|
BigIntLiteral(Box<'a, BigIntLiteral<'a>>) = 3,
|
||||||
RegExpLiteral(Box<'a, RegExpLiteral<'a>>),
|
RegExpLiteral(Box<'a, RegExpLiteral<'a>>) = 4,
|
||||||
StringLiteral(Box<'a, StringLiteral<'a>>),
|
StringLiteral(Box<'a, StringLiteral<'a>>) = 5,
|
||||||
TemplateLiteral(Box<'a, TemplateLiteral<'a>>),
|
TemplateLiteral(Box<'a, TemplateLiteral<'a>>) = 6,
|
||||||
UnaryExpression(Box<'a, UnaryExpression<'a>>),
|
UnaryExpression(Box<'a, UnaryExpression<'a>>) = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TypeScript Type
|
/// TypeScript Type
|
||||||
|
|
@ -373,9 +373,9 @@ pub struct TSTypeOperator<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum TSTypeOperatorOperator {
|
pub enum TSTypeOperatorOperator {
|
||||||
Keyof,
|
Keyof = 0,
|
||||||
Unique,
|
Unique = 1,
|
||||||
Readonly,
|
Readonly = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TypeScript Array Type
|
/// TypeScript Array Type
|
||||||
|
|
@ -723,9 +723,9 @@ pub struct TSTypeAliasDeclaration<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum TSAccessibility {
|
pub enum TSAccessibility {
|
||||||
Private,
|
Private = 0,
|
||||||
Protected,
|
Protected = 1,
|
||||||
Public,
|
Public = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -789,11 +789,11 @@ pub struct TSPropertySignature<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged, rename_all = "camelCase")]
|
#[serde(untagged, rename_all = "camelCase")]
|
||||||
pub enum TSSignature<'a> {
|
pub enum TSSignature<'a> {
|
||||||
TSIndexSignature(Box<'a, TSIndexSignature<'a>>),
|
TSIndexSignature(Box<'a, TSIndexSignature<'a>>) = 0,
|
||||||
TSPropertySignature(Box<'a, TSPropertySignature<'a>>),
|
TSPropertySignature(Box<'a, TSPropertySignature<'a>>) = 1,
|
||||||
TSCallSignatureDeclaration(Box<'a, TSCallSignatureDeclaration<'a>>),
|
TSCallSignatureDeclaration(Box<'a, TSCallSignatureDeclaration<'a>>) = 2,
|
||||||
TSConstructSignatureDeclaration(Box<'a, TSConstructSignatureDeclaration<'a>>),
|
TSConstructSignatureDeclaration(Box<'a, TSConstructSignatureDeclaration<'a>>) = 3,
|
||||||
TSMethodSignature(Box<'a, TSMethodSignature<'a>>),
|
TSMethodSignature(Box<'a, TSMethodSignature<'a>>) = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An index signature within a class, type alias, etc.
|
/// An index signature within a class, type alias, etc.
|
||||||
|
|
@ -837,9 +837,9 @@ pub struct TSCallSignatureDeclaration<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum TSMethodSignatureKind {
|
pub enum TSMethodSignatureKind {
|
||||||
Method,
|
Method = 0,
|
||||||
Get,
|
Get = 1,
|
||||||
Set,
|
Set = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -914,8 +914,8 @@ pub struct TSTypePredicate<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged, rename_all = "camelCase")]
|
#[serde(untagged, rename_all = "camelCase")]
|
||||||
pub enum TSTypePredicateName<'a> {
|
pub enum TSTypePredicateName<'a> {
|
||||||
Identifier(Box<'a, IdentifierName<'a>>),
|
Identifier(Box<'a, IdentifierName<'a>>) = 0,
|
||||||
This(TSThisType),
|
This(TSThisType) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -951,9 +951,9 @@ pub struct TSModuleDeclaration<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum TSModuleDeclarationKind {
|
pub enum TSModuleDeclarationKind {
|
||||||
Global,
|
Global = 0,
|
||||||
Module,
|
Module = 1,
|
||||||
Namespace,
|
Namespace = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TSModuleDeclarationKind {
|
impl TSModuleDeclarationKind {
|
||||||
|
|
@ -967,8 +967,8 @@ impl TSModuleDeclarationKind {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum TSModuleDeclarationName<'a> {
|
pub enum TSModuleDeclarationName<'a> {
|
||||||
Identifier(IdentifierName<'a>),
|
Identifier(IdentifierName<'a>) = 0,
|
||||||
StringLiteral(StringLiteral<'a>),
|
StringLiteral(StringLiteral<'a>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -976,8 +976,8 @@ pub enum TSModuleDeclarationName<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum TSModuleDeclarationBody<'a> {
|
pub enum TSModuleDeclarationBody<'a> {
|
||||||
TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>),
|
TSModuleDeclaration(Box<'a, TSModuleDeclaration<'a>>) = 0,
|
||||||
TSModuleBlock(Box<'a, TSModuleBlock<'a>>),
|
TSModuleBlock(Box<'a, TSModuleBlock<'a>>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// See serializer in serialize.rs
|
// See serializer in serialize.rs
|
||||||
|
|
@ -1082,8 +1082,8 @@ pub struct TSImportAttribute<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum TSImportAttributeName<'a> {
|
pub enum TSImportAttributeName<'a> {
|
||||||
Identifier(IdentifierName<'a>),
|
Identifier(IdentifierName<'a>) = 0,
|
||||||
StringLiteral(StringLiteral<'a>),
|
StringLiteral(StringLiteral<'a>) = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -1133,12 +1133,12 @@ pub struct TSMappedType<'a> {
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum TSMappedTypeModifierOperator {
|
pub enum TSMappedTypeModifierOperator {
|
||||||
True,
|
True = 0,
|
||||||
#[serde(rename = "+")]
|
#[serde(rename = "+")]
|
||||||
Plus,
|
Plus = 1,
|
||||||
#[serde(rename = "-")]
|
#[serde(rename = "-")]
|
||||||
Minus,
|
Minus = 2,
|
||||||
None,
|
None = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ast(visit)]
|
#[ast(visit)]
|
||||||
|
|
@ -1312,9 +1312,9 @@ pub struct TSInstantiationExpression<'a> {
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum ImportOrExportKind {
|
pub enum ImportOrExportKind {
|
||||||
/// `import { foo } from './foo'`;
|
/// `import { foo } from './foo'`;
|
||||||
Value,
|
Value = 0,
|
||||||
/// `import type { foo } from './foo'`;
|
/// `import type { foo } from './foo'`;
|
||||||
Type,
|
Type = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// [`JSDoc`](https://github.com/microsoft/TypeScript/blob/54a554d8af2657630307cbfa8a3e4f3946e36507/src/compiler/types.ts#L393)
|
// [`JSDoc`](https://github.com/microsoft/TypeScript/blob/54a554d8af2657630307cbfa8a3e4f3946e36507/src/compiler/types.ts#L393)
|
||||||
|
|
|
||||||
|
|
@ -95,3 +95,9 @@ impl<'a> JSXAttribute<'a> {
|
||||||
self.is_identifier("key")
|
self.is_identifier("key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> JSXChild<'a> {
|
||||||
|
pub const fn is_expression_container(&self) -> bool {
|
||||||
|
matches!(self, Self::ExpressionContainer(_))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue