Skip to content

TypeScript inside the package #3

Open
artospaj wants to merge 3 commits into
ithinuel:masterfrom
artospaj:master
Open

TypeScript inside the package #3
artospaj wants to merge 3 commits into
ithinuel:masterfrom
artospaj:master

Conversation

@artospaj

@artospaj artospaj commented Jan 1, 2021

Copy link
Copy Markdown

I've done a TS mapping to be able to use the mqttsn-packet in my project and I'd like to share the results with you.

@artospaj

Copy link
Copy Markdown
Author

@ithinuel could you please take a look?

@ithinuel ithinuel left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for your contribution, I'm glad it can help you !

I don't know much about typescript so I have some questions:

  • Is there a way to test the validity of those new files ?
    eg, checking the APIs actually match and are not broken by futures changes ?
  • Can those test be tested in CI ?

Speeking of CI, I noticed that the nodejs versions in .travis.yml where long outdated. So I prepared #4 to bump them to latest version and latest LTS.

Comment thread index.d.ts Outdated
Comment thread packet.d.ts Outdated
@artospaj

Copy link
Copy Markdown
Author

@ithinuel thank you for pointing out the question regarding type validation, I've taken some time to verify what's possible and found out it can be partially done using:

npx tsc --allowJs --checkJs ./mqttsn.d.ts ./packet.d.ts

This led to few issues being fixed 🙇

Unfortunately, that's only a semantics and for sure it can let some logical errors pass. The only way I can know is to rewrite tests to TypeScript, to let compiler jump in when it detects any difference in types when API methods are used in test scenarios.

@ithinuel

Copy link
Copy Markdown
Owner

Thanks for looking into this.
Would you mind updating .travis.yml to add that check ?

Do you think it'd be reasonable to add a little .ts example to demo this lib using typescript ?
This could be run in CI to have at least a minimal typescript subset being tested.
EG: have SubscribeShortTopic turned into a Buffer and parsed back into an object ?

I could then use that as a reference if/when I find time to learn typescript 😄

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.

2 participants