-
-
Notifications
You must be signed in to change notification settings - Fork 26.6k
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
Typescript file in __tests__ with incorrect extension causes unrelated errors to be ignored in yarn build #9160
Comments
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Please leave open and fix, it's a big gotcha that let linting issues get to production in our case |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Feels like a major issue to us |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
let's just hope we don't allow errors through to production because of this |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
TypeScript does not support JSX inside of a |
But that shouldn't lead to real, unrelated errors in other files going
undetected
…On Wed, 19 May 2021, 18:58 Ian Sutherland, ***@***.***> wrote:
Closed #9160 <#9160>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9160 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYCFS6MM5DGJMPI5VN6NXLTOP33JANCNFSM4N6MPFTQ>
.
|
Describe the bug
We're in the middle of a conversion to typescript and found that
noImplicitAny
errors weren't getting reported inreact-scripts build
which was incorrectly succeeding.I've now isolated the cause which is a very odd one based on the presence of any typescript files with incorrect extensions in
__tests__
directories. To be clear, the errors that should be getting reported are in regular react files/directories, not the__tests__
folder (i.e. this isn't the same as #5626).So if there is a file containing jsx with the incorrect extension
ts
instead oftsx
, and it is in a__tests__
folder, then allnoImplicitAny
errors get blotted out wherever they are andreact-scripts build
succeeds.VS Code reports the errors throughout.
Did you try recovering your dependencies?
Yes
yarn --version:
Which terms did you search for in User Guide?
typescript, noImplicitAny
Environment
Environment Info:
current version of create-react-app: 3.4.1
running from C:\Users\me\AppData\Local\Yarn\Data\global\node_modules\create-react-app
System:
OS: Windows 10 10.0.17134
CPU: (4) x64 Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
Binaries:
Node: 12.14.1 - C:\Program Files\nodejs\node.EXE
Yarn: 2.0.0-rc.35 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1098.0
Internet Explorer: 11.0.17134.1
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
const someFunc = a => a
) and use it in the app component.yarn build
and you will see the correct noImplicitAny error.const a = <div />
yarn build
, which will now succeed without errors or warnings even though our App.jsx still has a clear typescript error in it.yarn build
then correctly gives an error due to the wrong file extension.or
6b. Rename the .ts file to have a .tsx extension and then
yarn build
gives the correct error as in step 3.See my reproducible example on GitHub below.
Expected behavior
It should either give the typescript parse error due to incorrect extension which shows when moving the file out of
__tests__
, or it should give thenoImplicitAny
error that shows when correcting the file extension totsx
but leaving in__tests__
.Ideally the first, but that may not be possible yet due to #5626.
Actual behavior
yarn build
reports no errors and builds successfully despite there being a clear typescript error in theindex.tsx
file. The error is correctly reported if the__tests__
folder is deleted or if the file in it is renamed to have the correct.tsx
extension.Reproducible demo
https://github.com/mungojam/MRE-Typescript-Non-Error
The build succeeds, when it should fail.
Then to make it correctly fail, either switch to either of the other branches, or manually:
src/__tests__/a.ts
file extension to tsxOr
src/__tests__/a.ts
file extension to thesrc
folder.yarn build
which then gives the correct error about the file not being parsable, because it has jsx in it with the wrong file extension.The text was updated successfully, but these errors were encountered: