Skip to content

Commit 4621d05

Browse files
lorenzorapettiSimenB
authored andcommitted
Migrate jest-regex-util to Typescript (#7822)
1 parent 0c07df0 commit 4621d05

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- `[pretty-format]`: Migrate to TypeScript ([#7809](https://github.com/facebook/jest/pull/7809))
1111
- `[diff-sequences]`: Migrate to Typescript ([#7820](https://github.com/facebook/jest/pull/7820))
1212
- `[jest-get-type]`: Migrate to TypeScript ([#7818](https://github.com/facebook/jest/pull/7818))
13+
- `[jest-regex-util]`: Migrate to TypeScript ([#7822](https://github.com/facebook/jest/pull/7822))
1314

1415
### Performance
1516

packages/jest-regex-util/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
},
1212
"license": "MIT",
1313
"main": "build/index.js",
14+
"types": "build/index.d.ts",
1415
"gitHead": "634e5a54f46b2a62d1dc81a170562e6f4e55ad60"
1516
}

packages/jest-regex-util/src/__tests__/index.test.js renamed to packages/jest-regex-util/src/__tests__/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
jest.mock('path');
44

5-
import {replacePathSepForRegex} from '../index';
65
import path from 'path';
6+
import {replacePathSepForRegex} from '../index';
77

88
describe('replacePathSepForRegex()', () => {
99
describe('posix', () => {
10-
beforeEach(() => (path.sep = '/'));
10+
beforeEach(() => ((path as any).sep = '/'));
1111

1212
it('should return the path', () => {
1313
const expected = {};
14-
expect(replacePathSepForRegex(expected)).toBe(expected);
14+
expect(replacePathSepForRegex(expected as any)).toBe(expected);
1515
});
1616
});
1717

1818
describe('win32', () => {
19-
beforeEach(() => (path.sep = '\\'));
19+
beforeEach(() => ((path as any).sep = '\\'));
2020

2121
it('should replace POSIX path separators', () => {
2222
expect(replacePathSepForRegex('a/b/c')).toBe('a\\\\b\\\\c');

packages/jest-regex-util/src/index.js renamed to packages/jest-regex-util/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
87
*/
98

109
import path from 'path';
@@ -25,7 +24,7 @@ export const replacePathSepForRegex = (string: string) => {
2524
if (path.sep === '\\') {
2625
return string.replace(
2726
/(\/|(.)?\\(?![[\]{}()*+?.^$|\\]))/g,
28-
(_match, p1, p2) => (p2 && p2 !== '\\' ? p2 + '\\\\' : '\\\\'),
27+
(_match, _, p2) => (p2 && p2 !== '\\' ? p2 + '\\\\' : '\\\\'),
2928
);
3029
}
3130
return string;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"outDir": "build"
6+
}
7+
}

0 commit comments

Comments
 (0)