Skip to content

Commit 9350b1e

Browse files
committed
chore: migrate jest-docblock to TypeScript
1 parent 7906f1d commit 9350b1e

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- `[jest-leak-detector]`: Migrate to TypeScript ([#7825](https://github.com/facebook/jest/pull/7825))
1818
- `[jest-changed-files]`: Migrate to TypeScript ([#7827](https://github.com/facebook/jest/pull/7827))
1919
- `[jest-matcher-utils]`: Migrate to TypeScript ([#7835](https://github.com/facebook/jest/pull/7835))
20+
- `[jest-docblock]`: Migrate to TypeScript ([#7835](https://github.com/facebook/jest/pull/7835))
2021

2122
### Performance
2223

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
*
55
* This source code is licensed under the MIT license found in the
66
* LICENSE file in the root directory of this source tree.
7-
*
8-
* @flow
97
*/
108

11-
'use strict';
12-
139
import os from 'os';
1410
import * as docblock from '..';
1511

packages/jest-docblock/src/index.js renamed to packages/jest-docblock/src/index.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6-
*
7-
* @flow
86
*/
97

10-
import detectNewline from 'detect-newline';
118
import {EOL} from 'os';
9+
import detectNewline from 'detect-newline';
1210

13-
type Pragmas = {[key: string]: string | string[], __proto__: null};
11+
type Pragmas = {[key: string]: string | string[]};
1412

1513
const commentEndRe = /\*\/$/;
1614
const commentStartRe = /^\/\*\*/;
@@ -37,7 +35,7 @@ export function parse(docblock: string): Pragmas {
3735

3836
export function parseWithComments(
3937
docblock: string,
40-
): {comments: string, pragmas: Pragmas} {
38+
): {comments: string; pragmas: Pragmas} {
4139
const line = detectNewline(docblock) || EOL;
4240

4341
docblock = docblock
@@ -67,7 +65,7 @@ export function parseWithComments(
6765
typeof result[match[1]] === 'string' ||
6866
Array.isArray(result[match[1]])
6967
) {
70-
result[match[1]] = [].concat(result[match[1]], nextPragma);
68+
result[match[1]] = ([] as string[]).concat(result[match[1]], nextPragma);
7169
} else {
7270
result[match[1]] = nextPragma;
7371
}
@@ -79,9 +77,8 @@ export function print({
7977
comments = '',
8078
pragmas = {},
8179
}: {
82-
comments?: string,
83-
pragmas?: Pragmas,
84-
__proto__: null,
80+
comments?: string;
81+
pragmas?: Pragmas;
8582
}): string {
8683
const line = detectNewline(comments) || EOL;
8784
const head = '/**';
@@ -122,6 +119,8 @@ export function print({
122119
);
123120
}
124121

125-
function printKeyValues(key, valueOrArray) {
126-
return [].concat(valueOrArray).map(value => `@${key} ${value}`.trim());
122+
function printKeyValues<T>(key: string, valueOrArray: T | T[]) {
123+
return ([] as T[])
124+
.concat(valueOrArray)
125+
.map(value => `@${key} ${value}`.trim());
127126
}

packages/jest-docblock/tsconfig.json

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)