unifiedjs / unified

☔️ interface for parsing, inspecting, transforming, and serializing content through syntax trees
https://unifiedjs.com
MIT License
4.49k stars 110 forks source link

TypeScript error when doing simple unified markdown pipeline #229

Closed pudo closed 1 year ago

pudo commented 1 year ago

Initial checklist

Affected packages and versions

unified 11.0

Link to runnable example

https://github.com/opensanctions/site/blob/main/lib/util.tsx#L11-L20

Steps to reproduce

I'm trying to just build a string of markdown into some HTML using TypeScript and unified. When attempting to upgrade from unified 10 to 11, the very simple call syntax present in the README file of this project is rejected because of type inconsistencies. All the other dependencies are up to date, so I'm a curious if there may be a need to updated the usage as per README?

Expected behavior

The same pipeline works flawlessly using unified 10.

Actual behavior

./lib/util.tsx:13:10
Type error: No overload matches this call.
  Overload 1 of 3, '(preset?: Preset | null | undefined): Processor<undefined, undefined, undefined, undefined, undefined>', gave the following error.
    Type 'Plugin<[(Options | undefined)?], string, Root>' has no properties in common with type 'Preset'.
  Overload 2 of 3, '(list: PluggableList): Processor<undefined, undefined, undefined, undefined, undefined>', gave the following error.
    Argument of type 'Plugin<[(Options | undefined)?], string, Root>' is not assignable to parameter of type 'PluggableList'.
  Overload 3 of 3, '(plugin: Plugin<[], undefined, undefined>, ...parameters: [] | [boolean]): Processor<undefined, undefined, undefined, undefined, undefined>', gave the following error.
    Argument of type 'Plugin<[(Options | undefined)?], string, Root>' is not assignable to parameter of type 'Plugin<[], undefined, undefined>'.
      The 'this' types of each signature are incompatible.
        Type 'Processor<undefined, undefined, undefined, undefined, undefined>' is not assignable to type 'Processor<Root, Root, void, void>'.
          Types of property 'use' are incompatible.
            Type '{ <Parameters_2 extends unknown[] = [], Input extends string | Node | undefined = undefined, Output = Input>(preset?: Preset | null | undefined): Processor<undefined, undefined, undefined, undefined, undefined>; <Parameters_2 extends unknown[] = [], Input extends string | ... 1 more ... | undefined = undefined, Outp...' is not assignable to type '{ <PluginParameters extends any[] = any[], Input = Root, Output = Input>(plugin: Plugin<PluginParameters, Input, Output>, ...settings: [boolean] | PluginParameters): UsePlugin<...>; <PluginParameters extends any[] = any[], Input = Root, Output = Input>(tuple: [...] | [...]): UsePlugin<...>; (presetOrList: Preset | P...'.
              Types of parameters 'preset' and 'plugin' are incompatible.
                Type 'Plugin<any, any, any>' has no properties in common with type 'Preset'.

  11 | export function markdownToHtml(markdown: string): string {
  12 |   const result = unified()
> 13 |     .use(remarkParse)
     |          ^
  14 |     .use(remarkRehype, { allowDangerousHtml: true })
  15 |     .use(rehypeRaw)
  16 |     .use(rehypeHighlight)

Affected runtime and version

node@20.4.0

Affected package manager and version

9.7.2

Affected OS and version

No response

Build and bundle tools

Next.js

remcohaszing commented 1 year ago

Duplicate of https://github.com/unifiedjs/unified/issues/227

github-actions[bot] commented 1 year ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

github-actions[bot] commented 1 year ago

Hi! Thanks for taking the time to contribute!

Because we treat issues as our backlog, we close duplicates to focus our work and not have to touch the same chunk of code for the same reason multiple times. This is also why we may mark something as duplicate that isn’t an exact duplicate but is closely related.

Thanks, — bb