-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
π Search Terms
tsx, jsx, children, 5.8
π Version & Regression Information
- This changed between versions 5.7.3 and 5.8
- This changed in commit or PR 60880
β― Playground Link
No response
π» Code
declare global {
namespace JSX {
type Element = HTMLElement; /* return type for 'jsx()' */
/* accepted element tags & attributes */
type IntrinsicElements = {
/* All HTML elements */
[Tag in keyof HTMLElementTagNameMap]: {
[T in HTMLElementStringAttributes<Tag>]?: string | Dyn<string>;
} & {
[T in HTMLElementNumberAttributes<Tag>]?: number | Dyn<number>;
} & (Tag extends keyof TwrlOverrides ? TwrlOverrides[Tag] : {}) & {
style?: string /* note: This should probably be CSSStyleDeclaration */;
// BREAKS HERE without this: children?: Children /* defines the type of children */;
};
};
}
}π Actual behavior
The breaking change is not listed in the 5.8 Release Notes
π Expected behavior
The breaking change should be listed in the 5.8 Release Notes
Additional information about the issue
I ran into issues when upgrading TypeScript and narrowed it down to 5.7.3 to 5.8. The issues is that children is not inferred by default.
Luckily I came across this discussion: #61354
This led me to this PR: #60880
It would have been much faster if the (breaking) change had been mentioned in the 5.8 release notes. Moreover, one (apparent?) side effect of #61354 is that children does not have a default anymore (i.e. if JSX.ElementChildrenAttribute is not set, pre-5.8 children would be accepted; post-5.8 not anymore).
Here's the JSX implementation that surfaced the issue for me:
declare global {
namespace JSX {
type Element = HTMLElement; /* return type for 'jsx()' */
/* accepted element tags & attributes */
type IntrinsicElements = {
/* All HTML elements */
[Tag in keyof HTMLElementTagNameMap]: {
[T in HTMLElementStringAttributes<Tag>]?: string | Dyn<string>;
} & {
[T in HTMLElementNumberAttributes<Tag>]?: number | Dyn<number>;
} & (Tag extends keyof TwrlOverrides ? TwrlOverrides[Tag] : {}) & {
style?: string /* note: This should probably be CSSStyleDeclaration */;
children?: Children /* defines the type of children */; // <- this is now REQUIRED
};
};
}
}Fix: nmattia/twrl@d83fde4#diff-8e3158c55134a198f9c40ac714ce358df04312a9ca77d7726e1813fb2ba5b5c0R34