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

feat: prototype stronger typings #254

Merged
merged 11 commits into from
Jan 28, 2024
Merged

Conversation

Julusian
Copy link
Member

Prototype of stronger action, feedback and preset typings.
This revealed a couple of missing/incorrect properties in the presets.

This is written fully generic, intended to be possible to reusable for other modules.

At the same time as this typings change, refactoring has been done to break up the excessively long files

This is largely just a typings change, with a notable change being done for the callbacks for actions and feedbacks. The options objects have been changed to be a class, which provides some methods. This allows for modules to simplify at couple of scenarios:

  • getPlainNumber('myprop') allows for getting a number, and for verifying the property is a number. Internally it ensures it is typed as a number (parsing a string to number if necessary), returning the default for the property if it is undefined, and throwing an error if it is NaN.
  • getParsedNumber('myprop') allows for parsing a string field, and converting the result to a number. This avoids needing to call parseVariablesInString explicitly, as that is done inside the functions implementation.

If this options class were adopted by @companion-module/base, it would allow for some better tracking of which properties are used by subscribe/unsubscribe, and would make supprorting button scoped variables simpler from the module side.

Upgrade scripts have not been touched.

@Julusian Julusian force-pushed the feat/stronger-typings-prototype branch from f0fd7d9 to e5896a9 Compare January 28, 2024 18:39
@Julusian Julusian marked this pull request as ready for review January 28, 2024 18:50
@Julusian Julusian merged commit 02e0150 into master Jan 28, 2024
2 checks passed
@Julusian Julusian deleted the feat/stronger-typings-prototype branch January 28, 2024 18:52
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

Successfully merging this pull request may close these issues.

1 participant