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

Update TS error-guard's text to be meaningful #2182

Merged
merged 3 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `13.1.0`.
**Bug fixes**

- Fixed error message when an I18n mapping is a formatting function with no values provided. ([#2182](https://github.com/elastic/eui/pull/2182))

## [`13.1.0`](https://github.com/elastic/eui/tree/v13.1.0)

Expand Down
8 changes: 5 additions & 3 deletions src/components/i18n/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { ExclusiveUnion } from '../common';
import { I18nShape, Renderable, RenderableValues } from '../context/context';
import { processStringToChildren } from './i18n_util';

function throwError(): never {
throw new Error('asdf');
function errorOnMissingValues(token: string): never {
throw new Error(
`I18n mapping for token "${token}" is a formatting function but no values were provided.`
);
}

function lookupToken<
Expand All @@ -23,7 +25,7 @@ function lookupToken<

if (typeof renderable === 'function') {
if (values === undefined) {
return throwError();
return errorOnMissingValues(token);
} else {
// @ts-ignore-next-line
// TypeScript complains that `DEFAULT` doesn't have a call signature
Expand Down
3 changes: 0 additions & 3 deletions src/components/stat/stat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ export const EuiStat: FunctionComponent<
let titleText;
if (isLoading) {
titleText = (
// EuiI18n has trouble with the string setting
// @ts-ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these ignores are no longer needed, as EuiI18n's TS defs were updated to better support this setup

<EuiI18n token="euiStat.loadingText" default="Statistic is loading">
{/* // @ts-ignore */}
{(loadingText: string) => <p aria-label={loadingText}>--</p>}
</EuiI18n>
);
Expand Down