fix: make translation module type check correctly (#140)

This commit is contained in:
Krist Wongsuphasawat 2019-04-26 13:19:16 -07:00 committed by Yongjie Zhao
parent 368ed3cb5b
commit a35f88a69e

View File

@ -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) {
@ -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;