Skip to content

Feat: TypeScript App/Plugin Codegen Type Safety#1217

Merged
dOrgJelli merged 2 commits into
origin-devfrom
ts-codegen-type-safety
Sep 7, 2022
Merged

Feat: TypeScript App/Plugin Codegen Type Safety#1217
dOrgJelli merged 2 commits into
origin-devfrom
ts-codegen-type-safety

Conversation

@krisbitney
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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