8000 fix: update `DeleteWorkspaceOptions` to pick properties correctly by Parkreiner · Pull Request #13423 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

fix: update DeleteWorkspaceOptions to pick properties correctly #13423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 31, 2024

Conversation

Parkreiner
Copy link
Member
@Parkreiner Parkreiner commented May 31, 2024

Found this while writing the docs for the Backstage Coder SDK:

export type DeleteWorkspaceOptions = Pick<
  TypesGen.CreateWorkspaceBuildRequest,
  "log_level" & "orphan"
>;

It's literally a single character difference, but the second Pick argument should be:

"log_level" | "orphan"

Changes made

  • Changed the & to a |
  • Updated one of the calls to the deletion method to fix a typo that was being allowed because of the incorrect type
  • Updated one the test files to use the correct property format

Explanation

With the &, you have an intersection instead of a union. Basically, that says "give me a type that is both the literal "log_level" and the literal "orphan" at the same time". It's impossible for a value to be two different things at the exact same time, so the resulting type is never. When you pick never from an object, you pick nothing, so the ultimate resulting type is the type {} (which is equivalent to Nonullable<unknown>). Nonullable<unknown> isn't much better than an any type – it's basically any, but with null and undefined removed

@Parkreiner Parkreiner self-assigned this May 31, 2024
Copy link
@cdr-bot cdr-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is a hotfix and has been automatically approved.

  • ✅ Base is main
  • ✅ Has hotfix label
  • ✅ Head is from coder/coder
  • ✅ Less than 100 lines

@Parkreiner Parkreiner enabled auto-merge (squash) May 31, 2024 03:26
@Parkreiner Parkreiner disabled auto-merge May 31, 2024 03:59
@matifali
Copy link
Member
matifali commented May 31, 2024

@Parkreiner could it be related to #13257.
I am not able to delete workspaces for a while.

@Parkreiner
Copy link
Member Author
Parkreiner commented May 31, 2024

@matifali I haven't had the chance to touch the backend part of Coder core yet (I still need to learn Go), so I'm not 100% sure. My gut feeling, though, is that it wouldn't affect things too much

The client-side function takes the ID of a workspace, and an optional options object. This PR only affects that options object, and while incorrect properties were getting added to it, I would expect the server to just filter those out. The object has no required properties

@Parkreiner Parkreiner merged commit 19530c6 into main May 31, 2024
31 checks passed
@Parkreiner Parkreiner deleted the mes/delete-type-fix branch May 31, 2024 14:24
@github-actions github-actions bot locked and limited conversation to collaborators May 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0