feat(types): add types file#2398
feat(types): add types file#2398rubiin wants to merge 8 commits intovalidatorjs:masterfrom rubiin:types
Conversation
|
Having types file here will make sure the types and codebase are in sync. |
|
LGTM. Could you please also add some guidelines on how to use, on the README? Perhaps adding a section for Types? |
|
Sure thing. I will update the readme for this |
|
Since the types get installed along with the library, there is no need to install @types/validator package anymore for typescript support. I have added a small section on readme for that but we should also point this on the realease notes @profnandaa |
+1 for this one, I've been checking the latest |
|
Yeah . Since we have types file here , we dont have to depend on the @types/ packages . They can be slow and outdated so self managing is a better option |
pano9000
left a comment
There was a problem hiding this comment.
not a TypeScript expert, so not sure, what is usually preferred: one huge file or several smaller ones - but just from a gut feeling, I think it might be easier to many smaller ones, instead of one huge one?
The DefinitelyTyped version was also going with many small files, from what I can see.
but feel free to diregard my comment, if in TS world things are handled differently
Co-authored-by: Panagiotis Papadopoulos <[email protected]>
|
For now we can ship this and on later date , break it down on smaller files. |
| /** | ||
| * Check if the string is a valid [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) officially assigned currency code. | ||
| */ | ||
| export function isISO4217(str: string): boolean; |
There was a problem hiding this comment.
Please run a formatter like prettier on this file, so it is formatted consistently and I don't have to comment on those parts.
There was a problem hiding this comment.
If you resolve my comments without actually changing anything, please at least tell me why.
There was a problem hiding this comment.
@rubiin can you take another look at the comments by @ST-DDT ? Also the resolved ones.
You can add index.d.ts to the list that is being linted by https://github.com/validatorjs/validator.js/blob/master/package.json#L58-L59
There was a problem hiding this comment.
sure thing will do sometime later
Co-authored-by: ST-DDT <[email protected]>
There was a problem hiding this comment.
You need to provide a "types" field in the package.json for the types to actually work. Checkout the TypeScript Handbook regarding that topic.
There was a problem hiding this comment.
Good catch, will update it asap
This PR adds types file within the repo itself .
The types file is derived from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/validator
with some modifications
Checklist