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

Filter by extension

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
chore: handle interfaces as "any" in typescript
Use generated Deployment Option
  • Loading branch information
Emyrk committed Sep 28, 2023
commit 50d9fdfce7ec728b4698aeb1d71502868dc2cc1f
29 changes: 7 additions & 22 deletions scripts/apitypings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,28 +989,13 @@ func (g *Generator) typescriptType(ty types.Type) (TypescriptType, error) {
}, nil
}

// Do support "Stringer" interfaces, they likely can get string
// marshaled.
for i := 0; i < intf.NumMethods(); i++ {
meth := intf.Method(i)
if meth.Name() == "String" {
return TypescriptType{
ValueType: "string",
AboveTypeLine: indentedComment("actual value is an interface that implements 'String()'"),
Optional: false,
}, nil
}
}

// All complex interfaces should be named. So if we get here, that means
// we are using anonymous interfaces. Which is just weird and not supported.
// Example:
// type Foo struct {
// Bar interface {
// Baz() string
// }
// }
return TypescriptType{}, xerrors.New("only empty interface types are supported")
// Interfaces are difficult to determine the JSON type, so just return
// an 'any'.
return TypescriptType{
ValueType: "any",
AboveTypeLine: indentedComment("eslint-disable-next-line @typescript-eslint/no-explicit-any -- Golang interface, unable to resolve type."),
Optional: false,
}, nil
case *types.TypeParam:
_, ok := ty.Underlying().(*types.Interface)
if !ok {
Expand Down
13 changes: 1 addition & 12 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,21 +1024,10 @@ export interface DeploymentGroup {
readonly description: string;
readonly children: DeploymentGroup[];
}
export interface DeploymentOption {
readonly name: string;
readonly description: string;
readonly flag: string;
readonly flag_shorthand: string;
readonly value: unknown;
readonly hidden: boolean;
readonly group?: DeploymentGroup;
readonly env?: string;
readonly yaml?: string;
}

export type DeploymentConfig = {
readonly config: TypesGen.DeploymentValues;
readonly options: DeploymentOption[];
readonly options: TypesGen.ClibaseOption[];
};

export const getDeploymentConfig = async (): Promise<DeploymentConfig> => {
Expand Down
4 changes: 2 additions & 2 deletions site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions site/src/components/DeploySettingsLayout/OptionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import {
} from "components/DeploySettingsLayout/Option";
import { FC } from "react";
import { optionValue } from "./optionValue";
import { DeploymentOption } from "api/api";
import Box from "@mui/material/Box";

const OptionsTable: FC<{
options: DeploymentOption[];
options: ClibaseOption[];
}> = ({ options }) => {
const styles = useStyles();

Expand Down