Skip to content

Commit

Permalink
Fix few serialization issues (oxc-project#2506)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre authored and IWANABETHATGUY committed May 29, 2024
1 parent b4719ec commit 9ad8f89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl<'a> TemplateLiteral<'a> {
}

#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
pub struct TaggedTemplateExpression<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
Expand Down Expand Up @@ -780,7 +780,7 @@ impl<'a> CallExpression<'a> {

/// New Expression
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
pub struct NewExpression<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
Expand Down Expand Up @@ -1849,6 +1849,7 @@ impl<'a> FunctionBody<'a> {
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
pub struct ArrowFunctionExpression<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
pub span: Span,
/// Is the function body an arrow expression? i.e. `() => expr` instead of `() => {}`
pub expression: bool,
Expand Down
9 changes: 5 additions & 4 deletions crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct TSEnumDeclaration<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
pub span: Span,
pub id: BindingIdentifier,
#[cfg_attr(feature = "serde", serde(flatten))]
pub body: TSEnumBody<'a>,
/// Valid Modifiers: `const`, `export`, `declare`
pub modifiers: Modifiers<'a>,
Expand All @@ -49,10 +50,10 @@ pub struct TSEnumDeclaration<'a> {
///
/// A scope must be created on the enum body so this abstraction exists
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
pub struct TSEnumBody<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub span: Span,
pub members: Vec<'a, TSEnumMember<'a>>,
}
Expand Down Expand Up @@ -203,7 +204,7 @@ pub struct TSIntersectionType<'a> {
///
/// <https://www.typescriptlang.org/docs/handbook/2/keyof-types.html>
#[derive(Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type"))]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
pub struct TSTypeOperator<'a> {
#[cfg_attr(feature = "serde", serde(flatten))]
Expand Down Expand Up @@ -1058,7 +1059,7 @@ pub struct TSInstantiationExpression<'a> {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize), serde(tag = "type", rename_all = "camelCase"))]
#[cfg_attr(feature = "serde", derive(Serialize), serde(rename_all = "camelCase"))]
#[cfg_attr(all(feature = "serde", feature = "wasm"), derive(tsify::Tsify))]
pub enum ImportOrExportKind {
Value,
Expand Down
2 changes: 1 addition & 1 deletion napi/parser/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface ParseResult {
}
export interface Comment {
type: string
value: string
value: 'Line' | 'Block'
start: number
end: number
}
Expand Down
1 change: 1 addition & 0 deletions napi/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct ParseResult {
#[napi(object)]
pub struct Comment {
pub r#type: &'static str,
#[napi(ts_type = "'Line' | 'Block'")]
pub value: String,
pub start: u32,
pub end: u32,
Expand Down

0 comments on commit 9ad8f89

Please sign in to comment.