nodejs-datastore icon indicating copy to clipboard operation
nodejs-datastore copied to clipboard

Request to remove wildcard type from Datastore instances

Open karatekaneen opened this issue 4 years ago • 0 comments

The issue

The Datastore instance inherits from DatastoreRequest which among other things contain:

[key: string]: Entity; // Entity is aliased to any

This is a problem when dealing with typos since the return types are any all code following still compiles without warning.

Example:

const datastore = new Datastore()

datastore.fooBar('hello') // No warning or anything here

const [data] = await datastore.GET(key) 
// obvious typo here but the `data` variable has type "any" 
// and all following code compiles without warning

model.process(data) // No warning here either

Request

Since my knowledge of how the class works is very limited I'm not sure if it's possible but it would be nice if obvious errors like the one I showed are caught at write-time by having stricter types.

karatekaneen avatar Feb 03 '21 13:02 karatekaneen