specta-rs / specta

Easily export your Rust types to other languages
MIT License
290 stars 41 forks source link

DUMP #265

Open oscartbeaumont opened 5 months ago

oscartbeaumont commented 5 months ago

This is an old document in my notes that I wanna dump here. Will think about it again in the furture so that all of it will a pound of salt.

` #[specta(optional)]should not work on unnamed fields + add into trybuild comments: Vec<Cow<..>>ordoc: Option<Cow<..>>should probs just all bedoc: Cow<..>for consistency ShouldEnumTypehavedeprecatedandcomments. Logically right now it's onNamedDataType` but it's also a wacky disparity.

Are we properly escaping enum tags. I have a feeling they could contain invalid chars for a TS name or even reserved words???

Defined order for handling multiple conflicting attributes either within a single attribute or across multiple attributes. Should specta::lang::js_doc be specta::lang::ts::js_doc??? Should #[specta(optional)] change? Should #[specta(transparent)] change? Right now a reference to it is to the type name but Serde kinda imply in their docs that it should be a direct passthrough to the single inner field. If not changing it we should have something to handle the opposite case + unit test it with #[specta(optional)] on the single field. Unit test using inline and transparent together cause they cause issues. Especially with attributes applied to the inner value like #[specta(optional)]. Does exporting doc comments on redundant conditions break then removable of the redundant conditions? For usage with to_named it might make sense to allow mutable changes to deprecated, doc, etc on NamedDataType

2.0.0-rc.4:

Thursday:

Refactor TS exporter to use string joining instead of Vec's so save allocations + also just give it a general cleanup! type CowStr = Cow<'static, str>; Can TypeMap's value not be Option? I have a feeling it doesn't need to be anymore. Put TypeMap into ExportContext

Vec<impl Into<DataType> for DataType should be for UntaggedEnum

On a struct with named fields: Serialize the struct's name (or value of serde(rename)) as a field with the given key, in front of all the real fields of the struct.

Future:

Seal DefOpts Go through and do my best to seal enum types

For flatten right now we export ({ a: string }) & ({ a: string }) but we should export ({ a: string })

https://github.com/Aleph-Alpha/ts-rs/issues/165 https://github.com/Aleph-Alpha/ts-rs/issues/152 https://github.com/Aleph-Alpha/ts-rs/issues/153

Can TypeMap should/should it not hold Option<NamedDataType>??? Technically using a type in a partially constructed state is bad.

[f32; 4] should export as a Typescript tuple of length 4

Make #[serde(untagged)] enum work?

Review public API and doc and improve them Example of function exporting without 3rd party library Document features Document different export methods and when to use them Stuff from phone Discuss enum types and tagging, etc DefOpts.parent_inline document what it actually does // TODO: Does inline, definition and reference all need to exist and explain them Design Why not use Rust TypeId -> Limitations with lifetime etc

Make NamedDataType.export work Inlining a recursive type -> What happens? Unit test Put all language exporter other than ts behind "unstable" feature flag

Should Specta v2 keep the impls for external crates because we can't ever remove them once published and moving the impls into the downstream crate would be better performance. Break up the current language exporters into their crates and remove from Specta itself???

Rename internal module to __unstable so it's less likely to be in LSP hints and to make it clear it's not to be used.

Unit tests for stupid types -> Assoicated types, assoicated constants, with and without bounds, etc

oscartbeaumont commented 4 months ago
Specta v2
Why are there two Reference types.

Can we remove the reference method from Type.

Can we remove the generics arg from Type. Just ensure definition isn’t a lazy pass through cause I bet that’s what breaks it.

Rename DeprecatedType to DeprecatedAttribute or something

Should LiteralType end up as a TS only extension???

Move data type stuff to Specta-core which will cleanup the public docs

Better docs for traits and inline vs reference, named data type vs non named type

Using static references to trait object for typescript type extension???

Why is prettier and eslint in the TS module
Remove ‘ts::Result’

`export` feature doesn’t work with generic types. Should *just* work for have a better warning.

TODO: Merge this is the obsidian doc
oscartbeaumont commented 1 week ago
oscartbeaumont commented 1 week ago

Remove NamedDataType and merge it's metadata into Type

Static vecs

! type Move out non-ts exporter into crates

Should DataTypeReference.inline??? This would probs simplify the Type macro a bit

Type::reference -> DataTypeReference + Remove Reference The bigger issue here is the Reference could be inlined and then it's a DataType::* not DataType::Reference

Using Cow instead of Vec everywhere

Break out language exporters into dedicated crates Break static_types into language specific crates

The export feature should take in a standard interface to a language exporter so we don't need it to have methods for each language Should export feature be kept in the Specta core???

Can we somehow remove Specta's dependance on tauri while keeping tauri-specta working

Public constructor for List and Map

DataTypeReference.inline -> Should we use a property and delay processing it????

Lint for enabling Debug on all public types