Skip to content

Commit

Permalink
feat(react-dictionary): default to more lenient types
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsdaniels committed Sep 28, 2023
1 parent 3cfb400 commit 4e970b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-crabs-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codedazur/react-dictionary": minor
---

default to more lenient typings
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface DictionaryProviderProps {
}

export const DictionaryProvider: FunctionComponent<DictionaryProviderProps> = ({
locale = Locale.en_US,
locale = null,
dictionaries,
children,
}) => {
Expand Down
21 changes: 5 additions & 16 deletions packages/react-dictionary/contexts/dictionaryContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,24 @@ export type Dictionary = ReadonlyMap<DictionaryKey, string>;
* import "@codedazur/react-dictionary";
*
* declare module "@codedazur/react-dictionary" {
* export enum DictionaryKey {
* "foo",
* "bar",
* "baz",
* }
* export type DictionaryKey = "foo" | "bar" | "baz";
* }
*/
export enum DictionaryKey {}
export type DictionaryKey = string;

/**
* This enum can be overridden using module augmentation.
* This type can be overridden using module augmentation.
*
* @example
* // dictionary.d.ts
*
* import "@codedazur/react-dictionary";
*
* declare module "@codedazur/react-dictionary" {
* export enum Locale {
* en_US = "en_US",
* en_GB = "en_GB",
* }
* export type Locale = "en_US" | "en_GB";
* }
*/
export enum Locale {
en_US = "en_US",
}

export const DefaultLocale = Locale.en_US;
export type Locale = string;

export interface DictionaryContext {
locale: Locale | null;
Expand Down

0 comments on commit 4e970b1

Please sign in to comment.