Skip to content

Commit

Permalink
Merge pull request #323 from espeon/main
Browse files Browse the repository at this point in the history
fix: export non-Procedures TypeScript types
  • Loading branch information
oscartbeaumont authored Dec 3, 2024
2 parents d812910 + edd828c commit 0096763
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/legacy/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ where
}

pub fn typedef<TArg: Type, TResult: Type>(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 }
}
16 changes: 7 additions & 9 deletions src/legacy/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)?;
}

Expand Down

0 comments on commit 0096763

Please sign in to comment.