Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

If there are typescript typings for this module, it would be nice if it were in the readme #139

Closed
ORESoftware opened this issue Jul 11, 2017 · 7 comments

Comments

@ORESoftware
Copy link

ORESoftware commented Jul 11, 2017

If there are TS typings for this, it would help to document that something like so:

install

npm install JSONStream

install types

npm install -D @types/JSONStream

if there are not types, then this is a feature request for TS typings!

@dominictarr
Copy link
Owner

sure, please make a PR.

@EricByers
Copy link

There currently cannot be types for this module because DefinitelyTyped (who controls the @types/ on npm) will not let any non-lowercase modules made, this means even if it was added (as jsonstream lowercase) it wouldn't work :(.

See: #128

@ORESoftware
Copy link
Author

ORESoftware commented Jul 12, 2017

@EricByers ah you are under the mistaken impression that you need to publish to @types/X to get TS typings in place. You don't need to do that at all tmk.

All you need to do is include the *.d.ts files in this project itself, when publishing to NPM. You almost certainly need just one .d.ts file, let's say index.d.ts.

And then in your package.json, point "types" or "typings" properties to the main exported types file, let's say "index.d.ts".

Make sense?

So how it works, is I npm install JSONStream in my project and the .d.ts files are in node_modules and I can see it all and it just works great!

@ORESoftware
Copy link
Author

To further elucidate, I get this error when transpiling with TS:

index.ts(16,29): error TS7016: Could not find a declaration file for module 'JSONStream'. '/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-daemon/node_modules/JSONStream/index.js' implicitly has an 'any' type.

so all you need to do is generate index.d.ts, and you will be good to go :)

@EricByers
Copy link

I understand that process, I just wasn't expecting the app owner to accept it in and maintain it, most repos if they are not already written in TS.

@EricByers
Copy link

If you're willing to have it as any, you can import it as that way, and not worry about types at all. TS added support a few versions back.

@ORESoftware
Copy link
Author

I think he made it clear that we could submit a PR to create index.d.ts, without turning index.js into index.ts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants