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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export type {{#detectKeyword}}{{type}}{{/detectKeyword}} = {{type}}Enum | {{type
{{#methods}}

/* URI: "{{parent.uri}}" */
interface {{parent.type}}_Args_{{name}} extends Record<string, unknown> {
interface {{parent.type}}_Args_{{name}} {
{{#arguments}}
{{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}};
{{/arguments}}
Expand All @@ -106,7 +106,7 @@ export const {{type}} = {
return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({
uri,
method: "{{name}}",
args
args: args as unknown as Record<string, unknown>
});
}{{^last}},{{/last}}
{{^last}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
{{#moduleType}}
{{#methods}}

export interface Args_{{name}} extends Record<string, unknown> {
export interface Args_{{name}} {
{{#arguments}}
{{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}};
{{/arguments}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export type {{#detectKeyword}}{{type}}{{/detectKeyword}} = {{type}}Enum | {{type
{{#importedModuleTypes}}
{{#methods}}
/* URI: "{{parent.uri}}" */
interface {{parent.type}}_Args_{{name}} extends Record<string, unknown> {
interface {{parent.type}}_Args_{{name}} {
{{#arguments}}
{{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}};
{{/arguments}}
Expand All @@ -116,7 +116,7 @@ export const {{type}} = {
return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({
uri: "{{parent.uri}}",
method: "{{name}}",
args
args: args as unknown as Record<string, unknown>
});
}{{^last}},{{/last}}
{{^last}}
Expand All @@ -141,7 +141,7 @@ export class {{#detectKeyword}}{{type}}{{/detectKeyword}} {
return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({
uri: this.uri,
method: "{{name}}",
args
args: args as unknown as Record<string, unknown>
});
}
{{^last}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export type TestImport_Enum = TestImport_EnumEnum | TestImport_EnumString;
/// Imported Modules START ///

/* URI: "testimport.uri.eth" */
interface TestImport_Module_Args_importedMethod extends Record<string, unknown> {
interface TestImport_Module_Args_importedMethod {
str: Types.String;
optStr?: Types.String | null;
u: Types.UInt;
Expand All @@ -160,7 +160,7 @@ interface TestImport_Module_Args_importedMethod extends Record<string, unknown>
}

/* URI: "testimport.uri.eth" */
interface TestImport_Module_Args_anotherMethod extends Record<string, unknown> {
interface TestImport_Module_Args_anotherMethod {
arg: Array<Types.String>;
}

Expand All @@ -174,7 +174,7 @@ export const TestImport_Module = {
return client.invoke<Types.TestImport_Object | null>({
uri,
method: "importedMethod",
args
args: args as unknown as Record<string, unknown>
});
},

Expand All @@ -186,7 +186,7 @@ export const TestImport_Module = {
return client.invoke<Types.Int32>({
uri,
method: "anotherMethod",
args
args: args as unknown as Record<string, unknown>
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
MaybeAsync
} from "@polywrap/core-js";

export interface Args_moduleMethod extends Record<string, unknown> {
export interface Args_moduleMethod {
str: Types.String;
optStr?: Types.String | null;
en: Types.CustomEnum;
Expand All @@ -23,21 +23,21 @@ export interface Args_moduleMethod extends Record<string, unknown> {
mapOfArrOfObj: Map<Types.String, Array<Types.AnotherType>>;
}

export interface Args_objectMethod extends Record<string, unknown> {
export interface Args_objectMethod {
object: Types.AnotherType;
optObject?: Types.AnotherType | null;
objectArray: Array<Types.AnotherType>;
optObjectArray?: Array<Types.AnotherType | null> | null;
}

export interface Args_optionalEnvMethod extends Record<string, unknown> {
export interface Args_optionalEnvMethod {
object: Types.AnotherType;
optObject?: Types.AnotherType | null;
objectArray: Array<Types.AnotherType>;
optObjectArray?: Array<Types.AnotherType | null> | null;
}

export interface Args_if extends Record<string, unknown> {
export interface Args_if {
if: Types._else;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export type TestImport_Enum = TestImport_EnumEnum | TestImport_EnumString;
/// Imported Modules START ///

/* URI: "testimport.uri.eth" */
interface TestImport_Module_Args_importedMethod extends Record<string, unknown> {
interface TestImport_Module_Args_importedMethod {
str: Types.String;
optStr?: Types.String | null;
u: Types.UInt;
Expand All @@ -173,7 +173,7 @@ interface TestImport_Module_Args_importedMethod extends Record<string, unknown>
}

/* URI: "testimport.uri.eth" */
interface TestImport_Module_Args_anotherMethod extends Record<string, unknown> {
interface TestImport_Module_Args_anotherMethod {
arg: Array<Types.String>;
}

Expand All @@ -191,7 +191,7 @@ export class TestImport_Module {
return client.invoke<Types.TestImport_Object | null>({
uri: this.uri,
method: "importedMethod",
args
args: args as unknown as Record<string, unknown>
});
}

Expand All @@ -202,7 +202,7 @@ export class TestImport_Module {
return client.invoke<Types.Int32>({
uri: this.uri,
method: "anotherMethod",
args
args: args as unknown as Record<string, unknown>
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
MaybeAsync
} from "@polywrap/core-js";

export interface Args_methodOne extends Record<string, unknown> {
export interface Args_methodOne {
str: Types.String;
optStr?: Types.String | null;
}

export interface Args_methodTwo extends Record<string, unknown> {
export interface Args_methodTwo {
arg: Types.UInt32;
}

Expand Down
Loading