Skip to content

Commit 112f40e

Browse files
authored
feat: add type alias support (#10)
1 parent 44bdd18 commit 112f40e

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v3
1616
- name: Install webrpc-gen
1717
run: |
18-
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.32.3/webrpc-gen.linux-amd64
18+
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.37.0/webrpc-gen.linux-amd64
1919
chmod +x ./webrpc-gen
2020
echo $PWD >> $GITHUB_PATH
2121

_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.37.0 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)