fix(ast): properly serialize FormalParameter (#411)

This commit is contained in:
Boshen 2023-06-07 12:26:58 +08:00 committed by GitHub
parent 7c79fbc026
commit 86efc07188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View file

@ -1175,9 +1175,8 @@ pub struct DebuggerStatement {
/// Destructuring Binding Patterns
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
pub struct BindingPattern<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
pub kind: BindingPatternKind<'a>,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
pub optional: bool,
@ -1309,11 +1308,10 @@ pub struct FormalParameters<'a> {
}
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
pub struct FormalParameter<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
pub span: Span,
#[cfg_attr(feature = "serde", serde(flatten))]
pub pattern: BindingPattern<'a>,
pub accessibility: Option<TSAccessibility>,
pub readonly: bool,
@ -1321,7 +1319,7 @@ pub struct FormalParameter<'a> {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(untagged))]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub enum FormalParameterKind {
/// <https://tc39.es/ecma262/#prod-FormalParameters>
FormalParameter,

View file

@ -1382,17 +1382,16 @@ pub struct FormalParameters<'a> {
}
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
pub struct FormalParameter<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
pub span: Span,
#[cfg_attr(feature = "serde", serde(flatten))]
pub pattern: BindingPattern<'a>,
pub decorators: Vec<'a, Decorator<'a>>,
}
#[derive(Debug, Clone, Copy, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(untagged))]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub enum FormalParameterKind {
/// <https://tc39.es/ecma262/#prod-FormalParameters>
FormalParameter,