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

Error: No overload matches this call after library update. #227

Closed
4 tasks done
olafurw opened this issue Aug 18, 2023 · 5 comments
Closed
4 tasks done

Error: No overload matches this call after library update. #227

olafurw opened this issue Aug 18, 2023 · 5 comments
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on

Comments

@olafurw
Copy link

olafurw commented Aug 18, 2023

Initial checklist

Affected packages and versions

11.0.1

Link to runnable example

No response

Steps to reproduce

We are using the library basically in the same way as the example

unified()
  .use(remarkParse)
  .use(remarkGfm)
  .use(remarkRehype)
// etc

And in version 10.1.2 it works great but if I update it to version 11.0.1 I get this error from svelte-check (4.2.0)

I tried clicking on these Link to runnable example to create a runnable example but none of the links work. Let me know if you still need it and I'll try to set something up.

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'

Expected behavior

No error

Actual behavior

Error above.

Affected runtime and version

vite@4.4.9

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

Vite

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Aug 18, 2023
@remcohaszing
Copy link
Member

The unified ecosystem is in the process of being upgraded with breaking changes. unified has been updated, but the remark plugins not yet. Use unified 10 until then.

@remcohaszing remcohaszing closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2023
@github-actions

This comment has been minimized.

@leafac
Copy link

leafac commented Aug 31, 2023

First of all, thank y’all for your work on the unified ecosystem. It’s a joy to use and I really appreciate what you’re doing here 🤗

Now, I’ll add some information to help out the next person who arrives here after some confusion and some Googling 😅

Solution 1: Tell TypeScript to ignore the type errors

Use the @ts-expect-error comment. The example of remark’s README ends up looking like this:

import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import rehypeSanitize from 'rehype-sanitize'
import rehypeStringify from 'rehype-stringify'

main()

async function main() {
  const file = await unified()
    // @ts-expect-error
    .use(remarkParse)
    // @ts-expect-error
    .use(remarkRehype)
    .use(rehypeSanitize)
    .use(rehypeStringify)
    .process('# Hello, Neptune!')

  console.log(String(file))
}

This seems scary, but the maintainers of the unified ecosystem suggest that this is okay. Apparently the types changed, but the underlying code works even across parts of the ecosystem that have been updated and parts that haven’t been updated yet. My preliminary tests confirm this.

Note that at some point the rest of the ecosystem will be updated as well, and by then TypeScript will complain about the @ts-expect-error comments that were left behind.

Solution 2: Revert to older versions of the packages

Go to the package’s page on npm and look for an older version under the Versions tab (for example, here’s the Versions tab for remark). The version numbers, release dates, and number of downloads should make it fairly straightforward to figure out an appropriate older version. Then tell npm to install that specific version, for example:

$ npm install unified@10.1.2 rehype-parse@8.0.5 rehype-stringify@9.0.4 hast-util-to-string@2.0.0

References:

@olafurw
Copy link
Author

olafurw commented Aug 31, 2023

Hey @leafac,

Solution 1 isn't a solution. The ticket is about type problems, telling TS to ignore the type problem doesn't solve anything.
Solution 2 is the same thing that @remcohaszing wrote above.

So your very detailed comment (that probably took a little while to write) boils down to

  • 1: Tell TS to stop complaining
  • 2: Same answer as already given before.

So I'm just confused about the purpose of the comment, that's all.

@wooorm
Copy link
Member

wooorm commented Aug 31, 2023

’cause it’s more detailed, and from a users’ perspective.

For my opinion, TS is a linter. It gets things wrong all the time. You don‘t always have to listen to it. You can use new tools already. And update the rest when that’s ready. It works, and if it doesn’t yet then raise an issue, so we can get stuff in earlier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

4 participants