Comments (2)
Yes, you are right. The odd part is, I was a bit sure that I got this issue after the upgrade but seems like I got the timeline wrong 😓 I have downgraded the versions on the minimal repo, and it is still reproducible.
I have tracked down to this point
export function createForm<TFieldValues extends FieldValues>(props: {
initialValues?: FormOptions<TFieldValues>['initialValues'];
}) {
const scope = createFormModular<TFieldValues>({
initialValues: props.initialValues,
});
return scope;
}
If I comment out the return line in this function, there's no CPU issue. But when I return scope
from the function, then the TS Server goes crazy.
After converting the function as the same in the type definition file, problem gone. However, if I don't specify the return type manually, it still causes TS server issue, strange.
Final trial
export function createForm<TFieldValues extends FieldValues, TResponseData extends ResponseData = undefined>(options?: FormOptions<TFieldValues>): [
FormStore<TFieldValues, TResponseData>,
{
Form: (props: Omit<FormProps<TFieldValues, TResponseData>, 'of'>) => JSX.Element;
Field: <TFieldName extends FieldPath<TFieldValues>>(props: FieldPathValue<TFieldValues, TFieldName> extends MaybeValue<string> ? PartialKey<Omit<FieldProps<TFieldValues, TResponseData, TFieldName>, 'of'>, 'type'> : Omit<FieldProps<TFieldValues, TResponseData, TFieldName>, 'of'>) => JSX.Element;
FieldArray: <TFieldArrayName extends FieldArrayPath<TFieldValues>>(props: Omit<FieldArrayProps<TFieldValues, TResponseData, TFieldArrayName>, 'of'>) => JSX.Element;
}
] {
const scope = createFormModular<TFieldValues, TResponseData>(options);
return scope;
}
The main point of doing this is to create a reusable facilitator function that creates a form but with a bit of sugar to trigger the validate function when the lang/language gets a reactive update.
Since the above version solves the issue, I guess it is safe to close the issue.
Thank you for leading it to double-check @fabian-hiller 🙏🏻
from valibot.
Does this problem still occur when you restart your computer? Are you sure it did not happen with the previous version? Can you double check? I do not think this is related to our source code.
from valibot.
Related Issues (20)
- "Unsafe assignment of an `any` value" for pipe method HOT 1
- `ObjectSchema` does not satisfy predefined type (v.0.31) HOT 2
- Add a fallback override for `pipe` method to accept unlimited pipe items HOT 19
- Conditionally validate using pipes HOT 2
- Questions on how to proceed HOT 4
- Custom (runtime) error message HOT 6
- Issue with enums HOT 5
- Date validation default error message HOT 7
- Suggestion to Use nil Instead of null_ for Primitive Value HOT 5
- Bi-directional encoding/decoding HOT 5
- TypeScript compile fails HOT 5
- (Re-)Add support for zods `.default` method HOT 5
- How to know if a custom error message was given? HOT 12
- Edge case bug with JSR version HOT 1
- Discord HOT 5
- [bug] Decimal schema is expecting null HOT 2
- [suggestion]: mimeType wildcard support HOT 2
- Missing TS warning in `pipe` method
- Typescript: Incompatible Index Signatures HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from valibot.