quicktype / quicktype

Generate types and converters from JSON, Schema, and GraphQL

Home Page:https://app.quicktype.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uint8Array translated to []float64 instead of []byte

artob opened this issue · comments

This would seem like a bug:

// test.ts
export type InputData = Uint8Array;
quicktype -o test.go test.ts
// test.go
type InputData []float64

This also happens for Rust code

quicktype -o test.rs test.ts
// test.rs
pub type InputData = Vec<f64>;

A more correct output would be

pub type InputData = Vec<u8>;

Though even better still might be to use the serde_bytes crate since Vec<u8> doesn't always serialize optimally with serde otherwise. Then the output would be

pub type InputData = serde_bytes::ByteBuf;