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

Add typings for argument childProps in Properties.children() #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

soimon
Copy link
Contributor

@soimon soimon commented Apr 24, 2023

This is part of a set of pull requests aimed at reducing the amount of data being transmitted when using this (excellent 🙏) library extensively, often causing me timeouts in high performance situations. I've split my improvements in different features for your convenience, but I'd be happy to help combine them.

This PR is a first attempt at typing the childProps argument in Properties.children().

live.song.children('tracks', ['name', 'current_monitoring_state']);
// The property array is typed and has autocompletion for all property names present on the raw entry

It even includes rudimentary autocompletion for nesting children:

({} as Track).children('clip_slots', ['has_stop_button', 'will_record_on_start']);
({} as Track).children('clip_slots', ['playing_status', {name:'clip', initialProps:['legato']}]);

I haven't managed to get autocompletion working when the nested child is an array type though:

({} as Song).children('tracks', ['has_midi_input', {name:'clip_slots', initialProps:[/* Nothing here unfortunately, as clip_slots is an array property */]}]);

Once this bug is ironed out of the type definitions, you should be able to recursively select anything you want in one query (as far as I could tell the js on the M4L side already supports nesting).

@ricardomatias
Copy link
Owner

I apologise for the overdue feedback, let me know if you have interest in updating the PR to the current state. I think this would be a great feature to add to the library.

@soimon
Copy link
Contributor Author

soimon commented Nov 30, 2023

I apologise for the overdue feedback, let me know if you have interest in updating the PR to the current state. I think this would be a great feature to add to the library.

No problem. I have completed the project that prompted my pull request streak, but I'll revisit this when I have the time again. In my last attempt, I reached the limit of my TypeScript typing ability. If that's still the case, I'll share the steps I'm struggling with to better clarify the issue.

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.

None yet

2 participants