Files
coder/scripts/apitypings
Steven Masley e55d921537 chore: Typescript generator TODOs resolved, adding explainations (#6633)
* chore: Explain usage of eslint comments

* Conform comment

* Fix wording

* Linting
2023-03-17 09:28:16 -05:00
..

APITypings

This main.go generates typescript types from the codersdk types in Go.

Features

  • Supports Go types
    • Basics (string/int/etc)
    • Maps
    • Slices
    • Enums
    • Pointers
    • External Types (uses any atm)
      • Some custom external types are hardcoded in (eg: time.Time)

Type overrides

type Foo struct {
	// Force the typescript type to be a number
	CreatedAt time.Duration `json:"created_at" typescript:"number"`
}

Ignore Types

Do not generate ignored types.

// @typescript-ignore InternalType
type InternalType struct {
	// ...
}

Future Ideas

  • Use a yaml config for overriding certain types