microsoft / microsoft/TypeScript
Using JSX syntax in a namespace may incorrectly use the exported members of the current namespace as intrinsic elements (starting with a lowercase letter)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
jsx namespace preserve export intrinsic
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about (no entries for this)
⏯ Playground Link
💻 Code
WITH jsx: preserve enabled in tsconfig.json
export namespace form {
export const input = null;
export const test = <input />
}
🙁 Actual behavior
generated code:
export var form;
(function (form) {
form.input = null;
form.test = <form.input />;
})(form || (form = {}));
🙂 Expected behavior
generated code:
export var form;
(function (form) {
form.input = null;
form.test = <input />;
})(form || (form = {}));
Additional information about the issue
In fact, I observed this problem in a certain version of swc (swc does not support preserve mode, and the problem can be reproduced without enabling preserve mode). Considering that swc largely replicates the behavior of tsc, I suspected that this problem also exists in ts, and it is true, but only in jsx: preserve mode
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 with the linked TypeScript Playground reproduction using jsx: preserve and compare its emitted JavaScript with the expected output. Trace the JSX transformation for lowercase intrinsic elements inside an exported namespace. Done means the namespace's exported input remains rather than becoming <form.input />, with a regression test covering the repro.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100