unifiedjs / unified

☔️ interface for parsing, inspecting, transforming, and serializing content through syntax trees
https://unifiedjs.com
MIT License
4.49k stars 110 forks source link

Fix building with TypeScript 5.5 #247

Closed remcohaszing closed 4 months ago

remcohaszing commented 4 months ago

Initial checklist

Description of changes

We ran into a regression when building unified with TypeScript 5.5. Splitting the overload into 2 separate overloads fixes it.

This doesn’t require a new release. It just fixes the types if they are built now, the types published to npm are fine.

remcohaszing commented 4 months ago

I wasn’t aware unified accepts a boolean instead of options with for plugin though :thinking:

CI fails, because of type-coverage.

remcohaszing commented 4 months ago

Apparently type-coverage even fails for a good reason.

wooorm commented 4 months ago

I wasn’t aware unified accepts a boolean instead of options with for plugin though 🤔

.use(remarkToc, false)

That’s how presets can turn plugins off.


Build fails tho

remcohaszing commented 4 months ago

Does it also accept true, or just false?

wooorm commented 4 months ago

both, see code: https://github.com/unifiedjs/unified/blob/242105bd6e18c61ca10f37d99529b89f1be37518/lib/index.js#L628-L636

remcohaszing commented 4 months ago

I find this weird TBH. This means plugins can never require options.

Anyway, this is a TypeScript regression. I’ll make a reproduction. Maybe it’s best to pin typescript@~5.4.0 for now.

wooorm commented 4 months ago

This means plugins can never require options.

They’re called options, indeed ;) But it’s not correct, what you say: plugins can choose to disallow the case where they are not configured by throwing.

wooorm commented 4 months ago

Ok, I’ll just pin for now!

This repo already has a script to fix the types that TS generates, so perhaps that’s also possible.

github-actions[bot] commented 4 months ago

Hi! This was closed. Team: If this was merged, please describe when this is likely to be released. Otherwise, please add one of the no/* labels.

wooorm commented 4 months ago

thanks for looking into this, remco!