Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: generate enums as types
  • Loading branch information
brettkolodny committed Jun 9, 2025
commit 2b1c06f5b5082c451caf33e117e26795239d04a3
7 changes: 6 additions & 1 deletion preview/scripts/types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ func main() {
}

ts, err := gen.ToTypescript()
ts.ApplyMutations(config.ExportTypes, config.NullUnionSlices, config.SimplifyOmitEmpty)
ts.ApplyMutations(
config.ExportTypes,
config.NullUnionSlices,
config.SimplifyOmitEmpty,
config.EnumAsTypes,
)

if err != nil {
log.Fatalf("to typescript: %v", err)
Expand Down
21 changes: 2 additions & 19 deletions src/gen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ export interface NullHCLString {
}

// From apitypes/apitypes.go
export enum OptionType {
OptionTypeBoolean = "bool",
OptionTypeListString = "list(string)",
OptionTypeNumber = "number",
OptionTypeString = "string"
}
export type OptionType = "bool" | "list(string)" | "number" | "string";

// From preview/preview.go
export interface Output {
Expand Down Expand Up @@ -80,19 +75,7 @@ export interface ParameterData {
}

// From provider/formtype.go
export enum ParameterFormType {
ParameterFormTypeCheckbox = "checkbox",
ParameterFormTypeDefault = "",
ParameterFormTypeDropdown = "dropdown",
ParameterFormTypeError = "error",
ParameterFormTypeInput = "input",
ParameterFormTypeMultiSelect = "multi-select",
ParameterFormTypeRadio = "radio",
ParameterFormTypeSlider = "slider",
ParameterFormTypeSwitch = "switch",
ParameterFormTypeTagSelect = "tag-select",
ParameterFormTypeTextArea = "textarea"
}
export type ParameterFormType = "checkbox" | "" | "dropdown" | "error" | "input" | "multi-select" | "radio" | "slider" | "switch" | "tag-select" | "textarea";

// From types/parameter.go
export interface ParameterOption {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": false,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": false
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"files": [],
"erasableSyntaxOnly": false,
"erasableSyntaxOnly": true,
"references": [
{
"path": "./tsconfig.app.json"
Expand Down