Skip to content

Commit 20d39e6

Browse files
robwalkercolonglho
authored andcommitted
fix(types): Change type to allow autocompletion and existence checking (#1368)
1 parent e4b2187 commit 20d39e6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/define-messages.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import {MessageDescriptor} from './types';
66
* See the accompanying LICENSE file for terms.
77
*/
88

9-
export default function defineMessages(
10-
messageDescriptors: Record<string, MessageDescriptor>
9+
type Messages<Names extends keyof any = string> = {
10+
[key in Names]: MessageDescriptor;
11+
};
12+
13+
export default function defineMessages<Names extends keyof any>(
14+
messageDescriptors: Messages<Names>
1115
) {
1216
// This simply returns what's passed-in because it's meant to be a hook for
1317
// babel-plugin-react-intl.

0 commit comments

Comments
 (0)