[@types/jsdom] ConstructorOptions -> BaseOptions -> contentType is too restrictive #69511
Unanswered
CodingDoug
asked this question in
Issues with a @types package
Replies: 2 comments
-
Thanks for the discussion about "jsdom", some useful links for everyone: Pinging the DT module owners: @leonard-thieu, @palmfjord, @ExE-Boss. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Created #69520 to fix this |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The constructor options property is declared like this:
This means that contentType must only be one of the acceptable strings. However, this is too restrictive. The contentType attribute can also take a charset along with it (e.g.
text/html; charset=utf-8
). JSDOM observes this charset correctly, and is even documented as such (emphasis mine):My use cases requires that I provide a charset. Right now, I have to play games with TypeScript to get it to accept my string which is unknown at compile time (since it comes from an HTTP header).
I think
contentType
should accept any string, and the caller should accept that JSDOM will throw (as documented above) if it's not supported.Beta Was this translation helpful? Give feedback.
All reactions