-
Notifications
You must be signed in to change notification settings - Fork 14
fix: Only enable TypeScript jsx compiling for .js, .jsx, and .tsx files
#45
fix: Only enable TypeScript jsx compiling for .js, .jsx, and .tsx files
#45
Conversation
lib/simple_tsify.js
Outdated
| compilerOptions: { | ||
| esModuleInterop: true, | ||
| jsx: 'react', | ||
| jsx: ext === '.ts' ? undefined : 'react', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the default react and only turns it off if the extension is .ts. I think it should be flipped, so it's only set to react if the extension is .tsx (maybe .jsx too? not sure if that makes sense or is necessary). Seems more future-proof, so if some framework foo creates a TypeScript-compatible extension .tsf, it doesn't switch to react mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'react' isn't the only option, but probably the most common. Should there be a way to configure this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, how about changing it to ext === '.js' || ext === '.jsx' || ext === '.tsx'? Many developers use JSX syntax with .js files. I think it's safer to include .js files to the list.
There are 4 options: undefined, "react", "preserve", "react-native".
But "preserve" and "react-native" don't make sense here. Cypress transpiles the test code and sends it to the browser and runs it. When we select "preserve" or "react-native" option, the code cannot be executed on browsers. Because JSX is not compiled and they're still <X /> in the transpiled code.
Currently, developers use .js, .jsx, .tsx extensions to include JSX syntax. And .ts doesn't allow JSX syntax. AFAIK, there is no other scenario. So, I don't think providing option to allow other jsx TypeScript compile options is an over-spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, how about changing it to ext === '.js' || ext === '.jsx' || ext === '.tsx'
That sounds reasonable.
.js, .jsx, and .tsx files
|
🎉 This PR is included in version 2.2.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Fixes #44.