Skip to content
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

chore: add typecheck and fix type #633

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lifeiscontent
Copy link
Contributor

No description provided.

Comment on lines +3 to +7
{ "path": "./packages/conform-dom" },
{ "path": "./packages/conform-yup" },
{ "path": "./packages/conform-zod" },
{ "path": "./packages/conform-react" },
{ "path": "./packages/conform-validitystate" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@edmundhung both of these work, but now if we ctrl+click the paths in vscode they goto the file

@@ -14,7 +14,7 @@ export type SubmissionState = {
validated: Record<string, boolean>;
};

export type SubmissionContext<Value = null, FormError = string[]> = {
export type SubmissionContext<Value = unknown, FormError = string[]> = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

null here seems wrong because when running tests the value property isn't even set via parse

@@ -83,7 +71,7 @@ type SubfieldMetadata<
Schema,
FormSchema extends Record<string, any>,
FormError,
> = [Schema] extends [Primitive]
> = [Schema] extends [Primitive | Date | File]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@edmundhung this seems to be the only place Primitive is being used, whats the intent for overloading the term "Primitive" here with Date and File?

maybe another term like FormValue or something along those lines might be better here

Copy link
Owner

@edmundhung edmundhung left a comment

Choose a reason for hiding this comment

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

Can you share some context the usecase with the typecheck script? A lot of the changes here seems styling changes only.

@@ -623,7 +623,7 @@ function shouldNotify<Schema>(
return false;
}

export function createFormContext<
Copy link
Owner

Choose a reason for hiding this comment

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

What does this helps comparing to setting an alias on the entry file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you as the author know its unstable, but as the contributor I might not if I don't look at the export boundary (index) that I would read this as stable code

@@ -18,12 +18,13 @@
},
"scripts": {
"build:js": "rollup -c",
"build:ts": "tsc",
"build:ts": "tsc --emitDeclarationOnly",
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need to remove emitDeclarationOnly from the tsconfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when running tsc with --noEmit and --emitDeclarationOnly is set in the tsconfig, tsc throws an error saying only one can be set at a time.

Comment on lines -275 to -292
get getFieldset() {
return () =>
new Proxy({} as any, {
get(target, key, receiver) {
if (typeof key === 'string') {
return getFieldMetadata(
context,
subjectRef,
stateSnapshot,
name,
key,
);
}

return Reflect.get(target, key, receiver);
},
});
},
Copy link
Owner

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@edmundhung based off the type it says getFieldset doesn't exist so I removed it to see if tests would still pass I can revert, but we should probably update the types too

Comment on lines +300 to +302
// eslint-disable-next-line react-hooks/rules-of-hooks
const [value, setValue] = useInputValue(meta);
// eslint-disable-next-line react-hooks/rules-of-hooks
Copy link
Owner

Choose a reason for hiding this comment

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

Err.. why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the name of the function doesn't start with use it complains, I'm not sure what remix team does with thier unstable APIs to get around this but I could look into it. I'm guessing they might have lint rules turned off for things marked as unstable_

@lifeiscontent
Copy link
Contributor Author

@edmundhung besides the revert of getFieldset, is there anything else you'd like me to address in this PR before getting it merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants