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

fix(types): improve typing #339

Merged
merged 5 commits into from
Jan 13, 2024
Merged

fix(types): improve typing #339

merged 5 commits into from
Jan 13, 2024

Conversation

thib3113
Copy link
Collaborator

@thib3113 thib3113 commented Oct 3, 2023

The array property unique was missing from the RuleArray definition


I've done mutiples modifications in the index.d.ts :

  • add 2 missing ValidationRuleName
  • add misssing properties on array ( unique and convert )
  • removing some useless "default null" (all other values without default value doesn't have a default)
  • add default to mode (quick), and correct the default of empty to match doc
  • some reorder to match the documentation
  • harmonize jsdoc

@thib3113 thib3113 marked this pull request as draft October 3, 2023 13:17
@thib3113 thib3113 marked this pull request as ready for review October 3, 2023 16:19
@thib3113 thib3113 changed the title unique property seems missing from typing fix(types): improve typing Oct 3, 2023
@thib3113 thib3113 marked this pull request as draft October 4, 2023 13:10
@thib3113
Copy link
Collaborator Author

thib3113 commented Oct 5, 2023

I found other problems on typing, I will try to check this .

getRuleFromSchema => typing say it only allow ValidationRuleName | ValidationRuleName[] | { [key: string]: unknown }, but seems to be used with schema, and Array of schema, so maybe we can add ValidationSchema | ValidationSchema[]


typescript doesn't work when imported by ESM typescript ( typescript think you are exporting a value "default" ) .

Actually I can fix this on client side by doing :

import Validator, { default as ValidatorDefault } from 'fastest-validator';

type ValidatorType = ValidatorDefault.default;

const v = new (Validator as unknown as new (opts?: ValidatorConstructorOptions) => ValidatorType)();

but not really clean, I need to investigate more on this

@thib3113
Copy link
Collaborator Author

thib3113 commented Oct 6, 2023

More problems :

Class.instanceOf seems mandatory ( else schema.instanceOf.name produce an error )

Copy link
Owner

@icebob icebob left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@thib3113
Copy link
Collaborator Author

thib3113 commented Oct 8, 2023

@icebob, I will wait a little to set this ready for review, because I sometimes find another problems (like some minutes before), So if I found another typescript errors, I will add them here

@thib3113 thib3113 marked this pull request as ready for review October 9, 2023 16:16
@thib3113
Copy link
Collaborator Author

@icebob any update on this ?

@icebob icebob merged commit a6bfdc7 into icebob:master Jan 13, 2024
5 checks passed
@icebob
Copy link
Owner

icebob commented Jan 13, 2024

Thanks, sorry for late.

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.

2 participants