Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: strong type for getFormHelpers name#1029

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
greyscaled merged 1 commit intomainfromvapurrmaid/getFormHelpers
Apr 15, 2022

Conversation

greyscaled
Copy link
Contributor

@greyscaledgreyscaled commentedApr 15, 2022
edited
Loading

Summary:

ModifygetFormHelpers so that only the keys of the generic form interface
can be passed in forname.

Details:

Keys of an object in TS can naturally be ofstring | number | symbol. I don't think
there's an easy way to re-genericize this helper and type things that gets around this,
so I took the simple path of throwing anError ontypeof !== "string".

Impact:

Minor improvement to dev experience usinggetFormHelpers (compile-time safety).

@greyscaledgreyscaled requested a review froma team as acode ownerApril 15, 2022 17:31
@greyscaledgreyscaled self-assigned thisApr 15, 2022
@codecov
Copy link

codecovbot commentedApr 15, 2022
edited
Loading

Codecov Report

Merging#1029 (b007377) intomain (88e30be) willdecrease coverage by0.22%.
The diff coverage is33.33%.

@@            Coverage Diff             @@##             main    #1029      +/-   ##==========================================- Coverage   67.54%   67.32%   -0.23%==========================================  Files         259      259                Lines       15059    15061       +2       Branches      151      152       +1     ==========================================- Hits        10172    10140      -32- Misses       3873     3899      +26- Partials     1014     1022       +8
FlagCoverage Δ
unittest-go-macos-latest53.58% <ø> (-0.24%)⬇️
unittest-go-postgres-66.53% <ø> (-0.12%)⬇️
unittest-go-ubuntu-latest56.12% <ø> (-0.28%)⬇️
unittest-go-windows-202252.98% <ø> (-0.03%)⬇️
unittest-js68.10% <33.33%> (-0.10%)⬇️
Impacted FilesCoverage Δ
site/src/components/Form/index.ts89.47% <33.33%> (-10.53%)⬇️
pty/start_other.go64.70% <0.00%> (-23.53%)⬇️
peerbroker/dial.go77.04% <0.00%> (-6.56%)⬇️
cli/cliui/agent.go77.19% <0.00%> (-5.27%)⬇️
peer/conn.go76.14% <0.00%> (-5.08%)⬇️
coderd/parameter/compute.go74.07% <0.00%> (-4.45%)⬇️
cli/cliui/provisionerjob.go76.42% <0.00%> (-2.15%)⬇️
coderd/provisionerdaemons.go62.95% <0.00%> (-1.03%)⬇️
coderd/database/queries.sql.go83.65% <0.00%> (-0.21%)⬇️
provisioner/terraform/provision.go68.54% <0.00%> (+0.43%)⬆️
... and2 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update88e30be...b007377. Read thecomment docs.

// getIn is a util function from Formik that gets at any depth of nesting, and is necessary for the types to work
export const getFormHelpers = <T>(form: FormikContextType<T>, name: keyof T, error?: string): FormHelpers => {
if (typeof name !== "string") {
throw new Error(`name must be type of string, instead received '${typeof name}'`)
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if somehow this gets thrown in production?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

That's a desirable case at this stage. We don't yet have an error boundary ported (#1013 ), but you'd hit that.

@greyscaledgreyscaled merged commitcf8a20d intomainApr 15, 2022
@greyscaledgreyscaled deleted the vapurrmaid/getFormHelpers branchApril 15, 2022 20:31
@missknissmisskniss added this to theV2 Beta milestoneMay 15, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@presleyppresleyppresleyp approved these changes

Assignees

@greyscaledgreyscaled

Labels
None yet
Projects
None yet
Milestone
V2 Beta
Development

Successfully merging this pull request may close these issues.

3 participants
@greyscaled@presleyp@misskniss

[8]ページ先頭

©2009-2025 Movatter.jp