-
Notifications
You must be signed in to change notification settings - Fork 7
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
The library is difficult to use with a strict TypeScript configuration #26
Comments
What does |
Yes, while that would technically solve the build error, it does so in a way that I don't consider to be useful. If I were to only specify import { CometD } from 'cometd';
import { adapt } from 'cometd-nodejs-client';
adapt({ httpProxy: { uri: true, includes: ['example.com'] } });
const client = new CometD();
client.configure({ url: 'https://example.com' });
client.handshake((h) => {
if (!h.successful) {
console.error('Handshake was not successful');
}
}); The handshake does not fail because of the inability to connect to This is precisely the kind of error which I expect TypeScript to catch for me ahead of time, prior to running my code. |
@t-richards thanks for the explanations! Turns out that a major user of this library was also using TS and had an almost identical type definition, so I'm positive about merging your contribution. See PR for additional comments. |
@t-richards let me know if you're interested in contributing something similar for https://github.com/cometd/cometd-nodejs-server 😃 |
will this be merged? |
@alexanderkjeldaas yes it will. |
I have the following TypeScript code in my own project:
And the following TypeScript configuration (notably the "strict" and "noImplicitAny" options):
Given the above two things, attempting to call the
adapt()
function from this library results in a build error.In my opinion, the ideal solution to this problem would be for this library to provide a "TypeScript Declaration File" (
.d.ts
), in which exported functions and types are explicitly declared for use within TypeScript.Is this something the project considers to be desirable? If so, please see #25 for a proposed solution.
The text was updated successfully, but these errors were encountered: