Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter bag types with index signatures are too lax #413

Closed
yo1dog opened this issue Oct 14, 2024 · 1 comment · Fixed by #417
Closed

Parameter bag types with index signatures are too lax #413

yo1dog opened this issue Oct 14, 2024 · 1 comment · Fixed by #417
Assignees
Labels
priority: low This PR should be reviewed after all high and medium PRs. status: in progress This issue is being worked on. type: chore This PR contains changes that are not covered by other types (stylistic, dependency updates, etc).

Comments

@yo1dog
Copy link

yo1dog commented Oct 14, 2024

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 parfeon self-assigned this Oct 29, 2024
@parfeon parfeon added status: in progress This issue is being worked on. priority: low This PR should be reviewed after all high and medium PRs. type: chore This PR contains changes that are not covered by other types (stylistic, dependency updates, etc). labels Oct 29, 2024
parfeon added a commit that referenced this issue Oct 30, 2024
Fix definition of type which represent message actions received from history and list of users which added action of specific type and value to the message.

Closes #407

refactor(types): remove indexed signature for publish

Remove redundant indexed signature from publish message parameters type definition.

Closes #413

refactor(types): add serializable objects to `Payload` type

Extend `Payload` type definition with objects which can be serialized by `JSON.stringify` using `toJSON()` methods.

Closes #412

refactor(types): aggregate generated types definitions

Aggregate multiple types definitions into single type definition type with proper type names and namespaces.

Closes #405 #409 #410

refactor(types): add missing Subscribe Event Engine types

Add Subscribe Event Engine and Event Listener types to the bundled types definition file.

Closes #377
@parfeon
Copy link
Contributor

parfeon commented Oct 31, 2024

@yo1dog this issue is addressed in v8.2.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low This PR should be reviewed after all high and medium PRs. status: in progress This issue is being worked on. type: chore This PR contains changes that are not covered by other types (stylistic, dependency updates, etc).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants