-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[No QA] [TS Migration] FormActions lib #26883
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
stitesExpensify
merged 26 commits into
Expensify:main
from
kubabutkiewicz:ts-migration/FormActions
Nov 7, 2023
Merged
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
63f5ae0
ref: migrate to Typescript
kubabutkiewicz fcf1055
ref: added utility types
kubabutkiewicz 4ef760a
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz e435192
ref: added TODO comments
kubabutkiewicz 7d3bf5b
fix: removed JS file
kubabutkiewicz b7ae419
fix: fix setDraftValues type
kubabutkiewicz 3bf1d01
fix: removed unnecessary type
kubabutkiewicz 3488e84
fix: fixed draftValues type
kubabutkiewicz 116173f
Merge branch 'main' into ts-migration/FormActions
kubabutkiewicz 5cbbd99
Merge branch 'main' into ts-migration/FormActions
kubabutkiewicz e4fdf7c
fix: fixed TS errors
kubabutkiewicz 94e14b1
fix: added custom status key to onyx
kubabutkiewicz e17e39a
fix: finnaly add correct types
kubabutkiewicz e8f65c5
fix: removed unwanted file
kubabutkiewicz 0f56a23
Merge branch 'main' into ts-migration/FormActions
kubabutkiewicz 0c585ea
fix: added draft eqivalents of form keys
kubabutkiewicz e4b4256
fix: wip
kubabutkiewicz e7fbcb3
Fix setDraftValues types
fabioh8010 cbb57cc
chore: fix tests
kubabutkiewicz 8727835
chore: fix tests
kubabutkiewicz c173745
fix: resolve comments
kubabutkiewicz 2c361a6
Merge branch 'main' into ts-migration/FormActions
kubabutkiewicz 7690fd6
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz 575c207
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz d5daf2d
fix: linter
kubabutkiewicz 1afc78a
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import {KeyValueMapping} from 'react-native-onyx/lib/types'; | ||
import {PartialDeep} from 'type-fest'; | ||
import {OnyxFormKey} from '../../ONYXKEYS'; | ||
import {Form} from '../../types/onyx'; | ||
import * as OnyxCommon from '../../types/onyx/OnyxCommon'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
type ExcludeDraft<T> = T extends `${infer R}Draft` ? never : T; | ||
type OnyxFormKeyWithoutDraft = ExcludeDraft<OnyxFormKey>; | ||
|
||
function setIsLoading(formID: OnyxFormKey, isLoading: boolean) { | ||
Onyx.merge(formID, {isLoading} satisfies Form); | ||
} | ||
|
||
function setErrors(formID: OnyxFormKey, errors: OnyxCommon.Errors) { | ||
Onyx.merge(formID, {errors} satisfies Form); | ||
} | ||
|
||
function setErrorFields(formID: OnyxFormKey, errorFields: OnyxCommon.ErrorFields) { | ||
Onyx.merge(formID, {errorFields} satisfies Form); | ||
} | ||
|
||
function setDraftValues<T extends OnyxFormKeyWithoutDraft>(formID: T, draftValues: PartialDeep<KeyValueMapping[`${T}Draft`]>) { | ||
Onyx.merge(`${formID}Draft`, draftValues); | ||
} | ||
|
||
export {setDraftValues, setErrorFields, setErrors, setIsLoading}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.