问题
I'm trying to get the quota storage information from an Angular2 component with this command line:
navigator.storage.estimate().then((data) => console.log(data));
The command works properly in a pure Javascript script but it doesn't get compiled in Angular2/Typescript.
Can you help me?
Thanks
回答1:
I had the same problem and I couldn't find any available @types for the StorageManager interface.
My temporary solutions was to manually declare it in my code.
declare global {
interface StorageEstimate {
quota: number;
usage: number;
}
interface Navigator {
storage: {
estimate: () => Promise<StorageEstimate>;
persist: () => boolean;
persisted: () => boolean;
};
}
}
回答2:
what is navigator ? I guess it is a global variable on window without any type, so you should add a typing entry for this
https://github.com/typings/typings
来源:https://stackoverflow.com/questions/46957270/property-storage-does-not-exist-on-type-navigator