sindresorhus / meow

🐈 CLI app helper
MIT License
3.53k stars 150 forks source link

Typescript definition for default does not support arrays #189

Closed RobertSasak closed 3 years ago

RobertSasak commented 3 years ago

Property default expects string, boolean, number. However when isMultiple is true it should also accepts arrays.

Here is a minimal example of the issue:

import meow from 'meow'

meow(`Usage`, {
    importMeta: import.meta,
    flags: {
        unicorn: {
            type: 'string',
            alias: 'u',
            default: ['rainbow', 'cat'], // <- Type issue
            isMultiple: true,
        },
    },
})

Actual error message:

Type 'string[]' is not assignable to type 'string | number | boolean | undefined'.
  Type 'string[]' is not assignable to type 'string'.ts(2322)
index.d.ts(18, 11): The expected type comes from property 'default' which is declared here on type 'AnyFlag'
(property) Flag<"string", string>.default?: string | undefined