Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testTimeout: process.env.JEST_TIMEOUT
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nice for debugging

? parseInt(process.env.JEST_TIMEOUT)
: undefined,
testEnvironment: "jsdom",
testPathIgnorePatterns: ["utils", "lib"],
restoreMocks: true,
Expand Down
9 changes: 7 additions & 2 deletions src/FieldContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export function FieldContextProvider({
);
}

export function useMaybeFieldName() {
Copy link
Collaborator Author

@scamden scamden Jul 18, 2023

Choose a reason for hiding this comment

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

let us automatically derive the name from context if there are any Fields already provided above us

const context = useContext(FieldContext);
return context?.name;
}

function useContextProt(name: string) {
const context = useContext(FieldContext);
if (!context)
Expand Down Expand Up @@ -106,7 +111,7 @@ export function useTsController<FieldType extends any>() {
? DeepPartial<FieldType> | undefined
: FieldType | undefined;
// Just gives better types to useController
const controller = useController(context) as any as Omit<
const controller = useController(context) as unknown as Omit<
UseControllerReturn,
"field"
> & {
Expand Down Expand Up @@ -471,4 +476,4 @@ export function useNumberFieldInfo() {
},
"useNumberFieldInfo"
);
}
}
Loading