From 6b5723cdbef70841c8716de8fa557075ca68f3b3 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Thu, 7 Mar 2024 16:53:51 +0000 Subject: [PATCH] refactor(ast): shorten manual TS defs (#2638) Does the same thing, just (in my opinion) a little bit more readable. --- crates/oxc_ast/src/ast/js.rs | 7 ++----- crates/oxc_ast/src/ast/literal.rs | 7 ++----- crates/oxc_semantic/src/symbol.rs | 7 ++----- crates/oxc_span/src/atom.rs | 7 ++----- crates/oxc_syntax/src/node.rs | 7 ++----- crates/oxc_syntax/src/reference.rs | 7 ++----- crates/oxc_syntax/src/scope.rs | 7 ++----- crates/oxc_syntax/src/symbol.rs | 7 ++----- 8 files changed, 16 insertions(+), 40 deletions(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 8ed4bddf7..8bd786f79 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -14,11 +14,8 @@ use serde::Serialize; use super::{jsx::*, literal::*, ts::*}; -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export interface BindingIdentifier extends Span { type: "Identifier", name: Atom } export interface IdentifierReference extends Span { type: "Identifier", name: Atom } diff --git a/crates/oxc_ast/src/ast/literal.rs b/crates/oxc_ast/src/ast/literal.rs index 60af90a05..87a290279 100644 --- a/crates/oxc_ast/src/ast/literal.rs +++ b/crates/oxc_ast/src/ast/literal.rs @@ -163,11 +163,8 @@ bitflags! { } } -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type RegExpFlags = { G: 1, diff --git a/crates/oxc_semantic/src/symbol.rs b/crates/oxc_semantic/src/symbol.rs index 322a53a01..ef8edf11b 100644 --- a/crates/oxc_semantic/src/symbol.rs +++ b/crates/oxc_semantic/src/symbol.rs @@ -14,11 +14,8 @@ use crate::{ #[cfg(feature = "serde")] use serde::Serialize; -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type IndexVec = Array; "#; diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index 4cd2fdc0b..7124f8610 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -5,11 +5,8 @@ use serde::{Serialize, Serializer}; use compact_str::CompactString; -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type Atom = string; export type CompactStr = string; diff --git a/crates/oxc_syntax/src/node.rs b/crates/oxc_syntax/src/node.rs index c1c0e7204..e862fbfec 100644 --- a/crates/oxc_syntax/src/node.rs +++ b/crates/oxc_syntax/src/node.rs @@ -5,11 +5,8 @@ define_index_type! { pub struct AstNodeId = usize; } -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type AstNodeId = number; export type NodeFlags = { diff --git a/crates/oxc_syntax/src/reference.rs b/crates/oxc_syntax/src/reference.rs index 2649d11d3..5b6cf8825 100644 --- a/crates/oxc_syntax/src/reference.rs +++ b/crates/oxc_syntax/src/reference.rs @@ -7,11 +7,8 @@ define_index_type! { pub struct ReferenceId = u32; } -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type ReferenceId = number; export type ReferenceFlag = { diff --git a/crates/oxc_syntax/src/scope.rs b/crates/oxc_syntax/src/scope.rs index 03b2384ef..1b2506703 100644 --- a/crates/oxc_syntax/src/scope.rs +++ b/crates/oxc_syntax/src/scope.rs @@ -5,11 +5,8 @@ define_index_type! { pub struct ScopeId = u32; } -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type ScopeId = number; "#; diff --git a/crates/oxc_syntax/src/symbol.rs b/crates/oxc_syntax/src/symbol.rs index 45fd2f3c6..978ee43c3 100644 --- a/crates/oxc_syntax/src/symbol.rs +++ b/crates/oxc_syntax/src/symbol.rs @@ -8,11 +8,8 @@ define_index_type! { pub struct SymbolId = u32; } -#[cfg_attr( - all(feature = "serde", feature = "wasm"), - wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section) -)] -#[allow(dead_code)] +#[cfg(all(feature = "serde", feature = "wasm"))] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = r#" export type SymbolId = number; export type SymbolFlags = unknown;