You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See this PR for unit tests which reproduce the issue #15307
// dependencyExtractor will exclude this depimporttype{foo}from'file';// but include this depimport{typefoo}from'file';// this too, and other syntaxes where all named imports are all type importsimport{typefoo,typebar}from'file';
Expected behavior
Test should pass
Actual behavior
Test fails
Additional context
I recently swept through a large repo and added an import {type ABC} from 'some/file';. In the following days our CI suite ran far more tests than we had expected for all PRs.
We traced this down to Jest's dependencyExtractor including this type import to the dependencies of every file that I had touched. We expected that Jest would have ignored type imports, and were surprised to see that it did not.
While looking at the dependencyExtractor code further, I see that it does make an attempt to exclude type imports, but only if the import statement is explicitly states that all imports are types (ie: import type ...). I had considered adding eslint rules to follow this import syntax more often, but if this "bug" could be addressed in the dependencyExtractor, that would be lovely.
Version
29.7.0
Steps to reproduce
See this PR for unit tests which reproduce the issue #15307
Expected behavior
Test should pass
Actual behavior
Test fails
Additional context
I recently swept through a large repo and added an
import {type ABC} from 'some/file';
. In the following days our CI suite ran far more tests than we had expected for all PRs.We traced this down to Jest's dependencyExtractor including this type import to the dependencies of every file that I had touched. We expected that Jest would have ignored type imports, and were surprised to see that it did not.
While looking at the dependencyExtractor code further, I see that it does make an attempt to exclude type imports, but only if the import statement is explicitly states that all imports are types (
ie: import type ...
). I had considered adding eslint rules to follow this import syntax more often, but if this "bug" could be addressed in the dependencyExtractor, that would be lovely.Environment
The text was updated successfully, but these errors were encountered: