Skip to content

Commit

Permalink
chore: multipleValidOptions types (#8435)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshRosenstein authored and SimenB committed May 7, 2019
1 parent 2297194 commit b3f54e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/jest-config/src/ValidConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const NODE_MODULES_REGEXP = replacePathSepForRegex(NODE_MODULES);

const initialOptions: Config.InitialOptions = {
automock: false,
// @ts-ignore TODO: type this properly
bail: multipleValidOptions(false, 0),
browser: false,
cache: true,
Expand All @@ -39,9 +38,8 @@ const initialOptions: Config.InitialOptions = {
},
},
dependencyExtractor: '<rootDir>/dependencyExtractor.js',
// @ts-ignore TODO: type this properly
displayName: multipleValidOptions('test-config', {
color: 'blue',
color: 'blue' as 'blue',
name: 'test-config',
}),
errorOnDeprecated: false,
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-validate/src/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export function validationCondition(option: any, validOption: any): boolean {
return getValues(validOption).some(e => validationConditionSingle(option, e));
}

// TODO: This should infer the types of its arguments, and return a union type of the types
// See https://github.com/Microsoft/TypeScript/issues/5453
export function multipleValidOptions(...args: Array<any>) {
const options = [...args];
export function multipleValidOptions<T extends Array<any>>(
...args: T
): T[number] {
const options = <T>[...args];
// @ts-ignore
options[MULTIPLE_VALID_OPTIONS_SYMBOL] = true;
return options;
Expand Down

0 comments on commit b3f54e7

Please sign in to comment.