Skip to content

Conversation

@forivall
Copy link

@forivall forivall commented Jan 6, 2018

I noticed that the typing for select defines a tuple type with a single item, and not an array type. This caused code such as

const userProps: string[] = [
  'city',
  'country'
]

c.api('/me').select(userProps).buildFullUrl()

to fail typechecking with the message

Argument of type 'string[]' is not assignable to parameter of type 'string | [string]'.
  Type 'string[]' is not assignable to type '[string]'.
    Property '0' is missing in type 'string[]'.

This also fixes typechecking for supplying multiple arguments, where c.api('/me').select('city', 'country').buildFullUrl() would get the message Expected 1 arguments, but got 2.

@msftclas
Copy link

msftclas commented Jan 6, 2018

CLA assistant check
All CLA requirements met.

@forivall
Copy link
Author

forivall commented Jan 6, 2018

Hmm, one thing i thought about: if you want to ensure that arrays have at least one element (i disagree that that should be done, but that's neither here nor there), the workaround that I have to do is

const userProps: string[] & [string] = [
  'city',
  'country'
]

@MIchaelMainer
Copy link
Contributor

@forivall Thank you for taking the time to open this pull request! I won't be able to get to this right away but we'll get this into the next update.

@muthurathinam
Copy link
Contributor

muthurathinam commented Jul 10, 2018

This is fixed in pull requests #76 and #77. hence closing.!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants