faker-js / faker

Generate massive amounts of fake data in the browser and node.js
https://fakerjs.dev
Other
12.36k stars 892 forks source link

Extend Docs to Describe Expected Usage with TypeScript #3006

Open xDivisionByZerox opened 1 month ago

xDivisionByZerox commented 1 month ago

[!NOTE] The updated requirements for the issues can be found in this comment.

Pre-Checks

Describe the bug

In a project where TypeScript is not configured to run in strict mode, the function faker.helpers.arrayElement can be called with null and undefined, which leads to errors during runtime.

Minimal reproduction code

https://stackblitz.com/edit/faker-js-demo-c67mtj?file=index.ts

Additional Context

This might be true for ALL functions, as null is assignable to everything in non-strict mode.

Environment Info

-

Which module system do you use?

Used Package Manager

pnpm

ST-DDT commented 1 month ago

IMO we clearly define our needs/requirements. If you choose to ignore them using js, non strict ts or unsafe casts, then you are on your own.

xDivisionByZerox commented 1 month ago

IMO we clearly define our needs/requirements. If you choose to ignore them using js, non strict ts or unsafe casts, then you are on your own.

I don't know if I agree with this statement, especially since TypeScripts default is still non-strict mode.

ST-DDT commented 1 month ago

Team Decision

AmaanRS commented 1 week ago

Can you please explain to me what exactly do i have to do, like do i have to types for this ?

xDivisionByZerox commented 1 week ago

@AmaanRS I'm not sure if I understand correctly. Are you asking for the tasks to do to work on the issue? 🤔

ST-DDT commented 1 week ago

Can you please explain to me what exactly do i have to do, like do i have to types for this ?

@AmaanRS This is a documentation task, so it doesn't need any code changes.


@xDivisionByZerox I'm not exactly sure what should be done for this issue either. Could you please explain what documentation do you want where?

xDivisionByZerox commented 1 week ago

@xDivisionByZerox I'm not exactly sure what should be done for this issue either. Could you please explain what documentation do you want where?

Of couse. IMO the TypeScript section of our docs should add a note box hinting the user that using faker without (TS) strict mode might lead to unexpected behaviour which will not be worked around from our side.