Skip to content

Commit

Permalink
fix: inline defineMessages macro, fix #1592
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho authored and Long Ho committed Mar 4, 2020
1 parent b207d80 commit 5ae8349
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
1 change: 0 additions & 1 deletion api-extractor.bundled.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./api-extractor.json",
"bundledPackages": [
"@formatjs/macro",
"@formatjs/intl-listformat",
"@formatjs/intl-relativetimeformat",
"intl-messageformat-parser",
Expand Down
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
"@formatjs/intl-relativetimeformat": "^4.5.9",
"@formatjs/intl-unified-numberformat": "^3.2.0",
"@formatjs/intl-utils": "^2.2.0",
"@formatjs/macro": "^0.2.6",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/invariant": "^2.2.31",
"hoist-non-react-statics": "^3.3.2",
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
*/
import * as React from 'react';
export * from './types';
export {defineMessages} from '@formatjs/macro';
export function defineMessages<T, U extends Record<string, T>>(msgs: U): U {
return msgs;
}
import {
createFormattedComponent,
createFormattedDateTimePartsComponent,
Expand Down
7 changes: 6 additions & 1 deletion test/unit/format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
formatHTMLMessage as baseFormatHTMLMessage,
formatMessage as baseFormatMessage,
} from '../../src/formatters/message';
import {IntlFormatters} from '../../src';
import {IntlFormatters, defineMessages} from '../../src';

describe('format API', () => {
const {NODE_ENV} = process.env;
Expand Down Expand Up @@ -111,6 +111,11 @@ describe('format API', () => {
process.env.NODE_ENV = NODE_ENV;
});

it('defineMessages', function() {
expect(defineMessages({})).toEqual({});
expect(defineMessages({foo: {}})).toEqual({foo: {}});
});

describe('formatDate()', () => {
let df;
let formatDate;
Expand Down

0 comments on commit 5ae8349

Please sign in to comment.