I have an extension.ts
file that contains various extensions of predefined types of TypeScript/JavaScript, including the following class:
export {};
declare global {
interface Navigator {
currentLang() : string;
}
}
Navigator.prototype.currentLang = function() {
var userLang = navigator.language.split('-')[0];
userLang = /(en|it)/gi.test(userLang) ? userLang : 'en';
return userLang;
};
when I run the command ionic serve
the google developer console throws the following error:
TypeError: navigator.currentLang is not a function
What could be the problem?