node-serialport icon indicating copy to clipboard operation
node-serialport copied to clipboard

Feature Request: Bundle Typescript types in published package

Open cinderblock opened this issue 4 years ago • 11 comments

💥 Proposal

What feature you'd like to see

Typescript types included in the distributed packages

Motivation

It would be nice to not need to install the @types/serialport package to use this in TypeScript (or just to get automatic type hinting in modern code editors).

Pitch

Take the types from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/serialport and publishe them in the various packages.

All that is needed is a package.json#types field that mirrors the package.json#main field. Looks like creating a types folder that matches the exported lib folder should work.

Related issues

https://github.com/serialport/node-serialport/issues/1790 DefinitelyTyped Serialport issues

cinderblock avatar May 12 '20 08:05 cinderblock

It would be possible to make @types/serialport a dependency, like react-testing-library does for their types. That way they could stay synced with those updates.

HipsterBrown avatar May 12 '20 14:05 HipsterBrown

https://github.com/DefinitelyTyped/DefinitelyTyped#create-a-new-package

If you are the library author and your package is written in TypeScript, bundle the autogenerated declaration files in your package instead of publishing to Definitely Typed.

I recognize that this is talking specifically about packages "written in TypeScript", but, frankly, I don't think that is a hard requirement. DefinitelyTyped is wonderful but we don't need to lean on them if we can just bundle the types directly.

cinderblock avatar May 13 '20 07:05 cinderblock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week no further activity occurs. Feel free continue the discussion or ask for a never-stale label to keep it open. If this is a support issue, consider sharing it on stack overflow to get more eyes on your problem.

stale[bot] avatar Jul 12 '20 08:07 stale[bot]

Can we get a never-stale?

cinderblock avatar Jul 12 '20 20:07 cinderblock

Yep!

reconbot avatar Aug 22 '20 18:08 reconbot

bundle it directly, we need @serialport/stream and so on, especially when using @serialport/stream only and implement custom bindings

lygstate avatar Dec 17 '20 10:12 lygstate

Looking into this a little, it looks like 'serialport' is using 'plop' to bundle packages in a consistent way.

Plot claims to support Typescript types automatically.

Maybe this means what's required is converting everything here to .ts?

cinderblock avatar Aug 18 '21 18:08 cinderblock

We need a build system in place and then to convert everything to typescript (not just the templates for new parsers)

reconbot avatar Aug 19 '21 12:08 reconbot

Starting on this with the new bindings for serialport v10 https://github.com/serialport/bindings-cpp/pull/3

reconbot avatar Jan 22 '22 15:01 reconbot

No promises but if I can make v10 completely in typescript I will

reconbot avatar Jan 22 '22 15:01 reconbot

[email protected] is using the typscript bindings

reconbot avatar Jan 23 '22 04:01 reconbot