Skip to content

Commit f9439d8

Browse files
authoredOct 8, 2022
refactor(jest-cli): rework internal typings (#13405)
1 parent 9984ba1 commit f9439d8

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed
 

‎packages/jest-cli/src/init/index.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {MalformedPackageJsonError, NotFoundPackageJsonError} from './errors';
1515
import generateConfigFile from './generateConfigFile';
1616
import modifyPackageJson from './modifyPackageJson';
1717
import defaultQuestions, {testScriptQuestion} from './questions';
18-
import type {ProjectPackageJson} from './types';
18+
import type {ProjectPackageJson, PromptsResults} from './types';
1919

2020
const {
2121
JEST_CONFIG_BASE_NAME,
@@ -26,15 +26,6 @@ const {
2626
PACKAGE_JSON,
2727
} = constants;
2828

29-
type PromptsResults = {
30-
useTypescript: boolean;
31-
clearMocks: boolean;
32-
coverage: boolean;
33-
coverageProvider: boolean;
34-
environment: boolean;
35-
scripts: boolean;
36-
};
37-
3829
const getConfigFilename = (ext: string) => JEST_CONFIG_BASE_NAME + ext;
3930

4031
export default async function init(
@@ -101,12 +92,11 @@ export default async function init(
10192

10293
let promptAborted = false;
10394

104-
// @ts-expect-error: Return type cannot be object - faulty typings
105-
const results: PromptsResults = await prompts(questions, {
95+
const results = (await prompts(questions, {
10696
onCancel: () => {
10797
promptAborted = true;
10898
},
109-
});
99+
})) as PromptsResults;
110100

111101
if (promptAborted) {
112102
console.log();

‎packages/jest-cli/src/init/types.ts

+9
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ export type ProjectPackageJson = {
1212
scripts?: Record<string, string>;
1313
type?: 'commonjs' | 'module';
1414
};
15+
16+
export type PromptsResults = {
17+
useTypescript: boolean;
18+
clearMocks: boolean;
19+
coverage: boolean;
20+
coverageProvider: boolean;
21+
environment: boolean;
22+
scripts: boolean;
23+
};

0 commit comments

Comments
 (0)