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

Fix building with TypeScript 5.5 #247

Closed
wants to merge 1 commit into from
Closed

Conversation

remcohaszing
Copy link
Member

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

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.

We ran into a regression when building unified with TypeScript 5.5.
Splitting the overload into 2 separate overloads fixes it.
@remcohaszing remcohaszing added 🐛 type/bug This is a problem 👶 semver/patch This is a backwards-compatible fix ☂️ area/types This affects typings 🤞 phase/open Post is being triaged manually labels Jul 16, 2024
@remcohaszing
Copy link
Member Author

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

CI fails, because of type-coverage.

@remcohaszing
Copy link
Member Author

Apparently type-coverage even fails for a good reason.

@wooorm
Copy link
Member

wooorm commented Jul 16, 2024

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
Copy link
Member Author

Does it also accept true, or just false?

@wooorm
Copy link
Member

wooorm commented Jul 16, 2024

both, see code:

unified/lib/index.js

Lines 628 to 636 in 242105b

if (options[0] === false) {
continue
}
if (options[0] === true) {
options[0] = undefined
}
const transformer = attacher.call(self, ...options)

@remcohaszing
Copy link
Member Author

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
Copy link
Member

wooorm commented Jul 16, 2024

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
Copy link
Member

wooorm commented Jul 16, 2024

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.

@wooorm wooorm closed this Jul 16, 2024
@wooorm wooorm added the 🤷 no/invalid This cannot be acted upon label Jul 16, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jul 16, 2024
wooorm added a commit that referenced this pull request Jul 16, 2024
@wooorm
Copy link
Member

wooorm commented Jul 16, 2024

thanks for looking into this, remco!

wooorm added a commit that referenced this pull request Jul 16, 2024
@remcohaszing remcohaszing deleted the fix-typescript-5.5 branch July 18, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☂️ area/types This affects typings 🤷 no/invalid This cannot be acted upon 👎 phase/no Post cannot or will not be acted on 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem
Development

Successfully merging this pull request may close these issues.

2 participants