Skip to content

Commit

Permalink
Merge pull request microavia#65 from pavletto/fix_sender_signature
Browse files Browse the repository at this point in the history
Fix sender signature in ts generator
  • Loading branch information
Zemledelec authored Feb 8, 2023
2 parents 70a8ac9 + 72acc93 commit a9e9a87
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions messgen/ts_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"uint16": "number",
"int32": "number",
"uint32": "number",
"int64": "number",
"uint64": "number",
"int64": "bigint",
"uint64": "bigint",
"float32": "number",
"float64": "number",
"float64": "bigint",
"string": "string",

}
Expand Down Expand Up @@ -95,9 +95,9 @@ def generate_import(self, module_name, msg_name):
def generate_send(self, name):
msg_name = to_camelcase(name)
return '''
send_%s(data: Partial<ClearSystemInfo<MessageData<"%s">>>) {
return this.send(this.messages.MSG_%s, data);
}''' % (msg_name,name, name.upper())
send_%s(data: ClearSystemInfo<MessageData<"%s">>, callback?: (data: ClearSystemInfo<MessageData<"%s">>) => void): any {
return this.send(this.messages.MSG_%s, data, callback);
}''' % (msg_name,name, name, name.upper())

def generate_on(self, name, id):
msg_name = to_camelcase(name)
Expand All @@ -109,7 +109,7 @@ def generate_on(self, name, id):
def generate_class(self, methods, name_file):
out = []
out.append('export default class %sHelper {' % (name_file))
out.append(" send(struct: Struct, data: Partial<ClearSystemInfo<MessageData>>) {}")
out.append(" send(struct: Struct, data: ClearSystemInfo<MessageData>, callback?: (...args: any) => any) {}")
out.append(" protected onmessage: {(args?: any): void}[] = []")
out.append(" protected messages!: Messages<MessageName>")
out.append("\n".join(methods))
Expand Down

0 comments on commit a9e9a87

Please sign in to comment.