Closed restyler closed 3 years ago
You need to either use the options config directly:
const options3 = parse<IProxyChecker2Arguments>({
text: {
type: String,
optional: true
}
})
Or correctly type the options object:
const optionDefinitions2: ArgumentConfig<IProxyChecker2Arguments> = {
text: {
type: String,
optional: true
}
}
const options2 = parse<IProxyChecker2Arguments>(optionDefinitions2)
Thank you, it works! Still figuring out the TypeScript features 👍
The issues was that this:
const optionDefinitions2 = {
text: {
type: String,
optional: true
}
}
is typed as
type optionDefinitions2 = {
text: {
type: (value) => string,
optional: boolean
}
}
but the type required by parse
is
type optionDefinitions2 = {
text: {
type: (value) => string,
optional: true
}
}
you could have solved this by typing the boolean as a const (which means it won't change so it will be typed as true)
const optionDefinitions2 = {
text: {
type: String,
optional: true as const
}
}
"typescript": "^4.0.2" "ts-command-line-args": "^1.1.0"
Produces TS error:
Expected result: no TS compilation errors.