-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
"@remix-run/dev": patch | ||
--- | ||
|
||
Do not interpret JSX in .ts files | ||
|
||
While JSX is supported in `.js` files for compatibility with existing apps and libraries, | ||
`.ts` files should not contain JSX. By not interpreting `.ts` files as JSX, `.ts` files | ||
can contain single-argument type generics without needing a comma to disambiguate from JSX: | ||
|
||
```ts | ||
// this works in .ts files | ||
|
||
const id = <T>(x: T) => x; | ||
// ^ single-argument type generic | ||
``` | ||
|
||
```tsx | ||
// this doesn't work in .tsx files | ||
|
||
const id = <T>(x: T) => x; | ||
// ^ is this a JSX element? or a single-argument type generic? | ||
``` | ||
|
||
```tsx | ||
// this works in .tsx files | ||
|
||
const id = <T,>(x: T) => x; | ||
// ^ comma: this is a generic, not a JSX element | ||
|
||
const component = <h1>hello</h1> | ||
// ^ no comma: this is a JSX element | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters