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

Add TypeScript definition #17

Merged
merged 5 commits into from
Jan 14, 2021
Merged

Add TypeScript definition #17

merged 5 commits into from
Jan 14, 2021

Conversation

barmac
Copy link
Contributor

@barmac barmac commented Jan 13, 2021

This PR adds TypeScript definition for better developer experience (suggestions in the editor).

@sindresorhus
Copy link
Owner

Thanks for the PR, but I'm not interested in JSDoc. However, I'm happy to accept TypeScript types if you follow this styleguide?

Some examples:

@barmac
Copy link
Contributor Author

barmac commented Jan 14, 2021

Sure, I can do that! Please have a look now :)

@barmac barmac changed the title Add JSDoc Add TypeScript definition Jan 14, 2021
package.json Outdated
"xo": "^0.26.1"
},
"types": "index.d.ts",
Copy link
Owner

Choose a reason for hiding this comment

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

This is not needed.

index.test-d.ts Outdated
import setupElectronReloader = require('.');

expectType<void>(setupElectronReloader(module));
expectType<void>(setupElectronReloader(module, { watchRenderer: true }));
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
expectType<void>(setupElectronReloader(module, { watchRenderer: true }));
expectType<void>(setupElectronReloader(module, {watchRenderer: true}));

index.d.ts Outdated
* @param options.watchRenderer - Watch files used in the renderer process and reload the window when they change. Defaults to `true`.
* @param options.debug - Prints watched paths and when files change. Can be useful to make sure you set it up correctly.
* @param options.ignore - Ignore patterns passed to [`chokidar`](https://github.com/paulmillr/chokidar#path-filtering). By default, files/directories starting with a `.`, `.map` files, and `node_modules` directories are ignored. This option is additive to those.
*
Copy link
Owner

Choose a reason for hiding this comment

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

Drop the *.

index.d.ts Outdated
*/
declare function setupElectronReloader(
moduleObject: NodeModule,
options?: {
Copy link
Owner

Choose a reason for hiding this comment

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

Options should be a separate type and each option should have doc comments copied from the readme. See the guidelines.

index.d.ts Outdated
* setupElectronReloader(module, { ignore: [ 'client/src' ] });
* } catch (error) {
* console.error('Unable to setup reloading', error);
* }
Copy link
Owner

Choose a reason for hiding this comment

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

Use the example from the readme.

@barmac
Copy link
Contributor Author

barmac commented Jan 14, 2021

I've implemented the suggestions from your comments and think that it's ready for the second round 👍

@sindresorhus sindresorhus merged commit 559dbd3 into sindresorhus:master Jan 14, 2021
@sindresorhus
Copy link
Owner

Thanks :)

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