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: TypeScript App/Plugin Codegen Type Safety #1217

Merged
merged 2 commits into from
Sep 7, 2022

Conversation

krisbitney
Copy link
Contributor

@krisbitney krisbitney commented Sep 7, 2022

This PR enforces type safety for generated TypeScript code. Instead of extending Record<string, unknown>, generated object and arg types are cast to Record<string, unknown> just before invocations are called in the generated Module type. Generated arg types must be typecast to Record<string, unknown> because the client's invoke method expects a Record<string, unknown> | UInt8Array | undefined.

The TypeScript interface for the generated Env type still extends Record<string, unknown> to ensure it conforms to the generic parameter restriction set by the PluginModule definition in @polywrap/core-js.

Closes #897

@krisbitney krisbitney marked this pull request as draft September 7, 2022 11:30
@krisbitney krisbitney marked this pull request as ready for review September 7, 2022 11:53
@krisbitney krisbitney marked this pull request as draft September 7, 2022 11:55
@krisbitney krisbitney marked this pull request as ready for review September 7, 2022 16:52
@krisbitney krisbitney modified the milestone: origin-qa Sep 7, 2022
@krisbitney krisbitney linked an issue Sep 7, 2022 that may be closed by this pull request
Copy link
Contributor

@pileks pileks left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@dOrgJelli dOrgJelli left a comment

Choose a reason for hiding this comment

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

Awesome!

@dOrgJelli dOrgJelli merged commit 1e04535 into origin-dev Sep 7, 2022
@dOrgJelli dOrgJelli deleted the ts-codegen-type-safety branch April 10, 2023 17:04
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.

TypeScript App/Plugin Codegen Types Aren't Very Type-Safe
3 participants