Skip to content

Fix types generated for WorkspaceResource "type" field  #3767

Closed as not planned
@jsjoeio

Description

@jsjoeio

Problem

While working on #3754, I realized our types are a bit loose. On the frontend, we have a small set of possibilities listed here:

https://github.com/coder/coder/blob/main/site/src/components/Resources/ResourceAvatar.tsx#L16-L25

If this is the case, our generated types should use a union of strings instead of string. This will lead to safer code

Solution

Modify https://github.com/coder/coder/blob/main/codersdk/workspaceresources.go#L28 to be a limited subset of strings similar to what we do for BuildReason here:

https://github.com/coder/coder/blob/main/codersdk/workspacebuilds.go#L22-L34

Checklist

  • Modify Go types
  • Generate new TS types
  • Use on frontend

Metadata

Metadata

Assignees

Labels

apiArea: HTTP API

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions