-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[chore] separate RequestHeaders and ResponseHeaders types #2248
Conversation
🦋 Changeset detectedLatest commit: 3c57c7c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
ead8eee
to
03c7ef9
Compare
ecb182b
to
034fef7
Compare
fa5de32
to
e6251ce
Compare
I know we've discussed this on discord, but man it feels really wrong to type cast everywhere, almost as wrong as using I'm still hoping there's another way around this, how did other frameworks handle this, and how did we get this far with having Edit:
I meant this as "how is there no general |
e6251ce
to
66f7915
Compare
Ok, I added a function to get the header rather than using the type cast |
66f7915
to
27f9708
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really conflicted on this one, I hope it's okay if I call in another pair of eyes again 😅 @dummdidumm
Also, I haven't tried this so it might not work, but since we never (or rarely) use the string[]
value from headers, we can probably get away with keeping them as string
internally, but have them exported publicly as string | string[]
, so it'll only be loose when used outside of development, importing from @sveltejs/kit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor, too. It's pragmatic, and we could change it some time in v2 if TypeScript is then able to type this.
How to handle this internally: I don't know where the public points are where users can use this, but the idea of having a transformation in one place and use string
internally sounds nice and a little bit better than the current approach of always using the method. So my approval is more about the external change, and if the internal code can be refactored a bit to make the typings easier that would be great.
Alright, sounds good! It may take a while (or never if it isn't possible), but I'll try to think of a way we can achieve having only |
There doesn't seem to be a way to tell TypeScript that only
set-cookie
can be astring[]
, so just say that all header values can bestring | string[]
and deal with doing type assertions internally so that we can make things nice for our users