Skip to content

Conversation

@janaagaard75
Copy link

No description provided.

@mhoeger
Copy link
Contributor

mhoeger commented Dec 20, 2018

@janaagaard75 - thank you again for this :) we decided to leave out HTTP response, especially for the first round of types, because our HTTP response object is actually an interesting blend of express-like and http module-like ways of crafting a Response.

For example, in a JavaScript function, you will notice that you can both set status as a value and set status as a function:

res = {
  body: {
    "hello": "world"
  },
  status: 200,
  headers: {
    "content-type": "application/json"
  }
};
res.status(200).json({ "hello": "world" });

Maybe the best answer is to support two types that let you choose which flavor of response you want, but essentially decided that we could release the rest without having to worry about what experience would be best there.

@janaagaard75
Copy link
Author

Thank you for getting back to me! And that can see that writing correct type definitions for the Azure functions is a more complicated than I anticipated.

Maybe the best answer is to support two types that let you choose which flavor of response you want.

Agree.

(Just filling in for those who like me, still have a lot to learn about type definitions: My first thought was that this could easily be solved by writing something like status: number | ((number) => any), but as stated in this answer you need to add a type guard to able to call status as a function, and that is quite annoying.)

We could release the rest without having to worry about what experience would be best there.

Again, I agree. I think the community is just hungry for an official release, so that we have a central place, where we can figure out how to write the best possible definitions.

Where will you announce the release?

@janaagaard75
Copy link
Author

janaagaard75 commented Dec 21, 2018

How about adding an interface for the HTTP response, and set status to any? I have seen @christopheranderson's comment about avoiding any, but isn't it a step in the right directly to have this crude interface for the HTTP response, instead of the whole response simply being marked as any?

interface HttpResponse {
     body?: any
     headers?: { [key: string]: any }
     isRaw?: boolean
     status?: any
 }

(Sorry that I haven't updated the pull request to match this.)

@janaagaard75
Copy link
Author

Any updates on this, @mhoeger? If this is something that is not going to happen, then just close this issue. 🙂

@mhoeger
Copy link
Contributor

mhoeger commented Jan 10, 2019

Hey @janaagaard75, no updates yet (was out for a bit, still working on pushing the initial types file). I don't think we'll be able to take this PR in, and I'd like to spend some more time fleshing out a more intentional plan for the HTTP response (to avoid breaking changes). Thanks again for the input though :) Closing this PR but adding an issue to track.

@mhoeger mhoeger closed this Jan 10, 2019
@mhoeger mhoeger reopened this Jan 10, 2019
@mhoeger mhoeger closed this Jan 10, 2019
@dnfclas
Copy link

dnfclas commented Jan 10, 2019

CLA assistant check
All CLA requirements met.

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.

3 participants