Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

[RFC] Object parameters for javascript target #26

@vhfmag

Description

@vhfmag

Once #24 is done and we can use npm for versioning, breaking changes will become less scary. With that out of the way, I propose we implement an opt-in (maybe as a plugin?) object mode for endpoints' arguments, as follows:

// object mode disabled
function logIn(username: string, password: string) { /* stuff */ }

// object mode enabled
function logIn(args: { username: string, password: string }) { /* stuff */ }

By doing so, breaking changes can be more easily detected and fixed: imagine the logIn function changes, so that it starts to receive a username and a token, both strings. Without object mode, the change wouldn't be detected by type systems (as password and token have the same type), introducing subtle bugs.

Another kind of bug easily introduced without object mode but avoided with it, is based on the fact that arguments order matter: switching arguments of the same type (e.g. logIn(password, username)) is easily done and hardly detectable.

Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions