ExpandResult

Struct ExpandResult 

Source
pub struct ExpandResult {
    pub code: String,
    pub types: Option<String>,
    pub metadata: Option<String>,
    pub diagnostics: Vec<MacroDiagnostic>,
    pub source_mapping: Option<SourceMappingResult>,
}
Expand description

Result of expanding macros in TypeScript source code.

This is the primary return type for macro expansion operations, containing the expanded code, diagnostics, and source mapping.

§Example

use macroforge_ts::{ExpandResult, MacroDiagnostic};

// Create an ExpandResult programmatically
let result = ExpandResult {
    code: "class User {}".to_string(),
    types: None,
    metadata: None,
    diagnostics: vec![],
    source_mapping: None,
};

// Check for errors
if result.diagnostics.iter().any(|d| d.level == "error") {
    // Handle errors
}

Fields§

§code: String

The expanded TypeScript code with all macros processed.

§types: Option<String>

Optional TypeScript type declarations for generated methods.

§metadata: Option<String>

Optional JSON metadata about processed classes.

§diagnostics: Vec<MacroDiagnostic>

Diagnostics (errors, warnings, info) from the expansion process.

§source_mapping: Option<SourceMappingResult>

Source mapping for position translation between original and expanded code.

Implementations§

Source§

impl ExpandResult

Source

pub fn unchanged(code: &str) -> Self

Creates a no-op result with the original code unchanged.

Used for early bailout when no macros need processing, avoiding unnecessary parsing and expansion overhead.

§Arguments
  • code - The original source code to return unchanged
§Returns

An ExpandResult with:

  • code set to the input
  • All other fields empty/None
  • No source mapping (identity mapping implied)

Trait Implementations§

Source§

impl Clone for ExpandResult

Source§

fn clone(&self) -> ExpandResult

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl FromNapiValue for ExpandResult

Source§

unsafe fn from_napi_value( env: napi_env, napi_val: napi_value, ) -> Result<ExpandResult>

Safety Read more
Source§

fn from_unknown(value: Unknown<'_>) -> Result<Self, Error>

Source§

impl ToNapiValue for ExpandResult

Source§

impl TypeName for ExpandResult

Source§

impl ValidateNapiValue for ExpandResult

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> ImplicitClone for T
where T: Clone,

Source§

fn clone_quote_var(&self) -> Self

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> JsValuesTupleIntoVec for T
where T: ToNapiValue,

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Send for T
where T: ?Sized,

Source§

impl<T> Sync for T
where T: ?Sized,