0
votes

With typescript, I want to define a type T which can check if the value is a substring with the given strings. It's like

const a = 'apple'
const b = 'banana'
const c = 'cat'
const d = 'dog'
type T1<typeof T, typeof U> = ?
const t1:T<a,b> = 'xyz apple banana' // pass
const t2:T<b,c> = 'banana cat abc' // pass
const t3:T<a,b> = 'abc xyz def' // error, as not contain 'apple' and 'banana'

How can I define that type?