Я не понимаю, когда я абстрагирую options
в переменную (или даже импортирую из другого файла), Typescript жалуется на:
Argument of type '{ exclude: { type: string; required: boolean; description: string; default: never[]; alias: string; }; someOtherFlag: { type: string; required: boolean; description: string; default: never[]; }; }' is not assignable to parameter of type '{ [key: string]: Options; }'.
Property 'exclude' is incompatible with index signature.
Type '{ type: string; required: boolean; description: string; default: never[]; alias: string; }' is not assignable to type 'Options'.
Types of property 'type' are incompatible.
Type 'string' is not assignable to type '"string" | "number" | "boolean" | "array" | "count" | undefined'.ts(2345)
import * as yargs from 'yargs';
const options = {
exclude: {
type: 'array',
required: false,
description: 'Files to exclude',
default: [],
alias: 'e'
},
someOtherFlag: {
type: 'array',
required: false,
description: 'Another example flag'
default: []
}
};
// throws Typescript error
const cliOptions = yargs.options(options).argv;