This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
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
Merged
chrisbreiding
merged 4 commits into
cypress-io:master
from
sainthkh:ignore-react-syntax-in-ts-files
May 8, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 toreact
if the extension is.tsx
(maybe.jsx
too? not sure if that makes sense or is necessary). Seems more future-proof, so if some frameworkfoo
creates a TypeScript-compatible extension.tsf
, it doesn't switch toreact
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.
@chrisbreiding
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.@NicholasBoll
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 otherjsx
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.
That sounds reasonable.