-
-
Notifications
You must be signed in to change notification settings - Fork 915
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
Discuss boundaries of type-less JavaScript support #2725
Comments
@faker-js/maintainers @faker-js/members |
My feelings are
So generally I would support for example trying to handle these kind of cases in JS:
But I don't think we need to add special JS code to handle
|
Do you have a source for this? |
Say https://blog.jetbrains.com/webstorm/2024/02/js-and-ts-trends-2024/ Or if you look at https://www.npmjs.com/browse/depended/@faker-js/faker there's a fair mix of JS and TS. |
And as your linked survey shows, 50% use VS Code, which supports TypeScript/JavaScript with type hints and can warn you about bad code, if you let it. Maybe <5% of JS developers use a type-less IDE.
Yes, but you only achieve that by consistency. e.g. We could check for
I agree with that, for everything that typescript doesn't cover. (e.g. because of business logic or inter-variable constraints).
So which one should we add? If we cannot find a rule for that, we will talk about this again in the next PR.
What is so special about not providing any parameters? What about providing wrong/incompatible parameters? faker.date.between is a somewhat special case, that it previously worked without args and now requires some, so I think we could temporarily give it a specific and strict check, but we should eventually let that rely on TS inherent protections.
Once again, what is so special about it having a typo? Sure typos are easy, but what about passing a completely invalid value, like a number? or not quoting the value and thus using an undefined, unintended or uninitialized variable? Or having a typo in the name of the variable you intend to pass? AFAICT you don't get any error indications in your type-less code for that either. My main concern about adding a catch "other"/default clause is, that it also reduces our own DX as it hides issues like non-exhaustive-switch-case statements.
Which we have very few of. I could only find this one right now: And like that PR I would rather try to fix the underlying issue, than adding another check, that should never fail in the first place. If we get such reports, then we can discuss whether and how we could improve the checks (or just add the missing data), but we shouldn't do so prematurely.
For a migration period, maybe yes, and if so it has to be a proper check, not a leaky wall.
How much of a method should be checks? Even if you add one or two lines at a time, you still end up with lots of checks. |
Both of these give not any insight about TYPE-LESS JavaScript. Just because someone uses JS, doesn't mean they get no type support from JSDocs or an |
I'm not anti-types. I just think "this is not needed in TS" is insufficient justification for removing code which is useful for JS developers, e.g. which gives JS developers more useful error messages. I would expect the vast majority of lines in a project like Faker to be documentation, error checking etc. At its core, a lot of Faker methods are basically thin wrappers around Anyway, don't feel you have to rebut all my points. if the consensus of the maintainers is different, I'll happily go along with that. |
That seems very low, I feel the developer ecosystem is way more diverse than that, and bear in mind developers are not always in an IDE. For example maybe i'm in a browser console. Or in the Node REPL. Or I've SSHed into a server and need to write a quick script to dump some fake data into my DB and I'm just using |
That is from your statistic. At least if we assume type capable IDEs. |
Team decision We will not validate:
We will validate:
These rules will be included in the upcoming maintainer docs. |
We need to discuss how we support JavaScript when type checking is not available/used.
Points of interest:
The text was updated successfully, but these errors were encountered: