[GH-ISSUE #929] Parsers are missing in the type definitions #558

Closed
opened 2026-03-03 01:28:00 +03:00 by kerem · 2 comments
Owner

Originally created by @JPeer264 on GitHub (Aug 11, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/929

Parsers with following type have been introduced here:

parsers: {
  markdownit: { tokens: markdownit.Token[]  };
  micromark: { tokens: micromark.Token[] };
};

Types for:

I could add a PR. But I am afraid I need to install @types/markdown-it into the dependencies to make them available for the type declarations. Unless there is a better way of doing this.

Originally created by @JPeer264 on GitHub (Aug 11, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/929 Parsers with following type have been introduced [here](https://github.com/DavidAnson/markdownlint/commit/1461ad6272ce4b67a87d27d1cc001c3f365260f9#diff-807e51fda288b4ebd0ccd4229d72a4c025f9b9316b0244ac45e76d8ff2317269R568): ```ts parsers: { markdownit: { tokens: markdownit.Token[] }; micromark: { tokens: micromark.Token[] }; }; ``` Types for: - `markdownit.Token`: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/markdown-it/lib/token.d.ts#L8 - `micromark.Token`: https://github.com/DavidAnson/markdownlint/blob/main/helpers/micromark.cjs#L16 I could add a PR. But I am afraid I need to install `@types/markdown-it` into the dependencies to make them available for the type declarations. Unless there is a better way of doing this.
kerem 2026-03-03 01:28:00 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Aug 11, 2023):

markdown-it tokens are already defined in the .d.ts file: github.com/DavidAnson/markdownlint@d641caf90c/lib/markdownlint.d.ts (L139)

micromark tokens and the micromark parser are not documented or referenced because they are not officially supported for use by plug-ins yet.

Is there something you think is missing?

<!-- gh-comment-id:1675024219 --> @DavidAnson commented on GitHub (Aug 11, 2023): markdown-it tokens are already defined in the .d.ts file: https://github.com/DavidAnson/markdownlint/blob/d641caf90ca67660a1939e50f6cc8acb1939819f/lib/markdownlint.d.ts#L139 micromark tokens and the micromark parser are not documented or referenced because they are not officially supported for use by plug-ins yet. Is there something you think is missing?
Author
Owner

@JPeer264 commented on GitHub (Aug 14, 2023):

Thanks for coming back that quickly. The main reason why I came up with this issue is that we're writing our own custom rules (and we're using typescript for it). Unfortunately, we took advantage of the undocumented, yet officially exported, helpers file.

Before we took the function forEachInlineChild, which got removed with the latest version: github.com/DavidAnson/markdownlint@ef1bd286a9 (diff-77185aed1). In a matter of fact, it got replaced with the not exported filterByTypes from micromark.cjs as shown here.

As these things are all undocumented, it would be an excellent opportunity for us to move away from these features and use the types we actually have.


Since parsers are not officially supported, I guess these lines can be changed to params.tokens since these are the same types: https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md#:~:text=params.parsers.markdownit.tokens

<!-- gh-comment-id:1676815898 --> @JPeer264 commented on GitHub (Aug 14, 2023): Thanks for coming back that quickly. The main reason why I came up with this issue is that we're writing our own custom rules (and we're using typescript for it). Unfortunately, we took advantage of the undocumented, yet [officially exported](https://github.com/DavidAnson/markdownlint/blob/d641caf/package.json#L9 ), [helpers file](https://github.com/DavidAnson/markdownlint/blob/d641caf90ca67660a1939e50f6cc8acb1939819f/helpers/helpers.js). Before we took the function `forEachInlineChild`, which got removed with the latest version: https://github.com/DavidAnson/markdownlint/commit/ef1bd286a9802e7242fc620a0b0a856df8b644b2#diff-77185aed1090adda14ba6426fa837ea81f1c778a03fb90761798f08c670ab484L455-L462. In a matter of fact, it got replaced with the not exported `filterByTypes` from `micromark.cjs` as [shown here](https://github.com/DavidAnson/markdownlint/commit/e8cc7eb3cb3e5f9f3a7276341e7c53ca302195ac#diff-8c61751df67014eedef463cbcc88590d10d4fffcf23c30f5f049f5f1a221e012R13-R28). As these things are all undocumented, it would be an excellent opportunity for us to move away from these features and use the types we actually have. --- Since `parsers` are not officially supported, I guess these lines can be changed to `params.tokens` since these are the same types: https://github.com/DavidAnson/markdownlint/blob/main/doc/CustomRules.md#:~:text=params.parsers.markdownit.tokens
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#558
No description provided.