Generated a typescript client that have optional query parameters that is slice of string.
encore gen client -e local -l typescript > ./client.ts
type queryParameters struct {
Name []string `query:"id" encore:"optional"`
}
func World(ctx context.Context, query queryParameters) (*Response, error) {
rlog.Debug("hello world", "query", query)
msg := "Hello, " + "!"
return &Response{Message: msg}, nil
}
result in
export interface queryParameters {
Name?: string[]
}
const query = makeRecord<string, string | string[]>({
id: params.Name.map((v) => v),
})
and IDE is complaining that params.Name might be undefined.
Reproducible repo
https://github.com/PhakornKiong/encore-ts-codegen/blob/master/client.ts
Probably can be fixed by optional chaining?
