diff --git a/src/legacy/resolver.rs b/src/legacy/resolver.rs index c54ff0b5..145dc4a1 100644 --- a/src/legacy/resolver.rs +++ b/src/legacy/resolver.rs @@ -119,8 +119,8 @@ where } pub fn typedef(defs: &mut TypeMap) -> ProcedureDataType { - let mut type_map = TypeMap::default(); - let arg_ty = TArg::reference(&mut type_map, &[]).inner; - let result_ty = TResult::reference(&mut type_map, &[]).inner; + let arg_ty = TArg::reference(defs, &[]).inner; + let result_ty = TResult::reference(defs, &[]).inner; + ProcedureDataType { arg_ty, result_ty } } diff --git a/src/legacy/router.rs b/src/legacy/router.rs index 321bcfde..cebf50a7 100644 --- a/src/legacy/router.rs +++ b/src/legacy/router.rs @@ -11,7 +11,7 @@ use std::{ use futures::Stream; use serde_json::Value; use specta::{datatype::FunctionResultVariant, DataType, TypeMap}; -use specta_typescript::{self as ts, datatype, Typescript}; +use specta_typescript::{self as ts, datatype, export_named_datatype, Typescript}; use crate::{ internal::{Procedure, ProcedureKind, ProcedureStore, RequestContext, ValueOrStream}, @@ -161,14 +161,12 @@ export type Procedures = {{ }};"# )?; - for export in self.type_map.iter().map(|(_, ty)| { - datatype( - &config, - &FunctionResultVariant::Value(ty.inner.clone()), - &self.type_map, - ) - .unwrap() - }) { + // Generate type exports (non-Procedures) + for export in self + .type_map + .iter() + .map(|(_, ty)| export_named_datatype(&config, ty, &self.type_map).unwrap()) + { writeln!(file, "\n{}", export)?; }