Compilation error upgrading to 13.0.0 #150
-
Hi all, I'm getting the following error on CI following an upgrade to 13.0.0
It's not obvious to me how to resolve this... The docs still recommend following this pattern, but Vercel seems unhappy with it. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hey! Duplicate of #149. |
Beta Was this translation helpful? Give feedback.
-
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 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 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 [email protected] [email protected] [email protected] [email protected] References: |
Beta Was this translation helpful? Give feedback.
@awwsmm that goes back to @wooorm's original message.
In unified 11 (and rehype 13) the types were made stronger.
Not all plugins have been updated to match yet (unifiedjs/unified#228, unifiedjs/unified#227)
There are several hundred plugins being upgraded, it will take a bit for the upgrade to make its way through the ecosystem.
For now you can either: