cc.sys.localStorage type any?

cc.sys.localStorage type any?


Why the localStorage from cc.sys have any type? i can’t see any method or information.





Thank you @Big_Bear that not answer my question but it’s helpful


any is a convention in TypeScript because JavaScript is a loosely typed language while TS tries to keep types specific and strict while on top of JS.

localStorage is technically a Storage class object which truly is just an object but with a few extra methods designed around storing and retrieving items. It should really be labled Object but the idea behind putting any is probably because that object might have 100 keys or 1, it might be all strings or all numbers, perhaps a json string, etc. I’m sure they put any to remind developers that your localStorage does not have to adhere to a specific object structure.


Thank you for your answer @skara
If is technically an storage why don’t have storage type?
Then you can use the methods, let any type in a variable it’s a really bad practice. Doing that you are losing all typescript idea. Localstorage must be a storage type or any type that implements that. If has setItem, getItem, and all methods that must have…