Skip to content

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 and zhaoyongjie committed Nov 26, 2021
1 parent 368ed3c commit a35f88a
Showing 1 changed file with 6 additions and 5 deletions.
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 a35f88a

Please sign in to comment.