Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite330dc1

Browse files
authored
feat: Switch packages for typescript generation code (#1196)
* feat: Switch packages for typescript generation codeSupports a larger set of types - [x] Basics (string/int/etc) - [x] Maps - [x] Slices - [x] Enums - [x] Pointers
1 parentafc43fe commite330dc1

File tree

6 files changed

+685
-280
lines changed

6 files changed

+685
-280
lines changed

‎codersdk/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func New(serverURL *url.URL) *Client {
2626
}
2727

2828
// Client is an HTTP caller for methods to the Coder API.
29+
// @typescript-ignore Client
2930
typeClientstruct {
3031
HTTPClient*http.Client
3132
SessionTokenstring
@@ -113,6 +114,7 @@ func readBodyAsError(res *http.Response) error {
113114
}
114115

115116
// Error represents an unaccepted or invalid request to the API.
117+
// @typescript-ignore Error
116118
typeErrorstruct {
117119
httpapi.Response
118120

‎go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ require (
109109
golang.org/x/sysv0.0.0-20220412211240-33da011f77ad
110110
golang.org/x/termv0.0.0-20210927222741-03fcf44c2211
111111
golang.org/x/textv0.3.7
112+
golang.org/x/toolsv0.1.10
112113
golang.org/x/xerrorsv0.0.0-20220411194840-2f41105eb62f
113114
google.golang.org/apiv0.75.0
114115
google.golang.org/protobufv1.28.0

‎go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,7 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
22872287
golang.org/x/toolsv0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
22882288
golang.org/x/toolsv0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
22892289
golang.org/x/toolsv0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
2290+
golang.org/x/toolsv0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
22902291
golang.org/x/xerrorsv0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
22912292
golang.org/x/xerrorsv0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
22922293
golang.org/x/xerrorsv0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

‎scripts/apitypings/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#APITypings
2+
3+
This main.go generates typescript types from the codersdk types in Go.
4+
5+
#Features
6+
7+
- Supports Go types
8+
-[x] Basics (string/int/etc)
9+
-[x] Maps
10+
-[x] Slices
11+
-[x] Enums
12+
-[x] Pointers
13+
-[ ] External Types (uses`any` atm)
14+
- Some custom external types are hardcoded in (eg: time.Time)
15+
16+
17+
##Type overrides
18+
19+
```golang
20+
typeFoostruct {
21+
// Force the typescript type to be a number
22+
CreatedAt time.Duration`json:"created_at" typescript:"number"`
23+
}
24+
```
25+
26+
##Ignore Types
27+
28+
Do not generate ignored types.
29+
30+
```golang
31+
// @typescript-ignore InternalType
32+
typeInternalTypestruct {
33+
// ...
34+
}
35+
```
36+
37+
#Future Ideas
38+
39+
- Should`omitempty` in the`json` tag indicate optional?
40+
- Use a yaml config for overriding certain types

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp