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

API maps #413

Merged
merged 9 commits into from
Dec 21, 2023
Merged

API maps #413

merged 9 commits into from
Dec 21, 2023

Conversation

toasted-nutbread
Copy link

This is a first step towards making serialized API interfaces more type safe, as mentioned in #391.

This has some TypeScript black magic in it, but it basically amounts to describing all APIs on a TypeScript type and then using some common mapping types. For now, this is only set up to work for Offscreen, but should be able to be expanded upon.

It ensures type safety in the ApiMapInit type, which is used to initialize API maps. This pattern was already seen throughout the application, but with more lenient type checks, and mistakes could still be made.

@toasted-nutbread toasted-nutbread requested a review from a team as a code owner December 21, 2023 04:56
Copy link

github-actions bot commented Dec 21, 2023

⚠️ Visual differences introduced by this PR; please validate if they are desirable.

View Playwright Report (note: open the "playwright-report" artifact)

Copy link
Collaborator

@djahandarie djahandarie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is amazing, I didn't even know typescript could do type-level operations that are this complicated. 😅 It can be in a later PR, but I think some comments in api-map.d.ts would be useful for future reader trying to understand what is going on in there. I don't think it needs to be detailed, just a basic explanation of what it's trying to achieve.

@djahandarie djahandarie added this pull request to the merge queue Dec 21, 2023
Merged via the queue into yomidevs:master with commit ab847b1 Dec 21, 2023
5 checks passed
@djahandarie djahandarie added the kind/meta The issue or PR is meta label Dec 21, 2023
@toasted-nutbread toasted-nutbread mentioned this pull request Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/meta The issue or PR is meta
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants