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

Extend Docs to Describe Expected Usage with TypeScript #3006

Closed
10 tasks done
xDivisionByZerox opened this issue Jul 12, 2024 · 7 comments · Fixed by #3171
Closed
10 tasks done

Extend Docs to Describe Expected Usage with TypeScript #3006

xDivisionByZerox opened this issue Jul 12, 2024 · 7 comments · Fixed by #3171
Assignees
Labels
c: docs Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed m: helpers Something is referring to the helpers module p: 1-normal Nothing urgent
Milestone

Comments

@xDivisionByZerox
Copy link
Member

xDivisionByZerox commented Jul 12, 2024

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?

  • CJS
  • ESM

Used Package Manager

pnpm

@xDivisionByZerox xDivisionByZerox added c: bug Something isn't working p: 2-high Fix main branch labels Jul 12, 2024
@xDivisionByZerox xDivisionByZerox added this to the v9.0 milestone Jul 12, 2024
@ST-DDT
Copy link
Member

ST-DDT commented Jul 12, 2024

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 xDivisionByZerox added the m: helpers Something is referring to the helpers module label Jul 12, 2024
@xDivisionByZerox
Copy link
Member Author

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 xDivisionByZerox added p: 1-normal Nothing urgent and removed p: 2-high Fix main branch labels Jul 12, 2024
@ST-DDT ST-DDT added c: docs Improvements or additions to documentation and removed c: bug Something isn't working labels Jul 25, 2024
@ST-DDT ST-DDT modified the milestones: v9.0, vAnytime Jul 25, 2024
@ST-DDT
Copy link
Member

ST-DDT commented Jul 25, 2024

Team Decision

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

@xDivisionByZerox xDivisionByZerox changed the title helpers.arrayElement() breaks when not using TS strict mode Extend Docs to Describe Expected Usage with TypeScript Jul 26, 2024
@xDivisionByZerox xDivisionByZerox added good first issue Good for newcomers help wanted Extra attention is needed labels Jul 26, 2024
@AmaanRS
Copy link

AmaanRS commented Aug 17, 2024

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

@xDivisionByZerox
Copy link
Member Author

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

@ST-DDT
Copy link
Member

ST-DDT commented Aug 17, 2024

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
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: docs Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed m: helpers Something is referring to the helpers module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants