Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
fix: make translation module type check correctly (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw authored Apr 26, 2019
1 parent 0ef1436 commit c05fe3a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/superset-ui-translation/src/TranslatorSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Translator from './Translator';
import { TranslatorConfig } from './types';

let singleton: Translator;
let singleton: Translator | undefined;
let isConfigured = false;

function configure(config?: TranslatorConfig) {
Expand All @@ -15,10 +15,11 @@ function configure(config?: TranslatorConfig) {

function getInstance() {
if (!isConfigured) {
console.warn('You must call configure(...) before calling other methods');
if (!singleton) {
singleton = new Translator();
}
console.warn('You should call configure(...) before calling other methods');
}

if (typeof singleton === 'undefined') {
singleton = new Translator();
}

return singleton;
Expand Down

0 comments on commit c05fe3a

Please sign in to comment.