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

Type signature not matching server expected response #140

Open
toddheslin opened this issue Aug 25, 2023 · 0 comments
Open

Type signature not matching server expected response #140

toddheslin opened this issue Aug 25, 2023 · 0 comments

Comments

@toddheslin
Copy link

Expected Behavior

Typescipt doesn't complain for the correct server payload

Actual Behavior

The example in the repo show passing in an object with an accounts property:

courier-node/README.md

Lines 837 to 843 in 041a204

#### Updating user accounts
```ts
await courier.users.putAccounts("<USER_ID>", {
accounts: [{ account_id: "ACCOUNT_ID", profile: { foo: "bar" } }],
});
```

However, this creates a type error:

Argument of type '{ accounts: { account_id: string; profile: {}; }[]; }' is not assignable to parameter of type 'IUserAccount[]'.
  Object literal may only specify known properties, and 'accounts' does not exist in type 'IUserAccount[]'.

But this response actually works.

If we keep typescript happy with:

await courier.users.putAccounts("<USER_ID>",  [
  { account_id: "ACCOUNT_ID", profile: { foo: "bar" } }
]);

We get a 400 error with: { message: 'must be object', type: 'invalid_request_error' }

Steps to Reproduce the Problem

  1. Follow the docs example
  2. Observe the type error
  3. Make typescript happy
  4. Observe the 400 server error

Specifications

  • Version: 5.0
  • Platform: node18
  • Subsystem: macos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant