types: generate TypeScript from engine structs with tygo
tygo is pinned via go.mod's tool directive (Go 1.24+): the tool's version is locked like any dependency and runs as 'go tool tygo', no global install. 'go generate ./...' regenerates web/src/types/engine.ts from Config/Result and their json tags; the generated file is committed so the frontend builds without Go installed. The go:generate directive anchors in a root generate.go because generate runs commands from the declaring file's directory and tygo reads tygo.yaml from the cwd. go.mod's ignore directive (Go 1.25+) keeps ./... from crawling into web/node_modules, where some npm packages ship stray .go files.
This commit is contained in:
parent
f58f33c3fd
commit
9bae4a9ca0
5 changed files with 847 additions and 0 deletions
8
tygo.yaml
Normal file
8
tygo.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Generates the frontend's TypeScript types from the Go structs, which are
|
||||
# the single source of truth for parameters and results (see tool-handoff.md).
|
||||
# Regenerate with: go generate ./...
|
||||
packages:
|
||||
- path: "github.com/JustinZeus/spreadlab/internal/engine"
|
||||
output_path: "web/src/types/engine.ts"
|
||||
include_files:
|
||||
- "scenario.go"
|
||||
Loading…
Add table
Add a link
Reference in a new issue