Skip to content

Commit 0096763

Browse files
Merge pull request #323 from espeon/main
fix: export non-Procedures TypeScript types
2 parents d812910 + edd828c commit 0096763

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/legacy/resolver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ where
119119
}
120120

121121
pub fn typedef<TArg: Type, TResult: Type>(defs: &mut TypeMap) -> ProcedureDataType {
122-
let mut type_map = TypeMap::default();
123-
let arg_ty = TArg::reference(&mut type_map, &[]).inner;
124-
let result_ty = TResult::reference(&mut type_map, &[]).inner;
122+
let arg_ty = TArg::reference(defs, &[]).inner;
123+
let result_ty = TResult::reference(defs, &[]).inner;
124+
125125
ProcedureDataType { arg_ty, result_ty }
126126
}

src/legacy/router.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use futures::Stream;
1212
use serde_json::Value;
1313
use specta::{datatype::FunctionResultVariant, DataType, TypeMap};
14-
use specta_typescript::{self as ts, datatype, Typescript};
14+
use specta_typescript::{self as ts, datatype, export_named_datatype, Typescript};
1515

1616
use crate::{
1717
internal::{Procedure, ProcedureKind, ProcedureStore, RequestContext, ValueOrStream},
@@ -161,14 +161,12 @@ export type Procedures = {{
161161
}};"#
162162
)?;
163163

164-
for export in self.type_map.iter().map(|(_, ty)| {
165-
datatype(
166-
&config,
167-
&FunctionResultVariant::Value(ty.inner.clone()),
168-
&self.type_map,
169-
)
170-
.unwrap()
171-
}) {
164+
// Generate type exports (non-Procedures)
165+
for export in self
166+
.type_map
167+
.iter()
168+
.map(|(_, ty)| export_named_datatype(&config, ty, &self.type_map).unwrap())
169+
{
172170
writeln!(file, "\n{}", export)?;
173171
}
174172

0 commit comments

Comments
 (0)