Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* prettier:typescript * rename - begin to split ts usage tests * break out t test from init test usage * break apart t and generic t test * add broken mock test * attempt typing that should work * TranslateFunction -> TFunction TranslateOptions -> TOptions WithT.t - removed definition and extracted to TFunction exists - stopped (mis)using TranslateFunction and defined separately * Test parameterized t results for typical usage * duplicate TFunction definition inside WithT - can’t find a way around it - breaks mock.test but works for typical usage * Update init tests to use type inference instead of explicit types, remove TFunction duplication * use any workaround * add explicit test of arg in callback * remove comment no longer relevant
- Loading branch information
Showing
6 changed files
with
73 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import i18next from 'i18next'; | ||
|
||
i18next.exists('friend'); | ||
i18next.exists(['friend', 'tree']); | ||
i18next.exists('friend', { myVar: 'someValue' }); | ||
i18next.exists(['friend', 'tree'], { myVar: 'someValue' }); | ||
|
||
const a: boolean = i18next.exists('my.key'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import i18next from 'i18next'; | ||
|
||
/** | ||
* Exercises in mocking | ||
*/ | ||
const mockWithT: i18next.WithT = { | ||
t: ((key: string) => key) as any, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters