Skip to content

Commit

Permalink
fix(@formatjs/intl): fix __addMessages issues with references
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho committed Feb 9, 2021
1 parent e8790d4 commit f9266f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/intl/src/create-intl.ts
Expand Up @@ -173,11 +173,9 @@ export function createIntl<T = string>(
);
}

// @ts-expect-error this is fine
resolvedConfig.messages = {
...resolvedConfig.messages,
...messages,
};
Object.keys(messages).forEach(k => {
resolvedConfig.messages[k] = messages[k];
});
},
};
}
10 changes: 10 additions & 0 deletions packages/intl/tests/create-intl.test.ts
Expand Up @@ -13,3 +13,13 @@ test('createIntl', function () {
})
).toBe('bar');
});

test('__addMessages', function () {
const intl = createIntl({
locale: 'en',
messages: {},
});
expect(intl.messages).toEqual({});
intl.__addMessages({foo: ''});
expect(intl.messages).toEqual({foo: ''});
});

0 comments on commit f9266f9

Please sign in to comment.