# Q&A
# About Interface
Q: Why can't I use
interface
to define TypeScript types?A: Because the key of the type defined by
interface
does not have astring
type signature. But Soft Storage sets type constraints likeRecord<string, unknown>
for the incoming generics. So, usetype
to instead of it.
# About Remove and Clear
Q: Why isn't
remove()
andclear()
provided?A: There are two reasons:
Correlation of component states
In the framework, properties in the storage module are associated with states in the component one by one. If
remove()
andclear()
are called to delete key-value pairs from the storage module, states cannot sense that the storage module has been modified. As a result, non-nullable properties in the storage module and corresponding states in the component are out of sync, resulting in unexpected errors.Non-nullable definition of properties
Semantically,
remove()
andclear()
are used to delete key-value pairs in the storage module, including non-nullable properties. In this way, these non-nullable properties violate their definition of "non-nullable."