Skip to content
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 @@ -17,6 +17,7 @@
- `[jest-leak-detector]`: Migrate to TypeScript ([#7825](https://github.com/facebook/jest/pull/7825))
- `[jest-changed-files]`: Migrate to TypeScript ([#7827](https://github.com/facebook/jest/pull/7827))
- `[jest-matcher-utils]`: Migrate to TypeScript ([#7835](https://github.com/facebook/jest/pull/7835))
- `[jest-docblock]`: Migrate to TypeScript ([#7836](https://github.com/facebook/jest/pull/7836))

### Performance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
*
* 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 os from 'os';
import * as docblock from '..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import detectNewline from 'detect-newline';
import {EOL} from 'os';
import detectNewline from 'detect-newline';

type Pragmas = {[key: string]: string | string[], __proto__: null};
type Pragmas = {[key: string]: string | string[]};

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

export function parseWithComments(
docblock: string,
): {comments: string, pragmas: Pragmas} {
): {comments: string; pragmas: Pragmas} {
const line = detectNewline(docblock) || EOL;

docblock = docblock
Expand Down Expand Up @@ -67,7 +65,7 @@ export function parseWithComments(
typeof result[match[1]] === 'string' ||
Array.isArray(result[match[1]])
) {
result[match[1]] = [].concat(result[match[1]], nextPragma);
result[match[1]] = ([] as string[]).concat(result[match[1]], nextPragma);
} else {
result[match[1]] = nextPragma;
}
Expand All @@ -79,9 +77,8 @@ export function print({
comments = '',
pragmas = {},
}: {
comments?: string,
pragmas?: Pragmas,
__proto__: null,
comments?: string;
pragmas?: Pragmas;
}): string {
const line = detectNewline(comments) || EOL;
const head = '/**';
Expand Down Expand Up @@ -122,6 +119,8 @@ export function print({
);
}

function printKeyValues(key, valueOrArray) {
return [].concat(valueOrArray).map(value => `@${key} ${value}`.trim());
function printKeyValues(key: string, valueOrArray: string | string[]) {
return ([] as string[])
.concat(valueOrArray)
.map(value => `@${key} ${value}`.trim());
}
7 changes: 7 additions & 0 deletions packages/jest-docblock/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
}
}