Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate jest-validate to TypeScript #7991

Merged
merged 2 commits into from Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/jest-repl/src/cli/index.ts
Expand Up @@ -11,20 +11,20 @@ import Runtime from 'jest-runtime';
import yargs from 'yargs';
import {validateCLIOptions} from 'jest-validate';
import {deprecationEntries} from 'jest-config';
import {Config} from '@jest/types';
import * as args from './args';

const {version: VERSION} = require('../../package.json');

const REPL_SCRIPT = require.resolve('./repl.js');

export = function() {
const argv = yargs.usage(args.usage).options(args.options).argv;
const argv = <Config.Argv>yargs.usage(args.usage).options(args.options).argv;

// @ts-ignore: not the same arguments
// @ts-ignore: fix this at some point
validateCLIOptions(argv, {...args.options, deprecationEntries});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error here is nuts, I gave up :p


argv._ = [REPL_SCRIPT];

// @ts-ignore: not the same arguments
Runtime.runCLI(argv, [`Jest REPL v${VERSION}`]);
};
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/cli/index.ts
Expand Up @@ -28,7 +28,7 @@ export function run(cliArgv?: Config.Argv, cliInfo?: Array<string>) {
if (cliArgv) {
argv = cliArgv;
} else {
argv = yargs
argv = <Config.Argv>yargs
.usage(args.usage)
.help(false)
.version(false)
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-validate/src/validateCLIOptions.ts
Expand Up @@ -64,12 +64,12 @@ export default function validateCLIOptions(
argv: Config.Argv,
options: {
[s: string]: {alias?: string};
deprecationEntries: DeprecatedOptions;
},
rawArgv: string[] = [],
) {
const yargsSpecialOptions = ['$0', '_', 'help', 'h'];
const deprecationEntries = (options.deprecationEntries ||
{}) as DeprecatedOptions;
const deprecationEntries = options.deprecationEntries || {};
const allowedOptions = Object.keys(options).reduce(
(acc, option) => acc.add(option).add(options[option].alias || option),
new Set(yargsSpecialOptions),
Expand All @@ -96,7 +96,7 @@ export default function validateCLIOptions(
}
return acc;
},
{} as {[s: string]: Function},
{} as Record<string, Function>,
);
const deprecations = new Set(Object.keys(CLIDeprecations));
const deprecatedOptions = Object.keys(argv).filter(
Expand Down