Skip to content

Returning a bare Promise from map errors at runtime without a TypeScript error #54

@tom-sherman

Description

@tom-sherman

Reproduction:

class MyApiServer extends RpcTarget {
  getNames() {
    return ["Alice", "Bob", "Charlie"];
  }

  greet(name: string) { return `Hello ${name}` }
}

declare const api: RpcStub<MyApiServer>

await api.getNames().map(async name => {
  await someTask();
  return api.greet(name);
})

IMO this should be a type error to be able to call .map() type safe. The user should get an error here because they're returning something that's not Result or valid container or constant serializable value. I'd expect when returning a native promise to get an error here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions