microsoft / microsoft/TypeScript
Auto-closing of tags within curly braces `{}` does not work when parent element is same tag in JSX
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
typescript javascript jsx auto close closing div tag curly brackets braces
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSX auto-closing
⏯ Playground Link
💻 Code
import React from "react"
const Component = () => {
const foo = false
return (
<div> // this has to be a div, changing it to another tag (e.g. <main>) corrects the functionality of closing tag below
{foo && <div>} // does not auto close div here
</div>
)
}
🙁 Actual behavior
When working with JSX (both in TypeScript and JavaScript), the auto-closing functionality for HTML tags does not work as expected within curly braces {}. The closing tag (e.g., ) is not automatically inserted when opening a tag inside curly braces when the outer or parent element tag is the same.
🙂 Expected behavior
The auto-closing functionality should work for HTML tags within curly braces {} in JSX, just like it does for tags outside of curly braces. When opening a tag (e.g., <div>) within curly braces, the closing tag (e.g., </div>) should be automatically inserted even when parent element tag is the same.
Additional information about the issue
No response
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
Start by reproducing the JSX example in the linked TypeScript Playground, comparing the outer and inner elements when their tags match versus differ. Trace the auto-closing behavior for JSX expressions in the relevant TypeScript tooling, then verify that an opening tag inside curly braces receives its closing tag even when the parent uses the same tag.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100