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
Add TypeScript declarations and generate docs #54
Comments
If you understand a little bit of C++, you can explore wrapper headers. From a quick look, I can tell that HttpRequest has following methods:
and HttpResponse:
|
What happens if you print res.prototype? Or res.prototype.entries etc? |
My bad, forgot to take a look at the res's prototype 🧐 Anyway, I already used method described by @xxzefgh. But I think, that for some js-developers it can be hard to even look at c++ source code :) So docs would be great addition to such a cool library 🤓 Thank you, guys! |
Printing res should print also the proto? Or? It would be nice. |
Adding typescript declarations would probably help a lot both documenting (TypeDoc) and for IDEs. How do I add that? I don't want third parties involved who cannot keep up |
I'm talking about definitelytyped - they don't care about quality just quantity |
Where do I put my d.ts file for best effect? Can I just ship it in the NPM package and be done? |
Oh I just create uws.d.ts and put types field in package.json and boom! Now the project is TypeScript wow. A smart IDE will pick up that declaration file and apply to JavaScript as well yes? |
@alexhultman yes, either [filename].d.ts or index.d.ts will work. |
if you provide |
Oh wow it works. Visual Studio Code did pick up on the index.d.ts in node_modules right away and shows exactly what is what. I love solutions like these, one file, compatible with JS, adds documentation too. 👍 |
interface TemplatedApp { export function App(): TemplatedApp; I want TemplateApp to have functions how do I achieve such a dream |
interface TemplatedApp { export function App(): TemplatedApp; There's no integer type? |
There are now documentation generated from decl file: https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts WIP, but looks very beautiful! |
Documentation is pretty much done now, just need to have a release include that index.d.ts. |
Please do consider uploading this stub to the DefinitelyTyped repository as well: https://github.com/DefinitelyTyped/DefinitelyTyped. That is where, e.g., the JetBrains IDEs look for them. |
You don't need to upload them to third party, definitions are shipped with the module. Visual studio code pick up on them |
If you prefer to include the definitions with the module then you should include a It's possible VS Code goes beyond the call of duty and additionally looks for index.d.ts under the root but you can't expect every IDE to emulate VS Code. |
Hi Alex. I'm on VS Code using node 12+ with TS, but for some reason the IDE does not see the type definitions. I tried to manually reference them via So I can confirm the need of what olivier65 and xxzefgh suggested, i.e. add the |
If that helps can you PR it I forgot this issue |
Line 5 in a1d30bb
I added that line if it helps |
Is ./index.d.ts really Windows-compatible? |
I tested an older release on Windows / Visual Studio Code and it picked up on the type docs perfectly. According to the docs for package.json it should default to index.d.ts anyways. |
Because of native nature of your library it's impossible for IDEs to list methods of req and res objects. Also it's impossible to get methods and properties of this objects via Object.enties or Object.keys.
So the question is where to find an uWS's HTTP API reference?
The text was updated successfully, but these errors were encountered: