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

Please, add typescript types definitions to this module #3

Closed
micalevisk opened this issue Jun 7, 2021 · 1 comment · Fixed by #4
Closed

Please, add typescript types definitions to this module #3

micalevisk opened this issue Jun 7, 2021 · 1 comment · Fixed by #4
Labels
☂️ area/types This affects typings good first issue 👋 This may be a great place to get started! 🙆 yes/confirmed This is confirmed and ready to be worked on

Comments

@micalevisk
Copy link
Contributor

Problem

I'm using this lib with TypeScript and the TS compiler complains about the lack of typings:

Could not find a declaration file for module 'remark-unlink'. 'xxxx/node_modules/remark-unlink/index.js' implicitly has an 'any' type.
  Try `npm install @types/remark-unlink` if it exists or add a new declaration (.d.ts) file containing `declare module 'remark-unlink';`
ts(7016)

Solution

Create a types/index.d.ts file pretty much like strip-markdown, and update the files field of your package.json.

I think that the following will be enough:

declare module 'remark-unlink' {
  import type { Plugin } from 'unified';

  /**
   * Remark plugin to remove Markdown links, images, references, and definitions.
   */
  declare const remarkUnlink: Plugin;

  export = remarkUnlink;
}
@micalevisk micalevisk added 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Jun 7, 2021
@wooorm
Copy link
Member

wooorm commented Jun 7, 2021

Pull requests are welcome!
With ts definitions we tend to follow definitly typed's policy of including the typings, dtslint, and a type test.
The process is usually pretty quick, you can see some examples here: remarkjs/strip-markdown#21, remarkjs/remark-external-links#18, and remarkjs/remark-footnotes#4

Closing this issue out, as it is a goal across all 300+ unifier/remark repos, and keeping an open issue for each is a bit much 😅

@wooorm wooorm closed this as completed Jun 7, 2021
@wooorm wooorm added good first issue 👋 This may be a great place to get started! ☂️ area/types This affects typings 🙆 yes/confirmed This is confirmed and ready to be worked on and removed 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Jun 7, 2021
@micalevisk micalevisk mentioned this issue Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☂️ area/types This affects typings good first issue 👋 This may be a great place to get started! 🙆 yes/confirmed This is confirmed and ready to be worked on
Development

Successfully merging a pull request may close this issue.

2 participants