Calling all Typescript enthusiasts! I need help with this code snippet:
import * as appSettings from 'application-settings';
try {
// shim the 'localStorage' API with application settings module
global.localStorage = {
getItem(key: string) {
return appSettings.getString(key);
},
setItem(key: string, value: string) {
return appSettings.setString(key, value);
}
}
application.start({ moduleName: 'main-page' });
}
catch (err) {
console.log(err);
}
I'm getting an error in VSCode that says
[ts] Property 'localStorage' does not exist on type 'Global'. [2339]
. Any suggestions on how to resolve this issue?
This code is for a Nativescript app. You can view the entire file/app here for reference: https://github.com/burkeholland/nativescript-todo/blob/master/app/app.ts