Skip to content
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

fix: exclude .spec and .test files from type checking #11886

Closed
wants to merge 1 commit into from

Conversation

jwalton9
Copy link

@jwalton9 jwalton9 commented Jan 5, 2022

This PR fixes react-scripts@5 including test files when type checking during npm start and npm build. This was changed in the upgrade to webpack@5 https://github.com/facebook/create-react-app/pull/11201/files#diff-8e25c4f6f592c1fcfc38f0d43d62cbd68399f44f494c1b60f0cf9ccd7344d697R732 however the syntax does not exclude .spec and .test files.

There is a reproduction repo at https://github.com/jwalton9/cra-test-type-error which introduces a type error to src/App.test.tsx. Running npm start causes these issues to be reported.

The changes were validated by using npm link and running npm start

Fixes #11979

@facebook-github-bot
Copy link

Hi @jwalton9!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

schmidti159 added a commit to schmidti159/songskipper that referenced this pull request Jan 26, 2022
This currently breaks. Waiting for PR: facebook/create-react-app#11886

Update Spotify wrapper.
@gargrave
Copy link

Is there possibly an ETA on when this will be merged? This is a pretty sticky issue for us in trying to upgrade from 4 to 5.

@matthew-gladman-oua
Copy link

matthew-gladman-oua commented Mar 1, 2022

As a temporary work around, if you are using Craco, you can use this configuration file to inject the exclude without the typo in it:

// Taken from the original webpack config
const ForkTsCheckerWebpackPlugin =
    process.env.TSC_COMPILE_ON_ERROR === 'true'
        ? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
        : require('react-dev-utils/ForkTsCheckerWebpackPlugin');

module.exports = {
    webpack: {
        configure: (webpackConfig, {env, paths}) => {
            webpackConfig.plugins.map((plugin) => {
                if (plugin instanceof ForkTsCheckerWebpackPlugin) {
                    plugin.options.issue.exclude.push({file: '**/src/**/?(*.){spec,test}.*'});
                }
                return plugin;
            })

            return webpackConfig;
        },
    },
};

@jwalton9
Copy link
Author

@iansu @mrmckeb Any chance this could be reviewed soon or at least an update on when we can expect this to be reviewed? Seems like a pretty simple fix, and I'd like to remove our custom config to get around this issue

schmidti159 added a commit to schmidti159/songskipper that referenced this pull request Jun 8, 2022
This currently breaks. Waiting for PR: facebook/create-react-app#11886

Update Spotify wrapper.
schmidti159 added a commit to schmidti159/songskipper that referenced this pull request Jun 9, 2022
This currently breaks. Waiting for PR: facebook/create-react-app#11886

Update Spotify wrapper.
@lejahmie
Copy link

Seems like an easy review, any actions? Please :-)

@questicles
Copy link

Please can this be merged. I've never seen a 1 character change PR that is so impactful sit idle for so long.

@WTKersten
Copy link

Yes please, it is blocking us from upgrading.

@pvsleeper
Copy link

PLEASE can someone merge this? This is making our lives hell! :(

@TheMagnificent11
Copy link

Please merge as this is also blocking us from upgrading

@XiLiuRoy
Copy link

Please merge this PR as it is blocking us as well, many thanks

@colin-byrne-1
Copy link

please merge!

@tonyjmnz
Copy link

tonyjmnz commented Dec 2, 2022

@iansu @mrmckeb this change seems to be impactful for a number of users (myself included) and it has been sitting idle for close to a year. IMO this should be merged or closed with directions for a workaround.

@nwmahoney
Copy link

@iansu @mrmckeb +1 to what @tonyjmnz said. I'm surprised by the lack of communication on this issue. I may be misunderstanding, but this one-character change seems to be fixing what amounts to a typo.

@JeanOncle
Copy link

Please merge this issue, as this is blocking to us as well...

@florinkrasniqi1
Copy link

@jwalton9 how come this isn't reviewed at all? Did you manage to find anything else regarding this issue? I do understand that comma is interpreted as a literal character, rather than as a separator between two options and that's why they used | instead, however changing it manually seems to fix the issue for me too

@Mboulianne
Copy link

Was there any announcement, post, github issue where they explain what's going on with CRA? No release since April 2022 and PRs aren't getting approved. I see people wanting to contribute to the project, but they get no support from the code owners.

Here we have a very simple PR that would solve an annoying issue and it def shouldn't take one year to get it MERGED. Not approved, MERGED,

@StefanSchoof
Copy link

@Mboulianne I think you read #11768

@jwalton9
Copy link
Author

I don't think this is ever going to be reviewed, so I'm going to close it. FWIW we've migrated to vite for our client rendered applications

@jwalton9 jwalton9 closed this May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

react-scripts v5 type checks test files when running start command