Closed olafurw closed 1 year ago
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.
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.
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:
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
So I'm just confused about the purpose of the comment, that's all.
’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
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
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.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