Skip to content

Basic TypeScript example using reorg-rehype fails to compile #215

@RangHo

Description

@RangHo

With TypeScript 5.2.2, the simple example below fails to compile due to mismatched type signature.

import { reorg } from '@orgajs/reorg';
import toRehype from '@orgajs/reorg-rehype';
import toHtmlString from 'rehype-stringify';

const pipeline = reorg().use(toRehype).use(toHtmlString);

The error message reads:

src/test.ts:5:51 - error TS2769: No overload matches this call.
  Overload 1 of 3, '(plugin: Plugin<[], Node, Node>, ...settings: [boolean] | []): Processor<any, Node<Data>, Node<Data>, void>', gave the following error.
    Argument of type 'Plugin<[(Options | null | undefined)?], Root, string>' is not assignable to parameter of type 'Plugin<[], Node, Node>'.
  Overload 2 of 3, '(tuple: [Plugin<any[], Node<Data>, Node<Data>>, ...any[]] | [Plugin<any[], Node<Data>, Node<Data>>, boolean]): Processor<...>', gave the following error.
    Argument of type 'Plugin<[(Options | null | undefined)?], Root, string>' is not assignable to parameter of type '[Plugin<any[], Node<Data>, Node<Data>>, ...any[]] | [Plugin<any[], Node<Data>, Node<Data>>, boolean]'.
  Overload 3 of 3, '(presetOrList: Preset | PluggableList): Processor<any, Node<Data>, Node<Data>, void>', gave the following error.
    Argument of type 'Plugin<[(Options | null | undefined)?], Root, string>' is not assignable to parameter of type 'Preset | PluggableList'.

5 export const pipeline = reorg().use(toRehype).use(toHtmlString);
                                                    ~~~~~~~~~~~~

Since the example above works fine under non-typed situations (ESBuild, vanilla JS, etc.), a workaround is possible with // @ts-expect-error directive before the problematic line. I do believe that this is not ideal, though...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions