Skip to content

Commit

Permalink
fix: ignore TS type references when looking for out-of-scope referenc…
Browse files Browse the repository at this point in the history
…es (#7799)
  • Loading branch information
SimenB committed Feb 4, 2019
1 parent 5a81a09 commit b167892
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -24,6 +24,7 @@
- `[jest-cli]` Handle missing `numTodoTests` in test results ([#7779](https://github.com/facebook/jest/pull/7779))
- `[jest-runtime]` Exclude setup/teardown files from coverage report ([#7790](https://github.com/facebook/jest/pull/7790)
- `[babel-jest]` Throw an error if `babel-jest` tries to transform a file ignored by Babel ([#7797](https://github.com/facebook/jest/pull/7797))
- `[babel-plugin-jest-hoist]` Ignore TS type references when looking for out-of-scope references ([#7799](https://github.com/facebook/jest/pull/7799)

### Chore & Maintenance

Expand Down
2 changes: 2 additions & 0 deletions e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts
Expand Up @@ -12,6 +12,8 @@
import {Color} from '../types';
import {color} from '../entry';

jest.mock('some-module', () => ({} as Partial<{}>), {virtual: true});

jest.mock('../entry', () => {
const color: Color = 'blue';
return {color};
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-jest-hoist/src/index.js
Expand Up @@ -76,7 +76,7 @@ const IDVisitor = {
ReferencedIdentifier(path) {
this.ids.add(path);
},
blacklist: ['TypeAnnotation', 'TSTypeAnnotation'],
blacklist: ['TypeAnnotation', 'TSTypeAnnotation', 'TSTypeReference'],
};

const FUNCTIONS: Object = Object.create(null);
Expand Down

0 comments on commit b167892

Please sign in to comment.