Skip to content

Commit

Permalink
Update TS error-guard's text to be meaningful (#2182)
Browse files Browse the repository at this point in the history
* Update TS error-guard's text to be meaningful

* changelog
  • Loading branch information
chandlerprall authored Jul 31, 2019
1 parent 09f2b5b commit 5a186bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**Bug fixes**

- Fixed `EuiMutationObserver` errors in IE11 by conditionally setting the `attributes` observer option according to the new spec ([#2180](https://github.com/elastic/eui/pull/2180))
- 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
<EuiI18n token="euiStat.loadingText" default="Statistic is loading">
{/* // @ts-ignore */}
{(loadingText: string) => <p aria-label={loadingText}>--</p>}
</EuiI18n>
);
Expand Down

0 comments on commit 5a186bc

Please sign in to comment.