Skip to content

Parameter bag types with index signatures are too lax #413

Closed
@yo1dog

Description

@yo1dog

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.

Metadata

Metadata

Assignees

Labels

priority: lowThis PR should be reviewed after all high and medium PRs.status: in progressThis issue is being worked on.type: choreThis PR contains changes that are not covered by other types (stylistic, dependency updates, etc).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions