Closed DaSchTour closed 1 year ago
Hello,
The watch()
signature is the same as the get()
signature and is working as intended.
The schema
is optional, but then an Observable<unknown>
is returned, which is the intended behavior. Because if a runtime time check was not done with a schema
, it is not right to rely on a compilation cast: indeed, it is client-side storage, so the data could have been forged, which could lead to bugs and security issues.
I invite you to read again the "Validation" documentation, and especially the "Why a schema and a cast?" section for a longer description of the behavior.
Converting this to a discussion as it is not a bug.
Checks before posting an issue
Description of the issue
The documentation states, that schema is optional, so the signature for generic watch should not force usage of schema.
So please change
watch<T>(index: string, schema: JSONSchema): Observable<T> {}
towatch<T>(index: string, schema?: JSONSchema): Observable<T> {}
This would allow to specify the type and avoid later typecasting.