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: ignore TS type references when looking for out-of-scope references #7799

Merged
merged 1 commit into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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