microsoft / microsoft/TypeScript
Add JSX.ElementChildrenAttribute change to TypeScript 5.8 release notes
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
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
```ts
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]?: string | Dyn;
} & {
[T in HTMLElementNumberAttributes]?: number | Dyn;
} & (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: https://github.com/microsoft/TypeScript/issues/61354
This led me to this PR: https://github.com/microsoft/TypeScript/pull/60880
It would have been much faster if the (breaking) change had been mentioned in the [5.8 release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-8.html). 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:
```typescript
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]?: string | Dyn;
} & {
[T in HTMLElementNumberAttributes]?: number | Dyn;
} & (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: https://github.com/nmattia/twrl/commit/d83fde44202536c52f2816094fdcc4910c945c85#diff-8e3158c55134a198f9c40ac714ce358df04312a9ca77d7726e1813fb2ba5b5c0R34
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review PR 60880 and issue 61354 to confirm the JSX.ElementChildrenAttribute behavior change, then compare it with the TypeScript 5.8 release notes. Update the 5.8 release-notes page to describe the breaking change and its effect on children inference, using the reported twrl example as context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100