Skip to content

Improve parameter strictness #130

Description

@jhnns

The Clockodo SDK has been previously designed in a way to allow additional parameters that haven't been typed yet. E.g. imagine there is a new parameter we haven't added to the function type yet:

clockodo.getUser({
  newParam: true
});

In TypeScript, this would show an error because of the "excess property check". We extend all params with Record<string, unknown> to allow new, untyped params.

As a downside, this also makes it possible to missspell properties and TypeScript will allow it:

clockodo.getUser({
  // TS allows this because it thinks it's a new param
  oldButMisspelledParam: true
});

I think, we should remove & Record<string, unknown> thus making the type check more strict. As a downside, the SDK will now show an error if a new, untyped param is used. However, I think this can be easily fixed:

clockodo.getUser({
  // New, untyped param. Remove this once it got added to the SDK
  // @ts-expect-error
  newParam: true
});

This way, it will show a TypeScript error as soon as the type is added and the ts-expect-error is not necessary anymore. With us working more actively on the SDK, I think we should try to get the complete API typed and up-to-date.

What do you think @mrclickbits @anki247 @dsumer ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions