Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(span): reduce #[cfg_attr] boilerplate in type defs #4702

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/oxc_span/src/source_type/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ::{serde::Serialize, tsify::Tsify};
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
#[serde(rename_all = "camelCase")]
pub struct SourceType {
/// JavaScript or TypeScript, default JavaScript
pub(super) language: Language,
Expand All @@ -26,19 +26,19 @@ pub struct SourceType {
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(rename_all = "lowercase"))]
#[serde(rename_all = "lowercase")]
pub enum Language {
JavaScript = 0,
TypeScript = 1,
#[cfg_attr(feature = "serialize", serde(rename = "typescriptDefinition"))]
#[serde(rename = "typescriptDefinition")]
TypeScriptDefinition = 2,
}

/// Script or Module
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
#[serde(rename_all = "camelCase")]
pub enum ModuleKind {
Script = 0,
Module = 1,
Expand All @@ -48,7 +48,7 @@ pub enum ModuleKind {
#[ast]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
#[serde(rename_all = "camelCase")]
pub enum LanguageVariant {
Standard = 0,
Jsx = 1,
Expand Down
4 changes: 1 addition & 3 deletions crates/oxc_span/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use std::{

use miette::{LabeledSpan, SourceOffset, SourceSpan};
#[cfg(feature = "serialize")]
use serde::Serialize;
#[cfg(feature = "serialize")]
use tsify::Tsify;
use ::{serde::Serialize, tsify::Tsify};

/// An Empty span useful for creating AST nodes.
pub const SPAN: Span = Span::new(0, 0);
Expand Down