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

TypeScript definition files #220

Closed
benjamingr opened this issue Oct 17, 2018 · 13 comments
Closed

TypeScript definition files #220

benjamingr opened this issue Oct 17, 2018 · 13 comments
Assignees
Labels

Comments

@benjamingr
Copy link
Member

@zyishai has volunteered to help work on updating the TypeScript types of lolex to a point where they are up to date with recent additions.

Currently we don't ship TypeScript types with the library and people get them from DefinitelyTyped through @types/lolex here https://www.npmjs.com/package/@types/lolex

I'm wondering if it makes sense to move the types to the lolex repo so we can better keep them in sync - it could also save an npm install for those users if we just provide a .d.ts for lolex.

I'm in favour of adding them here and hopefully migrate (properly and with attribution!) content from the definitely typed repo at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/c61b1db6eb1d45546d6e88af964d10f73aed309b/types/lolex/index.d.ts

cc @fatso83 @SimenB what do you think?

@benjamingr benjamingr changed the title TypeScript TypeScript definition files Oct 17, 2018
@zyishai
Copy link

zyishai commented Oct 17, 2018

@benjamingr I'll be glad to contribute! I'm still beginning my TS journey, hope I'll be able to help!

@fatso83
Copy link
Contributor

fatso83 commented Oct 17, 2018

@benjamingr as long as someone is willing to maintain them, I'm all for it. I don't have any interest in TS after using it in the past, and I don't think any of the other maintainers have either, but if you do and there seems to be other who do too (thus the definitely typed repo), I think it makes sense to embed them here.

@SimenB
Copy link
Member

SimenB commented Oct 17, 2018

FWIW, I use TS at work, but I don't use Lolex at work (and if we do at some point, it'll be through using it with Jest, so typing info for it wouldn't matter for us).

As long as we set up some build step that checks that the TS file is in sync with reality I'm all for adding it. I guess it's easier to keep up to date here.

Since TS supports jsdoc, we could also in theory type up our source code with comments and generate the declaration file as a build step. Not sure if we want that or not, though 🙂

@mgred
Copy link
Contributor

mgred commented Oct 18, 2018

I'm wondering if it makes sense to move the types to the lolex repo

Totally! The argument of saving users from having another dependency is super solid, in my opinion.

I'm in favour of adding them here and hopefully migrate (properly and with attribution!) content from the definitely typed repo at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/c61b1db6eb1d45546d6e88af964d10f73aed309b/types/lolex/index.d.ts

That's quite a good start 👍

As long as we set up some build step that checks that the TS file is in sync with reality I'm all for adding it

That would be really awsome

Since TS supports jsdoc, we could also in theory type up our source code with comments and generate the declaration file as a build step.

Nice idea, commenting types in code is always nice for unferstanding, I think. If we could benefit from that in terms of generating definitions files, that would be win-win.

I used to use TS at work a lot, so if any questions or task raise here, I'll try to help.

BTW: would be nice to have this for all projects

@mroderick
Copy link
Member

@benjamingr as long as someone is willing to maintain them, I'm all for it. I don't have any interest in TS after using it in the past, and I don't think any of the other maintainers have either, but if you do and there seems to be other who do too (thus the definitely typed repo), I think it makes sense to embed them here.

I share @fatso83's stance, and personally have no interest in TypeScript, nor in any of the maintenance work required to support a different language other than JavaScript.

I'd be much happier if the burden of maintaining TypeScript support would rest on the shoulders of that community, like flow-typed seem to be doing just fine for supporting lolex using Flow without any effort on our part.

Since TS supports jsdoc, we could also in theory type up our source code with comments and generate the declaration file as a build step.

That solution sounds promising to me, as that will give benefits to a much larger part of the community, whether they use TypeScript or not, and will work long after people have moved on from TypeScript to the Next Big Thing™️

I've been musing about using JSDoc in sinonjs/sinon#1651, so this is very much in line with my thoughts about the future of the Sinon family of libraries.

I wonder, would it be possible to derive the artefacts needed for Flow support from the same annotations, as that will increase the total benefit to the community from (nearly) the same effort?


Just so we're all on the same page, if supporting TypeScript turns out to be a significant maintenance burden and that no one is actually doing the work of continued support of TS long term (solution dependent), then I am fully prepared to remove it again. If we end up with a more or less self running solution via JSDoc (or similar), then obviously we'll keep it.

Having said all that, if someone volunteers to step up to do the initial work and to support TypeScript (maybe even Flow) going forwards, then I think we should talk about how we can best go about this.
Key to the success of the effort is to maximise benefit in the long term, with a reasonable initial effort and minimal maintenance burden.

@zyishai
Copy link

zyishai commented Nov 6, 2018

OK, just finished updating the types to version 3! for now, I opened PR to DefinitelyTyped. If you decide in the future that you want to include ts in this repo - tell me and I will PR here too 😊.
cc @benjamingr

@benjamingr
Copy link
Member Author

Thanks and awesome work! Let's see how the DT PR goes and close this when it lands :)

@stale
Copy link

stale bot commented Jan 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 6, 2019
@SimenB
Copy link
Member

SimenB commented Apr 18, 2019

Since this happened, Jest has been migrated to TS, so it's suddenly more interesting to me personally for the the typings file to live in this repo...
Main benefit to keeping it here rather than DT would be better autocomplete for everybody (at least if they use vs code or webstorm, probably more IDEs as well) regardless if they use TS or not

@benjamingr
Copy link
Member Author

@SimenB I'm up for it

@DominicTobias-b1
Copy link

Hi, are there typings now? Think I'll have to switch back to sinon main lib for typings

@SimenB
Copy link
Member

SimenB commented Mar 25, 2020

current status: #293 (comment)

@mroderick mroderick self-assigned this Jul 16, 2020
@fatso83
Copy link
Contributor

fatso83 commented May 28, 2021

@DominicTobias-b1 we started shipping typings with v7

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

No branches or pull requests

7 participants