pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
553 stars 401 forks source link

Parameter bag types with index signatures are too lax #413

Closed yo1dog closed 3 weeks ago

yo1dog commented 1 month ago

In several places, inputs that would otherwise be strictly structured contain index signatures which allow the user to specify properties with any key. This prevents the typings from being able to catch misspellings and other mistakes. Specifically, in argument "bags".

For example, PublishParameters contains an index signature "for deprecated parameters", but this allows the following misspelling without any warning or error:

pubnub.publish({channel: 'fu', message: 'bar', storeInHistor: false})

Without the index signature, Typescript would flag storeInHistor with the error: Object literal may only specify known properties, but 'storeInHistor' does not exist in type 'PublishParameters'. Did you mean to write 'storeInHistory'?

Rather than an index signature, deprecated params should be explicitly listed but marked as deprecated. Or, a dedicated subkey or alternate param should be provided for specifying arbitrary keys which are merged when sent to the API.

parfeon commented 3 weeks ago

@yo1dog this issue is addressed in v8.2.10