-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
Search Terms
JSX, TSX, React, extension
Suggestion
I'm creating a new issue because comments in the closed #26489 issue are ignored, but it's clear that many people want this.
It's annoying having to use a separate file extension just because you want to use JSX. Not all tooling supports the .tsx
extension. It also means you either need to always use .tsx
if there's a possibility of JSX usage or you need to keep renaming files when you add JSX to them. Neither are good UX.
I propose deprecating <Type>expr
in favor of as
(as suggested in #26489 (comment)). They do the same thing, but as
is not conflicting with JSX. No point in having duplicate syntax that does the same thing.
Alternatively, add a compiler flag to disable <Type>expr
, which means JSX could be supported for the .ts
extension when this compiler flag is used.
Use Cases
Examples
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.