-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make #[ts(export_to = "...")]
relative to TS_RS_EXPORT_DIR
#250
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ae64422
82863bb
Fix docs.rs test
escritorio-gustavo 7e73ed8
Fix path_bug.rs test
escritorio-gustavo b25ac88
Fix docs.rs test again
escritorio-gustavo 8e86b35
Try to get info on test failure
escritorio-gustavo 83bebd5
More info
escritorio-gustavo afbc24e
Test TS_RS_EXPORT_DIR first to get error faster
escritorio-gustavo b325448
Change how environment variable is read
escritorio-gustavo 91485a3
Read environment variable outside macro
escritorio-gustavo 5ecae52
add TS::export_path
escritorio-gustavo 1dd9d73
Make output_path public
escritorio-gustavo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -165,9 +165,6 @@ use std::{ | |
pub use ts_rs_macros::TS; | ||
|
||
pub use crate::export::ExportError; | ||
// Used in generated code. Not public API | ||
#[doc(hidden)] | ||
pub use crate::export::__private; | ||
use crate::typelist::TypeList; | ||
|
||
#[cfg(feature = "chrono-impl")] | ||
|
@@ -304,10 +301,6 @@ pub trait TS { | |
} | ||
} | ||
|
||
fn get_export_to() -> Option<String> { | ||
Self::EXPORT_TO.map(ToString::to_string) | ||
} | ||
|
||
/// Declaration of this type, e.g. `interface User { user_id: number, ... }`. | ||
/// This function will panic if the type has no declaration. | ||
/// | ||
|
@@ -428,7 +421,17 @@ impl Dependency { | |
/// If `T` is not exportable (meaning `T::EXPORT_TO` is `None`), this function will return | ||
/// `None` | ||
pub fn from_ty<T: TS + 'static + ?Sized>() -> Option<Self> { | ||
let exported_to = T::get_export_to()?; | ||
let base = std::env::var("TS_RS_EXPORT_DIR") | ||
.ok() | ||
.as_deref() | ||
.map(Path::new) | ||
.unwrap_or_else(|| Path::new(".")) | ||
.to_owned(); | ||
|
||
let exported_to = base | ||
.join(T::EXPORT_TO.map(ToOwned::to_owned)?) | ||
.to_string_lossy() | ||
.to_string(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here, might be nice to re-use |
||
Some(Dependency { | ||
type_id: TypeId::of::<T>(), | ||
ts_name: T::ident(), | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we re-use
output_path
here? Might be the case that we have to get rid of thepath::absolute
inoutput_path
for that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't even think we need to remove
path::absolute
, this path will be fed intodiff_paths
, which uses absolute paths as wellThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, perfect!