-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e282f0
commit 607ac29
Showing
8 changed files
with
97 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "specta-macros" | ||
description = "Macros for specta. Don't use directly!" | ||
version = "2.0.0-rc.16" | ||
version = "2.0.0-rc.17" | ||
authors = ["Oscar Beaumont <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "specta-serde" | ||
description = "Serde support for Specta" | ||
version = "0.0.3" | ||
version = "0.0.4" | ||
authors = ["Oscar Beaumont <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
|
@@ -19,5 +19,5 @@ rustdoc-args = ["--cfg", "docsrs"] | |
workspace = true | ||
|
||
[dependencies] | ||
specta = { version = "=2.0.0-rc.16", path = "../specta" } | ||
specta = { version = "=2.0.0-rc.17", path = "../specta" } | ||
thiserror = "1.0.61" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "specta-typescript" | ||
description = "Export your Rust types to TypeScript" | ||
version = "0.0.3" | ||
version = "0.0.4" | ||
authors = ["Oscar Beaumont <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
|
@@ -25,7 +25,7 @@ function = ["specta/function"] | |
workspace = true | ||
|
||
[dependencies] | ||
specta = { version = "=2.0.0-rc.16", path = "../specta" } | ||
specta = { version = "=2.0.0-rc.17", path = "../specta" } | ||
# TODO: Don't depend on serde | ||
specta-serde = { version = "=0.0.3", path = "../specta-serde" } | ||
specta-serde = { version = "=0.0.4", path = "../specta-serde" } | ||
thiserror = "1.0.61" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "specta-util" | ||
description = "High-level utilities for working with Specta" | ||
version = "0.0.3" | ||
version = "0.0.4" | ||
authors = ["Oscar Beaumont <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
|
@@ -27,7 +27,7 @@ serde = [] | |
workspace = true | ||
|
||
[dependencies] | ||
specta = { version = "=2.0.0-rc.16", path = "../specta" } | ||
specta-macros = { version = "=2.0.0-rc.16", path = "../specta-macros", default-features = false, optional = true } | ||
specta = { version = "=2.0.0-rc.17", path = "../specta" } | ||
specta-macros = { version = "=2.0.0-rc.17", path = "../specta-macros", default-features = false, optional = true } | ||
ctor = { version = "0.2.8", default-features = false, optional = true } | ||
serde = "1.0.204" # TODO: Can we remove this or at least make it optional behind the `serde` flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "specta" | ||
description = "Easily export your Rust types to other languages" | ||
version = "2.0.0-rc.16" | ||
version = "2.0.0-rc.17" | ||
authors = ["Oscar Beaumont <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
|
@@ -84,7 +84,7 @@ interop = ["dep:specta1"] | |
workspace = true | ||
|
||
[dependencies] | ||
specta-macros = { version = "=2.0.0-rc.16", optional = true, path = "../specta-macros" } | ||
specta-macros = { version = "=2.0.0-rc.17", optional = true, path = "../specta-macros" } | ||
paste = { version = "1", optional = true } | ||
thiserror = "1.0.61" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,61 @@ | ||
#![allow(deprecated)] | ||
// #![allow(deprecated)] | ||
|
||
use specta::{datatype::Function, function::fn_datatype, specta, TypeMap}; | ||
use specta_typescript::export_function_header; | ||
// use specta::{datatype::Function, function::fn_datatype, specta, TypeMap}; | ||
|
||
#[specta] | ||
fn a() {} | ||
#[specta] | ||
fn b() -> () {} | ||
#[specta] | ||
async fn c() {} | ||
#[specta] | ||
fn d() -> String { | ||
"todo".into() | ||
} | ||
#[specta] | ||
fn e(a: String) {} | ||
#[specta] | ||
fn f(a: String, b: i32) {} | ||
#[specta] | ||
#[deprecated] | ||
fn g() {} | ||
// #[specta] | ||
// fn a() {} | ||
// #[specta] | ||
// fn b() -> () {} | ||
// #[specta] | ||
// async fn c() {} | ||
// #[specta] | ||
// fn d() -> String { | ||
// "todo".into() | ||
// } | ||
// #[specta] | ||
// fn e(a: String) {} | ||
// #[specta] | ||
// fn f(a: String, b: i32) {} | ||
// #[specta] | ||
// #[deprecated] | ||
// fn g() {} | ||
|
||
#[test] | ||
fn test_export_function_header() { | ||
assert( | ||
fn_datatype!(a)(&mut TypeMap::default()), | ||
Ok("export function a();"), | ||
); | ||
assert( | ||
fn_datatype!(b)(&mut TypeMap::default()), | ||
Ok("export function b(): null;"), | ||
); | ||
assert( | ||
fn_datatype!(c)(&mut TypeMap::default()), | ||
Ok("export async function c();"), | ||
); | ||
assert( | ||
fn_datatype!(d)(&mut TypeMap::default()), | ||
Ok("export function d(): string;"), | ||
); | ||
assert( | ||
fn_datatype!(e)(&mut TypeMap::default()), | ||
Ok("export function e(a: string);"), | ||
); | ||
assert( | ||
fn_datatype!(f)(&mut TypeMap::default()), | ||
Ok("export function f(a: string, b: number);"), | ||
); | ||
assert( | ||
fn_datatype!(g)(&mut TypeMap::default()), | ||
Ok("/**\n * @deprecated\n */\nexport function g();"), | ||
); | ||
} | ||
// #[test] | ||
// fn test_export_function_header() { | ||
// assert( | ||
// fn_datatype!(a)(&mut TypeMap::default()), | ||
// Ok("export function a();"), | ||
// ); | ||
// assert( | ||
// fn_datatype!(b)(&mut TypeMap::default()), | ||
// Ok("export function b(): null;"), | ||
// ); | ||
// assert( | ||
// fn_datatype!(c)(&mut TypeMap::default()), | ||
// Ok("export async function c();"), | ||
// ); | ||
// assert( | ||
// fn_datatype!(d)(&mut TypeMap::default()), | ||
// Ok("export function d(): string;"), | ||
// ); | ||
// assert( | ||
// fn_datatype!(e)(&mut TypeMap::default()), | ||
// Ok("export function e(a: string);"), | ||
// ); | ||
// assert( | ||
// fn_datatype!(f)(&mut TypeMap::default()), | ||
// Ok("export function f(a: string, b: number);"), | ||
// ); | ||
// assert( | ||
// fn_datatype!(g)(&mut TypeMap::default()), | ||
// Ok("/**\n * @deprecated\n */\nexport function g();"), | ||
// ); | ||
// } | ||
|
||
#[track_caller] | ||
fn assert(dt: Function, result: specta_typescript::Result<&str>) { | ||
match export_function_header(dt, &Default::default()) { | ||
Ok(s) => assert_eq!(result, Ok(s.as_str())), | ||
Err(e) => assert_eq!(result, Err(e)), | ||
} | ||
} | ||
// #[track_caller] | ||
// fn assert(dt: Function, result: specta_typescript::Result<&str>) { | ||
// match export_function_header(dt, &Default::default()) { | ||
// Ok(s) => assert_eq!(result, Ok(s.as_str())), | ||
// Err(e) => assert_eq!(result, Err(e)), | ||
// } | ||
// } |