Skip to content

Fix typing for select, expand, and orderby#59

Closed
forivall wants to merge 1 commit into
microsoftgraph:devfrom
forivall:fix-types
Closed

Fix typing for select, expand, and orderby#59
forivall wants to merge 1 commit into
microsoftgraph:devfrom
forivall:fix-types

Conversation

@forivall

@forivall forivall commented Jan 6, 2018

Copy link
Copy Markdown

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

msftclas commented Jan 6, 2018

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@forivall

forivall commented Jan 6, 2018

Copy link
Copy Markdown
Author

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
Copy Markdown
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

muthurathinam commented Jul 10, 2018

Copy link
Copy Markdown
Contributor

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