Skip to content

Commit 55337e5

Browse files
committed
yay
1 parent 68a1b10 commit 55337e5

File tree

5 files changed

+1270
-1718
lines changed

5 files changed

+1270
-1718
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
601601
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
602602
go run ./scripts/apitypings/ > $@
603603
./scripts/pnpm_install.sh
604-
pnpm exec prettier --write "$@"
605604

606605
site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
607606
cd site
@@ -611,7 +610,7 @@ site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisio
611610
site/src/theme/icons.json: $(wildcard scripts/gensite/*) $(wildcard site/static/icon/*)
612611
go run ./scripts/gensite/ -icons "$@"
613612
./scripts/pnpm_install.sh
614-
pnpm exec prettier --write "$@"
613+
pnpm -C site/ exec biome format --write src/theme/icons.json
615614

616615
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
617616
go run ./scripts/examplegen/main.go > examples/examples.gen.json

offlinedocs/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"@chakra-ui/react": "2.8.2",
1717
"@emotion/react": "11.11.4",
1818
"@emotion/styled": "11.11.5",
19-
"@types/lodash": "4.14.196",
2019
"archiver": "6.0.2",
2120
"framer-motion": "^10.17.6",
2221
"front-matter": "4.0.2",
@@ -36,7 +35,7 @@
3635
"@types/react-dom": "18.3.0",
3736
"eslint": "8.56.0",
3837
"eslint-config-next": "14.0.1",
39-
"prettier": "3.1.0",
38+
"prettier": "3.3.3",
4039
"typescript": "5.3.2"
4140
},
4241
"engines": {

scripts/apitypings/main.go

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var (
3939
// CLI option types:
4040
"github.com/coder/serpent",
4141
}
42-
indent = " "
42+
indent = "\t"
4343
)
4444

4545
func main() {
@@ -646,7 +646,7 @@ func (g *Generator) buildStruct(obj types.Object, st *types.Struct) (string, err
646646
// Just append these as fields. We should fix this later.
647647
state.Fields = append(state.Fields, tsType.AboveTypeLine)
648648
}
649-
state.Fields = append(state.Fields, fmt.Sprintf("%sreadonly %s%s: %s", indent, jsonName, optional, valueType))
649+
state.Fields = append(state.Fields, fmt.Sprintf("%sreadonly %s%s: %s;", indent, jsonName, optional, valueType))
650650
}
651651

652652
// This is implemented to ensure the correct order of generics on the
@@ -759,12 +759,8 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
759759
// }
760760
// }
761761
return TypescriptType{
762-
ValueType: "any",
763-
AboveTypeLine: fmt.Sprintf("%s\n%s",
764-
indentedComment("Embedded anonymous struct, please fix by naming it"),
765-
// Linter needs to be disabled here, or else it will complain about the "any" type.
766-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- Anonymously embedded struct"),
767-
),
762+
ValueType: "unknown",
763+
AboveTypeLine: indentedComment("Embedded anonymous struct, please fix by naming it"),
768764
}, nil
769765
case *types.Map:
770766
// map[string][string] -> Record<string, string>
@@ -815,16 +811,11 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
815811
}
816812
genValue := ""
817813

818-
// Always wrap in parentheses for proper scoped types.
819-
// Running prettier on this output will remove redundant parenthesis,
820-
// so this makes our decision-making easier.
821-
// The example that breaks without this is:
822-
// readonly readonly string[][]
823814
if underlying.GenericValue != "" {
824-
genValue = "(readonly " + underlying.GenericValue + "[])"
815+
genValue = "Readonly<Array<" + underlying.GenericValue + ">>"
825816
}
826817
return TypescriptType{
827-
ValueType: "(readonly " + underlying.ValueType + "[])",
818+
ValueType: "Readonly<Array<" + underlying.ValueType + ">>",
828819
GenericValue: genValue,
829820
AboveTypeLine: underlying.AboveTypeLine,
830821
GenericTypes: underlying.GenericTypes,
@@ -969,11 +960,10 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
969960
// You can handle your type manually in the switch list above, otherwise "any" will be used.
970961
// An easy way to fix this is to pull your external type into `codersdk` package, then it will
971962
// be known by the generator.
972-
return TypescriptType{ValueType: "any", AboveTypeLine: fmt.Sprintf("%s\n%s",
973-
indentedComment(fmt.Sprintf("Named type %q unknown, using \"any\"", n.String())),
974-
// Linter needs to be disabled here, or else it will complain about the "any" type.
975-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type"),
976-
)}, nil
963+
return TypescriptType{
964+
ValueType: "unknown",
965+
AboveTypeLine: indentedComment(fmt.Sprintf("Named type %q unknown, using \"unknown\"", n.String())),
966+
}, nil
977967
}
978968

979969
// Defer to the underlying type.
@@ -1002,21 +992,16 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
1002992
// This field is 'interface{}'. We can't infer any type from 'interface{}'
1003993
// so just use "any" as the type.
1004994
return TypescriptType{
1005-
ValueType: "any",
1006-
AboveTypeLine: fmt.Sprintf("%s\n%s",
1007-
indentedComment("Empty interface{} type, cannot resolve the type."),
1008-
// Linter needs to be disabled here, or else it will complain about the "any" type.
1009-
indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- interface{}"),
1010-
),
995+
ValueType: "unknown",
996+
AboveTypeLine: indentedComment("Empty interface{} type, cannot resolve the type."),
1011997
}, nil
1012998
}
1013999

10141000
// Interfaces are difficult to determine the JSON type, so just return
1015-
// an 'any'.
1001+
// an 'unknown'.
10161002
return TypescriptType{
1017-
ValueType: "any",
1018-
AboveTypeLine: indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- Golang interface, unable to resolve type."),
1019-
Optional: false,
1003+
ValueType: "unknown",
1004+
Optional: false,
10201005
}, nil
10211006
case *types.TypeParam:
10221007
_, ok := ty.Underlying().(*types.Interface)

site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
"jest-websocket-mock": "2.5.0",
151151
"jest_workaround": "0.1.14",
152152
"msw": "2.2.3",
153-
"prettier": "3.1.0",
153+
"prettier": "3.3.3",
154154
"protobufjs": "7.2.5",
155155
"rxjs": "7.8.1",
156156
"ssh2": "1.15.0",

0 commit comments

Comments
 (0)