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

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

Open
RangHo opened this issue Oct 19, 2023 · 0 comments
Open

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

RangHo opened this issue Oct 19, 2023 · 0 comments

Comments

@RangHo
Copy link

RangHo commented Oct 19, 2023

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...

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

No branches or pull requests

1 participant