-
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Field components should now infer state.value properly
* chore: refactor TS typings for React * fix: field should now infer state.value properly in React adapter * chore: fix Vue package typings * chore: fix linting * chore: fix React adapter * chore: improve performance of TData type in FieldApi * chore: add back index and parent type * chore: add Vue TSC dep on Vue example * chore: fix lint and type test * chore: update Vite stuff * chore: add implicit dep for Vue and React examples * chore: add type test pre-req * chore: install deps from examples in PR CI * chore: remove filter from more installation
- Loading branch information
1 parent
b5a768f
commit 160f712
Showing
14 changed files
with
425 additions
and
516 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -22,7 +22,7 @@ jobs: | |
node-version: 18.15.0 | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm --filter "./packages/**" --filter form --prefer-offline install --no-frozen-lockfile | ||
run: pnpm --prefer-offline install --no-frozen-lockfile | ||
- name: Run Tests | ||
uses: nick-fields/[email protected] | ||
with: | ||
|
@@ -48,7 +48,7 @@ jobs: | |
node-version: 16.14.2 | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm --filter "./packages/**" --filter form --prefer-offline install --no-frozen-lockfile | ||
run: pnpm --prefer-offline install --no-frozen-lockfile | ||
- run: pnpm run test:eslint --base=${{ github.event.pull_request.base.sha }} | ||
typecheck: | ||
name: 'Typecheck' | ||
|
@@ -67,7 +67,7 @@ jobs: | |
node-version: 16.14.2 | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm --filter "./packages/**" --filter form --prefer-offline install --no-frozen-lockfile | ||
run: pnpm --prefer-offline install --no-frozen-lockfile | ||
- run: pnpm run test:types --base=${{ github.event.pull_request.base.sha }} | ||
format: | ||
name: 'Format' | ||
|
@@ -86,7 +86,7 @@ jobs: | |
node-version: 16.14.2 | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm --filter "./packages/**" --filter form --prefer-offline install --no-frozen-lockfile | ||
run: pnpm --prefer-offline install --no-frozen-lockfile | ||
- run: pnpm run test:format --base=${{ github.event.pull_request.base.sha }} | ||
test-build: | ||
name: 'Test Build' | ||
|
@@ -105,7 +105,7 @@ jobs: | |
node-version: 16.14.2 | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm --filter "./packages/**" --filter form --prefer-offline install --no-frozen-lockfile | ||
run: pnpm --prefer-offline install --no-frozen-lockfile | ||
- name: Get appropriate base and head commits for `nx affected` commands | ||
uses: nrwl/nx-set-shas@v3 | ||
with: | ||
|
This file contains 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 contains 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 contains 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 contains 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 contains 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 contains 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,63 @@ | ||
import { assertType } from 'vitest' | ||
import * as React from 'react' | ||
import { useForm } from '../useForm' | ||
|
||
it('should type state.value properly', () => { | ||
function Comp() { | ||
const form = useForm({ | ||
defaultValues: { | ||
firstName: 'test', | ||
age: 84, | ||
}, | ||
} as const) | ||
|
||
return ( | ||
<form.Provider> | ||
<form.Field | ||
name="firstName" | ||
children={(field) => { | ||
assertType<'test'>(field.state.value) | ||
}} | ||
/> | ||
<form.Field | ||
name="age" | ||
children={(field) => { | ||
assertType<84>(field.state.value) | ||
}} | ||
/> | ||
</form.Provider> | ||
) | ||
} | ||
}) | ||
|
||
it('should type onChange properly', () => { | ||
function Comp() { | ||
const form = useForm({ | ||
defaultValues: { | ||
firstName: 'test', | ||
age: 84, | ||
}, | ||
} as const) | ||
|
||
return ( | ||
<form.Provider> | ||
<form.Field | ||
name="firstName" | ||
onChange={(val) => { | ||
assertType<'test'>(val) | ||
return null | ||
}} | ||
children={(field) => null} | ||
/> | ||
<form.Field | ||
name="age" | ||
onChange={(val) => { | ||
assertType<84>(val) | ||
return null | ||
}} | ||
children={(field) => null} | ||
/> | ||
</form.Provider> | ||
) | ||
} | ||
}) |
Oops, something went wrong.