Commit Graph
254 Commits
Author SHA1 Message Date
xazukx b9f212886b Add ability to create native typescript enums instead of unions. 2025-06-10 12:00:10 -06:00
NyxCode dc2892f441 fix regression: #[ts(optional)] incompatible with #[ts(type = ...)] (#416) 2025-06-04 08:47:33 -03:00
6075bd1bc3 Handle serde(skip_serializing_if) + serde(default) (#393)
* `skip_serializing_if` assumes that object’s field may not exist

* update implementation to match the two special-cases mentioned

* fix comment

* update README.md

* Run cargo +nightly fmt to attempt to resolve merge conflict

* update changelog

* fix typo in emitted compiler errors

* add missing functionality to test, add TODOs

* implement #[ts(optional)] for tuple structs

* avoid triggering TS1257

* implement override

* adjust docs, add one more test

* adjust docs

* clarify comment on optional::apply

* typo

---------

Co-authored-by: Moritz Bischof <moritz.bischof1@gmail.com>
Co-authored-by: gustavo-shigueo <gustavo.gsmn@gmail.com>
2025-06-03 17:34:23 +02:00
NyxCode 0dbaa5efab Allow arbitrary expressions in #[doc] (#411) 2025-05-30 11:58:10 -03:00
Gustavo Shigueo 315bed8f3f Remove duplicate validation (#404)
* Remove duplicated validation of struct attributes

* Fix clippy warnings

* Revert MSRV break
2025-05-30 00:17:43 +02:00
NyxCode 40b82771c8 Allow arbitrary expressions in #[ts(export_to)] (#399) 2025-04-04 18:17:03 -03:00
NyxCode f64db436e8 Allow arbitrary expressions in top-level #[ts(rename)] (#398) 2025-04-04 15:07:41 -03:00
Gustavo Shigueo 7b7ec40669 Handle serde fail gracefully (#389) 2025-04-03 11:50:10 -03:00
Gustavo Shigueo ee2240db94 Prevent naming collisions with <T as crate::TS> (#386) 2025-03-06 17:55:08 -03:00
Gustavo Shigueo 594fa3027a Fix top level #[ts(as = "...")] dependency list (#385) 2025-03-06 17:07:23 -03:00
Gustavo ShigueoandNyxCode ad0f22917e Add #[ts(optional)] to struct (#366)
* Parse #[ts(optional_fields)] on structs
* compile-time checked `#[ts(optional)]` (#367)
* #[ts(type)] overrides #[ts(optional_fields)]
* Make #[ts(type)] and #[ts(optional)] incompatible
* Update MSRV

---------

Co-authored-by: NyxCode <moritz.bischof1@gmail.com>
2025-02-21 09:19:05 -03:00
Gustavo Shigueo 64382968c5 Fix empty struct tagged enum variant (#371) 2024-11-25 13:24:21 -03:00
escritorio-gustavoandGustavo Shigueo 9763ca0195 Support #[ts(as = "...")] and #[ts(type = "...")] on enum variants (#284)
Co-authored-by: Gustavo Shigueo <gustavo.gsmn@gmail.com>
2024-09-16 16:57:57 -03:00
escritorio-gustavoandgustavo-shigueo 5cbc7405d8 feat: Allow multiple types to set #[ts(export_to = "...")] to the same file (#316)
---------

Co-authored-by: gustavo-shigueo <gustavo.gsmn@gmail.com>
2024-08-01 18:15:19 -03:00
Gustavo Shigueo 5c3b8c9457 Fix error in internally tagged enums with flattened fields (#344) 2024-07-27 12:19:47 -03:00
Gustavo Shigueo e08161c790 Fix JSDoc formatting for Rust block comments (#342) 2024-07-25 15:20:38 -03:00
NyxCode af15ff92d7 Allow for flattening of generic parameters (#336) 2024-06-28 02:07:52 +02:00
NyxCode badbac08e6 Testing with --no-default-features didnt seem to work in CI (#319) 2024-05-20 08:36:36 -03:00
7d28c1a97a Rework dependency and generics handling (#306)
* add failing test

* remove `TypeList`

* cleanup codegen

* add failing tests for tuples

* fix missing `visit_generics` impl for tuples

* Merge branch 'main' into better-dependencies

* Merge branch 'main' into better-dependencies

* Lower MSRV to 1.63.0

* add test for #317

* update changelog

---------

Co-authored-by: Gustavo <gustavo.shigueo@proton.me>
Co-authored-by: escritorio-gustavo <131818645+escritorio-gustavo@users.noreply.github.com>
2024-05-17 22:13:59 +02:00
escritorio-gustavo d122373963 Handle case where TypePath::qself is Some (#310) 2024-04-18 09:25:01 -03:00
NyxCode cb1314d87c Fix unqualified TS trait method calls (#309) 2024-04-17 08:12:04 -03:00
escritorio-gustavoandNyxCode e671a7a343 Infered types (_) in #[ts(as = "...")] (#299)
---------

Co-authored-by: NyxCode <moritz.bischof1@gmail.com>
2024-04-10 14:07:50 -03:00
escritorio-gustavo b9a4cca637 Fix location of rename_all errors (#303) 2024-04-09 11:15:48 -03:00
Kevin AmadoandMoritz Bischof 8cfc3d7e05 dedup dependencies (#293)
Co-authored-by: Moritz Bischof <moritz.bischof1@gmail.com>
2024-04-09 10:21:05 -03:00
escritorio-gustavo ff93760886 Support #[serde(with = "...")] for struct fields (#280) 2024-04-09 08:45:09 -03:00
escritorio-gustavo 1079b991b4 Fix inconsistencies with serde and add SCREAMING-KEBAB-CASE (#298) 2024-04-09 08:07:48 -03:00
escritorio-gustavo c222ab0d39 Add MSRV to cargo.toml and README (#300) 2024-04-08 15:39:20 -03:00
escritorio-gustavo 40360d4236 Rework attribute parsing (#290) 2024-04-03 11:08:45 -03:00
escritorio-gustavo 22d03fc2f0 Prevent empty Dependencies from being added to dependency_types (#291) 2024-04-02 17:31:12 -03:00
Aiden McClelland c862aa6208 add support for top level as (#288) 2024-04-02 17:10:34 -03:00
escritorio-gustavo cf450ac5d6 Fix #[ts(rename_all_fields = "...")] on enums containing tuple or unit variants (#287) 2024-04-01 09:52:01 -03:00
Aiden McClelland 8b7762269a add support for top level type overrides (#286)
* add support for top level type overrides

* add docs

* use early return

* error for `type` incompatible with other enum container attributes about serialization

* remove non-applicable `#[non_exhaustive]` attribute

* rename t_o to attr_type_override
2024-03-28 21:25:07 +01:00
escritorio-gustavo 6f7311d523 Fix bug in enum flattening (#282)
* When a struct containing a flattened enum was itself flattened, the type generated would be missing the enum
2024-03-22 10:30:31 -03:00
Aumetra Weisman 88c2ae8c09 Fix generic impl (#281)
* Fix rename impl for generics
* Add regression test
2024-03-22 08:22:43 -03:00
77f224e07a Option to rename source of TS trait (#274)
Add #[ts(crate = ..)] attribute 

---------

Co-authored-by: Gustavo <gustavo.shigueo@proton.me>
Co-authored-by: Moritz Bischof <moritz.bischof1@gmail.com>
2024-03-20 14:16:54 -03:00
escritorio-gustavo 7949a33898 Merge pull request #271 from Aleph-Alpha/improve-type-as
`#[ts(as = "..")]` - Allow any type, not just path
2024-03-18 07:57:35 -03:00
Wilson Gramer 6cdaa0c9c5 Use 'match' instead of 'map_or_else' in 'generate_impl_block_header' 2024-03-17 15:13:29 -04:00
Moritz Bischof f4c6e5e7aa allow any type, not just path, in #[ts(type_as = "..")] 2024-03-16 16:22:14 +01:00
Gustavo c6f126e9fb Remove unnecessary is_empty check 2024-03-14 09:44:00 -03:00
Gustavo f2df989cca Simplify bound parsing 2024-03-14 09:19:33 -03:00
Gustavo 790e9f549b Parse WherePredicate to improve error locations 2024-03-14 08:54:57 -03:00
Wilson Gramer 9cb9682d7a Add '#[ts(bound)]' attribute 2024-03-13 20:09:25 -04:00
Gustavo 96dc7cbad9 Add leading colon to ts_rs path in macro expansion 2024-03-13 15:17:01 -03:00
02031e91b5 #[ts(concrete)]: Allow generic parameter to be "disabled" (#264)
* implement first POC

* make #[ts(export)] work

* Make '#[ts(concrete)]' an attribute on the type, not the generic parameters (#262)

* Add test for importing associated type

* Test using the generic itself

* Add trait bound to concrete types used within enum

* use concrete type in `TS::decl`

* Remove unused param

* organize tests

* add simple tests without associated types

* Remove all generics, since they are no longer handled by type_def

* Prevent creation of file without extension in test

* Prevent generation of file in issue261 test

* Revert "Add trait bound to concrete types used within enum"

This reverts commit b511f1f14957595b7bcec383dfea1c2e358a23e9.

* Tests missing semicolons in expected text

* Typo on type name

* implement "one bound per field"

* add type filtering

* remove TS bound from tests

* Remove todo!

* Ensure only generics get type bounds

* Remove explicit return

* Cargo fmt

* Refactor `filter_ty` (#265)

* update docs and changelog

* Fix typo in CHANGELOG.md

* Cargo fmt

* Remove TS bound from trait in test file

---------

Co-authored-by: Wilson Gramer <12683684+WilsonGramer@users.noreply.github.com>
Co-authored-by: Gustavo <gustavo.shigueo@proton.me>
Co-authored-by: escritorio-gustavo <131818645+escritorio-gustavo@users.noreply.github.com>
2024-03-13 19:04:46 +01:00
Moritz Bischof f790cb72b5 Make TS::output_path _not_ include TS_RS_EXPORT_DIR
Introduce missing functions "export(_all)?(_to)?"
Make naming more consistent
2024-03-10 17:52:45 +01:00
Gustavo 4cc011c8e0 Change ignore to compile_fail 2024-03-08 15:55:56 -03:00
escritorio-gustavo 474cc86a2e Merge pull request #257 from Aleph-Alpha/better-error-locations
Improve location of some compiler errors
2024-03-08 07:58:21 -03:00
Gustavo b8a1df92ff Make inacurate error spans capture the entire item 2024-03-07 16:11:47 -03:00
NyxCode cd59b2c3d2 Alternative handling of output paths (#256)
* Implement alternative handling of output paths

* adjust CI

* fix CI, remove println!
2024-03-07 19:20:05 +01:00
Gustavo 501e87c324 Improve location of some errors 2024-03-07 15:08:17 -03:00