Skip to content

Commit

Permalink
fix(inquirer): fix inquirer types (#1563)
Browse files Browse the repository at this point in the history
  • Loading branch information
simondel authored and nicojs committed May 28, 2019
1 parent 49ec183 commit 37ca23c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/initializer/StrykerInquirer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface PromptResult {
export class StrykerInquirer {

public async promptPresets(options: Preset[]): Promise<Preset | undefined> {
const choices: inquirer.ChoiceType[] = options.map(_ => _.name);
const choices: inquirer.ChoiceType<string>[] = options.map(_ => _.name);
choices.push(new inquirer.Separator());
choices.push('None/other');
const answers = await inquirer.prompt<{ preset: string }>({
Expand All @@ -24,7 +24,7 @@ export class StrykerInquirer {
}

public async promptTestRunners(options: PromptOption[]): Promise<PromptOption> {
const choices: inquirer.ChoiceType[] = options.map(_ => _.name);
const choices: inquirer.ChoiceType<string>[] = options.map(_ => _.name);
choices.push(new inquirer.Separator());
choices.push(CommandTestRunner.runnerName);
const answers = await inquirer.prompt<{ testRunner: string }>({
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/initializer/presets/ReactPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ReactPreset implements Preset {
}`;

public async createConfig(): Promise<PresetConfiguration> {
const choices: inquirer.ChoiceType[] = ['JSX', 'TSX'];
const choices: inquirer.ChoiceType<string>[] = ['JSX', 'TSX'];
const answers = await inquirer.prompt<{ choice: string }>({
choices,
message: 'Is your project a JSX project or a TSX project?',
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/initializer/presets/VueJsPreset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ export class VueJsPreset implements Preset {
}`;

public async createConfig(): Promise<PresetConfiguration> {
const testRunnerChoices: inquirer.ChoiceType[] = ['karma', 'jest'];
const testRunnerChoices: inquirer.ChoiceType<string>[] = ['karma', 'jest'];
const testRunnerAnswers = await inquirer.prompt<{ testRunner: string }>({
choices: testRunnerChoices,
message: 'Which test runner do you want to use?',
name: 'testRunner',
type: 'list'
});
const scriptChoices: inquirer.ChoiceType[] = ['typescript', 'javascript'];
const scriptChoices: inquirer.ChoiceType<string>[] = ['typescript', 'javascript'];
const scriptAnswers = await inquirer.prompt<{ script: string }>({
choices: scriptChoices,
message: 'Which language does your project use?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ describe(StrykerInitializer.name, () => {
});
await sut.initialize();
expect(inquirerPrompt).callCount(7);
const [promptPreset, promptTestRunner, promptTestFramework, promptMutator, promptTranspilers, promptReporters, promptPackageManagers]: inquirer.Question[] = [
const [promptPreset, promptTestRunner, promptTestFramework, promptMutator, promptPackageManagers]: inquirer.ListQuestion<string>[] = [
inquirerPrompt.getCall(0).args[0],
inquirerPrompt.getCall(1).args[0],
inquirerPrompt.getCall(2).args[0],
inquirerPrompt.getCall(3).args[0],
inquirerPrompt.getCall(6).args[0],
];
const [promptTranspilers, promptReporters]: inquirer.CheckboxQuestion<string>[] = [
inquirerPrompt.getCall(4).args[0],
inquirerPrompt.getCall(5).args[0],
inquirerPrompt.getCall(6).args[0],
];
expect(promptPreset.type).to.eq('list');
expect(promptPreset.name).to.eq('preset');
Expand Down Expand Up @@ -196,7 +198,7 @@ describe(StrykerInitializer.name, () => {
});
await sut.initialize();
expect(inquirerPrompt).callCount(2);
const [promptPreset, promptPackageManager]: inquirer.Question[] = [
const [promptPreset, promptPackageManager]: inquirer.ListQuestion<string>[] = [
inquirerPrompt.getCall(0).args[0],
inquirerPrompt.getCall(1).args[0]
];
Expand Down

0 comments on commit 37ca23c

Please sign in to comment.