-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
Deprecate helpers.createTransaction() #782
Comments
We can safely remove the |
closed via #916 |
We we use it. LOL. It would be nice if there were deprecation notes with a recommended alternative approach. |
Thanks 🙏 |
We have improved our upgrading guideline rules in the meantime. https://next.fakerjs.dev/guide/upgrading.html We removed these methods because the requirements for the complex return objects differ between most users and thus an individualistic approach with these methods usually results in better usability. We are sorry for the inconvenience that was caused by this change. Here is a workaround, that you can use as an alternative to the built-in method: function createTransaction(): {
amount: string;
date: Date;
business: string;
name: string;
type: string;
account: string;
} {
return {
amount: faker.finance.amount(),
date: faker.date.recent(),
business: faker.company.name(),
name: `${faker.finance.accountName()} (...${faker.string.numeric(4)})`,
type: faker.helpers.arrayElement(
faker.definitions.finance.transaction_type
),
account: faker.finance.accountNumber(),
};
} Tested with {
amount: '428.32',
date: 2024-05-30T20:17:49.443Z,
business: 'Hodkiewicz, Gottlieb and Effertz',
name: 'Savings Account (...7362)',
type: 'withdrawal',
account: '96287636'
} |
The missing thought process here is that someone upgrading the library with pre-existing usage needs to go hunt down how to satisfy previous behavior to not break existing behavior. That means understanding what was being done in the built-in method and then mimicking it. I was able to do this, but it required digging into the (now removed) code to see how it was done. The migration notes basically don't account for this use case at all, amounting to "You're on your own. Do what you need.". What we needed is to reproduce what was being done in the old version so as to not break pre-existing behavior. |
I think this has something which has improved over time. The 6 to 7 migration guide was quite terse. 7 to 8 and the upcoming 8 to 9 migration guides are hopefully better about providing explicit alternatives for removed functionality. |
Clear and concise description of the problem
The method provides a range of methods that are loosely related to each other.
Most users will usually require more specific data models or other property names.
Suggested solution
The method should be deprecated for removal similar to the card methods.
Alternative
Upgrade the method to create transactions for the current/recent/future date.
Additional context
No response
The text was updated successfully, but these errors were encountered: