Type Alias StringIncludes<Subject, Search, Then, Else>

StringIncludes<Subject, Search, Then, Else>: Subject extends `${infer _X}${Search}${infer _Y}`
    ? Then
    : Else

Check if Subject includes Search. If either of them is not a string, returns Else.

type R = StringIncludes<'abc', 'a'> // true

type R = StringIncludes<'abc', 'd'> // false

Type Parameters

  • Subject extends string
  • Search extends string
  • Then = true
  • Else = false