alux-shape-typescript
alux-shape-typescript interprets an alux-shape term as TypeScript declarations.
use ;
use TsShape;
let alg = new;
let checksum = alg.field;
let display_name = alg.field;
let user = alg.named_product;
assert_eq!;
println!;
export interface User {
checksum: string
displayName: string
}
A shape carries what stands for it where it is used, and the declarations that use depends on. So a
name is declared once however often it appears, and module() answers with every declaration a shape
needs, in name order.
Members are spelled as the surface spells them. A type's own name is written in pascal case, which is TypeScript's convention rather than the shape's statement.
Three readings worth stating, because each is a decision rather than a translation:
- An integer is
numberat every width, since that is what a JSON number is. A width beyond what that holds exactly is the reason a domain writes such a quantity as text, which reads asstring. - Bare bytes are
never. Nothing states how they are written, so no value inhabits them;bytes_hexreads asstring. - A merged product becomes an intersection, so a product with nothing merged in is an
interfaceand one with something merged in is a type alias. Both are the same shape; only the declaration differs.