Skip to content

Commit ddb7332

Browse files
committed
Support interface{} types in generated Typescript
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent b9d5915 commit ddb7332

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

scripts/apitypings/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,13 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
457457
}
458458
resp.Optional = true
459459
return resp, nil
460+
case *types.Interface:
461+
// only handle the empty interface for now
462+
intf := ty
463+
if intf.Empty() {
464+
return TypescriptType{ValueType: "any"}, nil
465+
}
466+
return TypescriptType{}, xerrors.New("only empty interface types are supported")
460467
}
461468

462469
// These are all the other types we need to support.

site/src/api/typesGenerated.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ export interface GoogleInstanceIdentityToken {
172172
readonly json_web_token: string
173173
}
174174

175+
// From codersdk/licenses.go
176+
export interface License {
177+
readonly id: number
178+
readonly uploaded_at: string
179+
readonly claims: Record<string, any>
180+
}
181+
175182
// From codersdk/users.go
176183
export interface LoginWithPasswordRequest {
177184
readonly email: string

0 commit comments

Comments
 (0)