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

Improve parameter strictness #130

Open
jhnns opened this issue Sep 27, 2023 · 0 comments
Open

Improve parameter strictness #130

jhnns opened this issue Sep 27, 2023 · 0 comments
Assignees

Comments

@jhnns
Copy link
Member

jhnns commented Sep 27, 2023

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 ?

@jhnns jhnns self-assigned this Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant