Skip to content

Commit

Permalink
Migrate jest-leak-detector to TypeScript (#7825)
Browse files Browse the repository at this point in the history
  • Loading branch information
r3nya authored and SimenB committed Feb 7, 2019
1 parent 20f037f commit 5c18df6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
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"}
]
}

0 comments on commit 5c18df6

Please sign in to comment.