Skip to content

chore(site): fix typegen usage #868

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 1 commit into from
Apr 4, 2022
Merged

chore(site): fix typegen usage #868

merged 1 commit into from
Apr 4, 2022

Conversation

presleyp
Copy link
Contributor

@presleyp presleyp commented Apr 4, 2022

  • I realized it's actually true that we don't know for sure what our errors are. Open to ideas about how we want to handle them (as Error, type checking as they come in, or be defensive throughout?)
  • the reason I had to defensively check whether event.type was SIGN_IN even though the typegen file knew that it was always SIGN_IN is that I had annotated event as UserEvent. The lesson is, let typegen figure out your types for you.

I updated the Code Conventions doc with info on how to use typegen.

@presleyp presleyp requested a review from a team as a code owner April 4, 2022 21:25
@presleyp presleyp self-assigned this Apr 4, 2022
@presleyp presleyp requested a review from greyscaled April 4, 2022 21:26
@codecov
Copy link

codecov bot commented Apr 4, 2022

Codecov Report

Merging #868 (f1c5316) into main (4601a35) will increase coverage by 2.15%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #868      +/-   ##
==========================================
+ Coverage   63.90%   66.05%   +2.15%     
==========================================
  Files         199      203       +4     
  Lines       11830    13226    +1396     
  Branches       87       86       -1     
==========================================
+ Hits         7560     8737    +1177     
- Misses       3442     3603     +161     
- Partials      828      886      +58     
Flag Coverage Δ
unittest-go- 65.45% <ø> (+2.38%) ⬆️
unittest-go-macos-latest 52.50% <ø> (-6.42%) ⬇️
unittest-go-ubuntu-latest 54.95% <ø> (-6.87%) ⬇️
unittest-go-windows-2022 51.84% <ø> (-6.24%) ⬇️
unittest-js 62.70% <100.00%> (+0.06%) ⬆️
Impacted Files Coverage Δ
site/src/xServices/user/userXService.ts 81.81% <100.00%> (+6.81%) ⬆️
coderd/httpmw/userparam.go 51.85% <0.00%> (-24.82%) ⬇️
pty/start_other.go 64.70% <0.00%> (-23.53%) ⬇️
cli/cliui/prompt.go 71.60% <0.00%> (-7.57%) ⬇️
codersdk/users.go 65.38% <0.00%> (-3.04%) ⬇️
coderd/parameters.go 63.04% <0.00%> (-2.35%) ⬇️
peer/channel.go 83.04% <0.00%> (-2.34%) ⬇️
coderd/httpmw/organizationparam.go 68.00% <0.00%> (-1.82%) ⬇️
cli/parameters.go 16.07% <0.00%> (-0.30%) ⬇️
coderd/users.go 57.41% <0.00%> (ø)
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4601a35...f1c5316. Read the comment docs.

Copy link
Contributor

@greyscaled greyscaled left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the investigation and write-up and updating the conventions. Really thorough stuff!

@@ -3,7 +3,7 @@ import * as Types from "../../api/types"
import * as API from "../../api"

export interface UserContext {
getUserError?: Error | unknown // unknown is a concession while I work out typing issues
getUserError?: Error | unknown
Copy link
Contributor

Choose a reason for hiding this comment

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

Open Question: Maybe this is something we talk about at FE V or down the line; I am documenting it just for completion. I'm wondering if we will strategize around discerning errors using predicates:

const isUserError = (e: any): e is UserError => {
  // ...
}

If so, we might want to associate errors with types in some meaningful way and logically group these predicates. I'll want to think on that architecturally speaking with you, and I do not feel compelled to make a quick decision yet, as we're OK right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding to FE V!

@presleyp presleyp merged commit 63b4006 into main Apr 4, 2022
@presleyp presleyp deleted the presleyp/typegen branch April 4, 2022 22:02
@misskniss misskniss added this to the V2 Beta milestone May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants