faker icon indicating copy to clipboard operation
faker copied to clipboard

Extend Docs to Describe Expected Usage with TypeScript

Open xDivisionByZerox opened this issue 1 year ago • 7 comments
trafficstars

[!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.

  • This configuration was not discussed in https://github.com/faker-js/faker/issues/2725#issuecomment-2012927210.

Environment Info

-

Which module system do you use?

  • [X] CJS
  • [X] ESM

Used Package Manager

pnpm

xDivisionByZerox avatar Jul 12 '24 16:07 xDivisionByZerox

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.

ST-DDT avatar Jul 12 '24 16:07 ST-DDT

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.

xDivisionByZerox avatar Jul 12 '24 16:07 xDivisionByZerox

Team Decision

  • We assume that the user either uses strict TypeScript or handles the issues arising from not using it themselves.

ST-DDT avatar Jul 25 '24 16:07 ST-DDT

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

AmaanRS avatar Aug 17 '24 14:08 AmaanRS

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

xDivisionByZerox avatar Aug 17 '24 14:08 xDivisionByZerox

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?

ST-DDT avatar Aug 17 '24 18:08 ST-DDT

@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.

xDivisionByZerox avatar Aug 17 '24 20:08 xDivisionByZerox