Skip to content
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

[typeshare] Support external tags for enums #7

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

naveenOnarayanan
Copy link

@naveenOnarayanan naveenOnarayanan commented Nov 7, 2024

Description

  • For complex enums the default serde serialization is externally tagged, to avoid having to re-write our rust logic to use internal tags via #[serde(tag = "type", content = "content")] we are going to add manual support for it in typescript
  • Bumping version to 1.12.1
  • Adding a --dry-run flag to allow building locally

Before

# Rust
enum MyEnum {
  blahblah {
    name: String
  }
  blahblah2 {
    age: u64
  }
}
# Typescript
export type MyEnum = 
  { "type": "blahblah", content: { "name": string }}
  | { "type": "blahblah2", content: { "age": number }}

After

export type MyEnum =
 { "blahblah": { "name": string }}
| { "blahblah2": { "age": number }}

Test Plan

  • CI passes

Revert Plan

  • Revert

@naveenOnarayanan naveenOnarayanan merged commit 49b811a into main Nov 7, 2024
5 checks passed
naveenOnarayanan added a commit that referenced this pull request Nov 22, 2024
* For complex enums the default serde serialization is externally tagged, to avoid having to re-write our rust logic to use internal tags via `#[serde(tag = "type", content = "content")]` we are going to add manual support for it in `typescript`
* Bumping version to `1.12.1`
* Adding a `--dry-run` flag to allow building locally

```
enum MyEnum {
  blahblah {
    name: String
  }
  blahblah2 {
    age: u64
  }
}
```

```
export type MyEnum =
  { "type": "blahblah", content: { "name": string }}
  | { "type": "blahblah2", content: { "age": number }}
```

```
export type MyEnum =
 { "blahblah": { "name": string }}
| { "blahblah2": { "age": number }}
```

* CI passes

* Revert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants