pacedotdev / oto

Go driven rpc code generation tool for right now.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

With oto 0.11.0, TypeScript definitions with objects are wrong

opened this issue · comments

With the following API definition and the client.ts.plush template from the otohttp project, we get wrong TypeScript output. This can be reproduced with the current version, v0.11.0, but was not occurring with an older version, in my case v.0.10.14.

package definitions

type SessionService interface {
	UpdateSession(UpdateSessionRequest) UpdateSessionResponse
}

type UpdateSessionRequest struct { Customer *Customer }
type UpdateSessionResponse struct {}
type Customer struct {}

The wrong TypeScript code:

// removed for brevity
export class UpdateSessionRequest {
	constructor(data?: any) {
		if (data) {
			this.customer = new *Customer(data.customer);
		}
	}

	customer?: *Customer;
}
// removed for brevity

Noticing the star before the Customer? That's causing syntax errors.

@clord Did you fix this in another template recently?

@nachtjasmin thanks for reporting this. I've updated the template with a fix, can you try it and let me know if that works?