Skip to content

Commit c6a56c4

Browse files
committed
feat: add type alias support
1 parent 44bdd18 commit c6a56c4

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

_examples/hello-webrpc/hello-api.ridl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ enum Kind: uint32
77
- USER = 1
88
- ADMIN = 2
99

10+
type Username: string
11+
type Age: uint32
12+
1013
struct Empty
1114

1215
struct User

_examples/hello-webrpc/webapp/client.gen.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// hello-webrpc v1.0.0 7037367a376940060eaf2739a920c4dca4a6dc2e
1+
// hello-webrpc v1.0.0 949b00a8db9810c69295f9dd9f02587a65d3c497
22
// --
3-
// Code generated by webrpc-gen@v0.32.3 with ../../ generator. DO NOT EDIT.
3+
// Code generated by webrpc-gen@v0.36.1-5-g76cb402 with ../../ generator. DO NOT EDIT.
44
//
55
// webrpc-gen -schema=hello-api.ridl -target=../../ -exports=false -client -out=./webapp/client.gen.js
66

@@ -11,12 +11,16 @@ const WebRPCVersion = "v1"
1111
const WebRPCSchemaVersion = "v1.0.0"
1212

1313
// Schema hash generated from your RIDL schema
14-
const WebRPCSchemaHash = "7037367a376940060eaf2739a920c4dca4a6dc2e"
14+
const WebRPCSchemaHash = "949b00a8db9810c69295f9dd9f02587a65d3c497"
1515

1616
//
1717
// Types
1818
//
1919

20+
// type Username = string
21+
22+
// type Age = uint32
23+
2024
var Kind;
2125
(function (Kind) {
2226
Kind["USER"] = "USER"

types.go.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
})({{$enumName}} || ({{$enumName}} = {}))
2020
{{end -}}
2121

22+
{{- if isAliasType $type }}
23+
// type {{$type.Name}} = {{$type.Type}}
24+
{{end -}}
25+
2226
{{- if isStructType $type }}
2327
{{if $opts.exports}}export {{end}}class {{.Name}} {
2428
constructor(_data) {

0 commit comments

Comments
 (0)