Conversation
If the Props type isn’t defined, it now falls back to an empty shape instead of any. Also all keys are marked as readonly. As a result, props are no longer represented using the string `Props`, but an inline representation of the shape of the props. Given that the upcoming support for an MDX layout also requires a patched version of `Props`, this new setup is more consistent. Also the `props` description now contains a link to the props page on the MDX website.
🦋 Changeset detectedLatest commit: c7015d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| '', | ||
| '// @ts-ignore', | ||
| '/** @typedef {Props} MDXContentProps */', | ||
| '/** @typedef {0 extends 1 & Props ? {} : Props} MDXContentProps */', |
There was a problem hiding this comment.
{} is not an empty object type, it is an any type (minus null and undefined).
If you want to represent an empty object see https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts
There was a problem hiding this comment.
{} is indeed not an object. It is an empty shape whose properties may be accessed, in other words, everything except null or undefined. Likewise { toString(): string } is not an object, but a shape that has a toString() method that returns string, in other words, pretty much everything except null and undefined.
To represent an actual object, the object type can be used, or object & { someProprty: string }. However, typically this doesn’t matter.
The goal here, and often with TypeScript, is not to ensure this is an empty object. It’s to ensure this is a shape whose properties may be accessed, even if it has no properties.
There was a problem hiding this comment.
I’m going to merge this, because I really need this change. Feel free to open an issue if you strongly feel I’m wrong about this.
Initial checklist
Description of changes
If the Props type isn’t defined, it now falls back to an empty shape instead of any. Also all keys are marked as readonly. As a result, props are no longer represented using the string
Props, but an inline representation of the shape of the props.Given that the upcoming support for an MDX layout also requires a patched version of
Props, this new setup is more consistent.Also the
propsdescription now contains a link to the props page on the MDX website.