Closed tommy-mitchell closed 1 year ago
Makes sense! Do you mind reviewing the PR?
Just found this. Just what I need~
Lost track of this. I will merge the PR.
@richex-cn consider lowercasing the header
consider lowercasing the header
It still not work for me.
And #93 will solve it.
Originally I came here to file a bug report. In
index.d.ts
, theoptions.headers
property is declared using TypeScript's builtinHeaders
interface, which is different from the intended Node HTTP headers:https://github.com/thgh/rollup-plugin-serve/blob/6743a314411d24c373329d61236e215b7af20b0a/index.d.ts#L53-L56
However, while looking into it, I noticed that many of the type descriptions were slightly different from those declared in
index.js
using JSDoc tags. The TypeScript compiler actually already has a way of emitting type definitions from JS files, which can use the plugin's already-maintained JSDoc tags (and their comment descriptions) to create anindex.d.ts
file. Using this method, types could be automatically created on build and would only have to be maintained in the one file.I've tested this out on a local clone of the repo and it seems to work well. I'm happy to make a PR.
As an aside, the DefinitelyTyped definitions for Node HTTP includes a list of common headers, such as this list for
IncomingHTTPHeaders
. I'm not familiar with the types of headers used by this plugin, but by using these types IntelliSense can suggest the common headers[^1]:[^1]: Using TypeScript here as I'm more familiar with the syntax than with JSDoc. Idea still applies.