Skip to content

Commit 47ae8ac

Browse files
committed
Export TFunction and all types
1 parent d927a26 commit 47ae8ac

File tree

4 files changed

+11
-22
lines changed

4 files changed

+11
-22
lines changed

dist/brackets-viewer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,5 @@ window.inMemoryDatabase = new InMemoryDatabase();
77
window.bracketsManager = new BracketsManager(window.inMemoryDatabase);
88

99
export { BracketsViewer };
10-
export { ToI18nKey } from './lang';
11-
export {
12-
Config,
13-
MatchClickCallback,
14-
Placement,
15-
ViewerData,
16-
ParticipantImage,
17-
RoundNameInfo,
18-
MatchWithMetadata,
19-
Connection,
20-
ConnectionType,
21-
OriginHint,
22-
} from './types';
10+
export { ToI18nKey, TFunction } from './lang';
11+
export * from './types';

src/lang.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import i18next, { StringMap, TOptions } from 'i18next';
1+
import i18next, { StringMap, TOptions, TFunction } from 'i18next';
22
import LanguageDetector from 'i18next-browser-languagedetector';
33

44
import { Stage, Status, FinalType, GroupType, StageType } from 'brackets-model';
@@ -8,6 +8,8 @@ import { OriginHint, RoundNameInfo } from './types';
88
import en from './i18n/en/translation.json';
99
import fr from './i18n/fr/translation.json';
1010

11+
export type { TFunction } from 'i18next';
12+
1113
export const locales = {
1214
en,
1315
fr,
@@ -51,8 +53,6 @@ export function t<Scope extends keyof Locale, SubKey extends string & keyof Loca
5153
return i18next.t(key, options);
5254
}
5355

54-
export type Translator = typeof t;
55-
5656
export type ToI18nKey<S extends string> = S extends `${infer A}_${infer B}`
5757
? `${A}-${B}`
5858
: never;
@@ -235,22 +235,22 @@ export function getBracketName(stage: Stage, type: GroupType): string | undefine
235235
/**
236236
* Returns the name of a round.
237237
*/
238-
export function getRoundName({ roundNumber, roundCount }: RoundNameInfo, t: Translator): string {
238+
export function getRoundName({ roundNumber, roundCount }: RoundNameInfo, t: TFunction): string {
239239
return roundNumber === roundCount ? t('common.round-name-final') : t('common.round-name', { roundNumber });
240240
}
241241

242242
// eslint-disable-next-line jsdoc/require-param
243243
/**
244244
* Returns the name of a round in the winner bracket of a double elimination stage.
245245
*/
246-
export function getWinnerBracketRoundName({ roundNumber, roundCount }: RoundNameInfo, t: Translator): string {
246+
export function getWinnerBracketRoundName({ roundNumber, roundCount }: RoundNameInfo, t: TFunction): string {
247247
return roundNumber === roundCount ? t('common.round-name-winner-bracket-final') : t('common.round-name-winner-bracket', { roundNumber });
248248
}
249249

250250
// eslint-disable-next-line jsdoc/require-param
251251
/**
252252
* Returns the name of a round in the loser bracket of a double elimination stage.
253253
*/
254-
export function getLoserBracketRoundName({ roundNumber, roundCount }: RoundNameInfo, t: Translator): string {
254+
export function getLoserBracketRoundName({ roundNumber, roundCount }: RoundNameInfo, t: TFunction): string {
255255
return roundNumber === roundCount ? t('common.round-name-loser-bracket-final') : t('common.round-name-loser-bracket', { roundNumber });
256256
}

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CallbackFunction, FormConfiguration } from './form';
33
import { InMemoryDatabase } from 'brackets-memory-db';
44
import { BracketsViewer } from './main';
55
import { BracketsManager } from 'brackets-manager';
6-
import { ToI18nKey, Translator } from './lang';
6+
import { ToI18nKey, TFunction } from './lang';
77

88
declare global {
99
interface Window {
@@ -244,7 +244,7 @@ export type RoundNameInfo = {
244244
/**
245245
* A function returning a round name based on its number and the count of rounds.
246246
*/
247-
export type RoundNameGetter = (info: RoundNameInfo, t: Translator) => string;
247+
export type RoundNameGetter = (info: RoundNameInfo, t: TFunction) => string;
248248

249249
/**
250250
* A function called when a match is clicked.

0 commit comments

Comments
 (0)