-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat .js as JSX #6562
Treat .js as JSX #6562
Conversation
We should add a unit test with --allowJs and some JSX syntax in there, and make sure no errors are reported. |
👍 |
Why exactly are we doing this? |
@DanielRosenwasser Because ReactNative uses JSX directly in .js files, so this is becoming popular. VSCode has asked for this. As JSX is a superset, there is no ambiguity with plain JavaScript. |
Need to update the tests also. As expected, some errors changed now that parsing default has changed (though only 2, and the errors look like an improvement - good job! :-) ). Once done- 👍 |
@@ -546,7 +546,7 @@ namespace ts { | |||
|
|||
function getLanguageVariant(fileName: string) { | |||
// .tsx and .jsx files are treated as jsx language variant. | |||
return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx") ? LanguageVariant.JSX : LanguageVariant.Standard; | |||
return fileExtensionIs(fileName, ".tsx") || fileExtensionIs(fileName, ".jsx") || fileExtensionIs(fileName, '.js') ? LanguageVariant.JSX : LanguageVariant.Standard; |
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.
Double quotes.
No description provided.