Skip to content
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

feat: type definitions, es modules usage #25

Merged
merged 3 commits into from
Dec 22, 2020
Merged

feat: type definitions, es modules usage #25

merged 3 commits into from
Dec 22, 2020

Conversation

t-richards
Copy link
Contributor

@t-richards t-richards commented Aug 25, 2020

This PR:

  1. Adds a set of TypeScript type definitions (.d.ts) to the library.
  2. Adds example code to the readme for using the library via ES modules.

Testing

How I tested these type definitions locally:

  1. Convert all test/ files from .js -> .ts
  2. Add @types/node, @types/mocha, ts-node, typescript packages
  3. Convert all top-level variables in tests from const -> let
  4. mocha -r ts-node/register test/*.ts
  5. Expect tests to pass!

@sbordet
Copy link
Member

sbordet commented Aug 25, 2020

@t-richards thanks for the PR, but I would like you to open an issue first to discuss what is the problem first and what's the best way to solve it.

I don't see what the problem is right now?
We don't use TS and I don't see why we should?
I am genuinely asking, thanks.

@t-richards
Copy link
Contributor Author

t-richards commented Aug 25, 2020

Comment moved --> #26.

@sbordet
Copy link
Member

sbordet commented Aug 25, 2020

@t-richards yes please open an issue with your comment and let's continue the discussion there.

@@ -0,0 +1,12 @@
export interface Proxy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add the license boilerplate at the beginning of the file - copy it from cometd-nodejs-client.js.

@@ -0,0 +1,12 @@
export interface Proxy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to rename this to HttpProxy?

@sbordet
Copy link
Member

sbordet commented Aug 27, 2020

@t-richards, since you've done it, would you contribute also (maybe another PR) at least one test (converted or new) in TS?

Can tests be run by mocha in "mixed" mode, i.e. some of them in TS and some in JS?

@t-richards
Copy link
Contributor Author

@sbordet I believe that mocha can run mixed TypeScript / JavaScript tests.

That said, if the test conversion process from JS -> TS is somewhat straightforward, I think it might make sense to convert them all in one go and not bother with the mixed mode. I will try this out in a separate PR.

@t-richards t-richards requested a review from sbordet September 4, 2020 18:40
@sbordet sbordet merged commit 9eb89f1 into cometd:master Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The library is difficult to use with a strict TypeScript configuration
2 participants