Skip to content

Commit

Permalink
fix jed type export (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw authored and pull[bot] committed Mar 28, 2024
1 parent f4fa07a commit d7f53ab
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Jed, { LanguagePack } from 'jed';
import UntypedJed from 'jed';
import { Jed, LanguagePack } from './jed';

const DEFAULT_LANGUAGE_PACK = {
domain: 'superset',
Expand All @@ -24,7 +25,7 @@ export default class Translator {

constructor(config: TranslatorConfig = {}) {
const { languagePack = DEFAULT_LANGUAGE_PACK } = config;
this.i18n = new Jed(languagePack);
this.i18n = new UntypedJed(languagePack) as Jed;
}

translate(input: string, ...args: any[]): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
import '../types/external.d';

export { configure, t, tn } from './TranslatorSingleton';
export { TranslatorConfig, LanguagePack } from './Translator';
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export interface LanguagePack {
domain: string;
/* eslint-disable-next-line camelcase */
locale_data: {
superset: {
[key: string]:
| string[]
| {
domain: string;
/* eslint-disable-next-line camelcase */
plural_forms: string;
lang: string;
};
};
};
}

export interface Jed {
translate(input: string): Jed;
ifPlural(value: number, plural: string): Jed;
fetch(...args: any[]): string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LanguagePack } from 'jed';
import { LanguagePack } from '../../src/index';

const languagePack: LanguagePack = {
domain: 'superset',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LanguagePack } from 'jed';
import { LanguagePack } from '../../src/index';

const languagePack: LanguagePack = {
domain: 'superset',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
declare module 'jed' {
export interface LanguagePack {
domain: string;
locale_data: {
superset: {
[key: string]: string[] | {
domain: string;
plural_forms: string;
lang: string;
};
};
}
}

export default class Jed {
constructor(languagepack: LanguagePack);

translate(input: string): Jed;
ifPlural(value: number, plural: string): Jed;
fetch(...args: any[]): string;
}
}
declare module 'jed';

0 comments on commit d7f53ab

Please sign in to comment.