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

Migrate jest-leak-detector to TypeScript #7825

Merged
merged 9 commits into from
Feb 7, 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 @@ -12,6 +12,7 @@
- `[jest-get-type]`: Migrate to TypeScript ([#7818](https://github.com/facebook/jest/pull/7818))
- `[jest-regex-util]`: Migrate to TypeScript ([#7822](https://github.com/facebook/jest/pull/7822))
- `[jest-diff]`: Migrate to TypeScript ([#7824](https://github.com/facebook/jest/pull/7824))
- `[jest-leak-detector]`: Migrate to TypeScript ([#7825](https://github.com/facebook/jest/pull/7825))

### Performance

Expand Down
1 change: 1 addition & 0 deletions packages/jest-leak-detector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"pretty-format": "^24.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ it('tests different objects', () => {
});

it('correctly checks more complex leaks', () => {
let ref1 = {};
let ref2 = {};
let ref1: any = {};
let ref2: any = {};

// Create a circular dependency between ref1 and ref2.
ref1.ref2 = ref2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

'use strict';

import prettyFormat from 'pretty-format';
import v8 from 'v8';
import vm from 'vm';
import prettyFormat from 'pretty-format';

export default class {
_isReferenceBeingHeld: boolean;
private _isReferenceBeingHeld: boolean;

constructor(value: ?Object) {
constructor(value: unknown) {
if (this._isPrimitive(value)) {
throw new TypeError(
[
Expand Down Expand Up @@ -55,7 +51,7 @@ export default class {
return this._isReferenceBeingHeld;
}

_runGarbageCollector() {
private _runGarbageCollector() {
const isGarbageCollectorHidden = !global.gc;

// GC is usually hidden, so we have to expose it before running.
Expand All @@ -68,7 +64,7 @@ export default class {
}
}

_isPrimitive(value: any): boolean {
private _isPrimitive(value: unknown): boolean {
return value !== Object(value);
}
}
10 changes: 10 additions & 0 deletions packages/jest-leak-detector/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"references": [
{"path": "../pretty-format"}
]
}