Is it possible to allow the Use
function argument type to accept any unknown key, as well as correctly type the keys from SomeGeneric
?
function Example (opt: { valid?: boolean }) {
}
type SomeGeneric = Parameters<typeof Example>[0]
function Use(opt: SomeGeneric) {
}
Use({ valid: true }) // works fine
Use({ valid: 'true' }) // works fine
Use({ meow: true }) // does not work with unknown options like `meow`
function UseAny(opt: SomeGeneric & any) {
}
UseAny({ valid: 'hi', meow: true }) // does not properly validate `valid` when it's a string
How can I prevent Use({ meow: true })
from triggering a type warning?