From d7f53ab3d606529287346253fc919d72ead7e5a9 Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Mon, 28 Jan 2019 22:29:31 -0800 Subject: [PATCH] fix jed type export (#83) --- .../superset-ui-translation/src/Translator.ts | 5 ++-- .../superset-ui-translation/src/index.ts | 2 -- .../superset-ui-translation/src/jed.ts | 22 ++++++++++++++++++ .../test/languagePacks/en.ts | 2 +- .../test/languagePacks/zh.ts | 2 +- .../types/external.d.ts | 23 +------------------ 6 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/jed.ts diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/Translator.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/Translator.ts index 9bc495f3608bd..7c74d4ca644bf 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/Translator.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/Translator.ts @@ -1,4 +1,5 @@ -import Jed, { LanguagePack } from 'jed'; +import UntypedJed from 'jed'; +import { Jed, LanguagePack } from './jed'; const DEFAULT_LANGUAGE_PACK = { domain: 'superset', @@ -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 { diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/index.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/index.ts index 8d047e7e25700..492599e2da6fa 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/index.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/index.ts @@ -1,4 +1,2 @@ -import '../types/external.d'; - export { configure, t, tn } from './TranslatorSingleton'; export { TranslatorConfig, LanguagePack } from './Translator'; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/jed.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/jed.ts new file mode 100644 index 0000000000000..5f4d25fb07ae4 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/src/jed.ts @@ -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; +} diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/en.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/en.ts index c3113a85f0414..c8fbddb06e25b 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/en.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/en.ts @@ -1,4 +1,4 @@ -import { LanguagePack } from 'jed'; +import { LanguagePack } from '../../src/index'; const languagePack: LanguagePack = { domain: 'superset', diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/zh.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/zh.ts index 9b368c313c341..b98e84db960f2 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/zh.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/test/languagePacks/zh.ts @@ -1,4 +1,4 @@ -import { LanguagePack } from 'jed'; +import { LanguagePack } from '../../src/index'; const languagePack: LanguagePack = { domain: 'superset', diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/types/external.d.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/types/external.d.ts index 4ce1f22161a07..1175c8147a049 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/types/external.d.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-translation/types/external.d.ts @@ -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';