export interface Options {
str?: string
}
function f(opts: Options) {
if (!opts.str) throw new Error()
const s: string = opts.str
const x = ['a'].map(d => d + opts.str)
const y = ['a'].map(d => d.split(opts.str)) // error: opts.str: Type 'undefined' is not assignable to type 'string | RegExp'.
}