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

Restricted API for helpers #1889

Merged
merged 6 commits into from
May 20, 2024
Merged

Restricted API for helpers #1889

merged 6 commits into from
May 20, 2024

Conversation

ijlee2
Copy link
Contributor

@ijlee2 ijlee2 commented May 20, 2024

Why?

Closes #1735.

Before, the helpers had used the internal state allowEmpty, the user preference options.allowEmpty, and isEmpty() from @ember/utils, to handle an input that isn't well-defined. isEmpty() had made maintenance especially difficult, because it returns true for many JavaScript values.

Solution?

From now on, the intl service's format*() and t() methods form the source of truth. The helpers simply call these methods.

@ijlee2 ijlee2 added breaking Breaking change will result in a new major version enhance: code Issue asks for new feature or refactor labels May 20, 2024
@ijlee2 ijlee2 force-pushed the feature-restrict-helpers-api branch from 3994846 to 6f0f345 Compare May 20, 2024 08:15
@ijlee2 ijlee2 marked this pull request as ready for review May 20, 2024 08:29
@ijlee2 ijlee2 force-pushed the feature-restrict-helpers-api branch from 6f0f345 to f8cda95 Compare May 20, 2024 08:29
Comment on lines -20 to -23
assert(
'To use `addTranslations()`, make sure to call `setupTest()`, `setupRenderingTest()`, or `setupApplicationTest()`.',
context,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to remove assert(), as it's unlikely that developers can run a test without setupTest(), setupRenderingTest(), or setupApplicationTest().

Note, the assert() had provided a more user-friendly error message.

Named?: Options & { allowEmpty?: boolean };
Positional: [Value] | [Value, Options];
Named?: Options;
Positional: [Value];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the use of inheritance (addon/helpers/-format-base.js), #1633 had accidentally increased the API of {{format-*}} helpers.

@ijlee2 ijlee2 merged commit 7edc22d into main May 20, 2024
32 checks passed
@ijlee2 ijlee2 deleted the feature-restrict-helpers-api branch May 20, 2024 08:37
This was referenced May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change will result in a new major version enhance: code Issue asks for new feature or refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider more forgiving DX
1 participant