Home > Enterprise >  TypeScript conditional types not compiling
TypeScript conditional types not compiling

Time:03-18

Why does the following typescript not compile without errors?

const conditionalTypedFunction =
  (inputArg: string | string []):
    typeof inputArg extends string ? string : string[] 
  => {
    return inputArg;
  }

Here is a link to the TypeScript Playground: enter image description here

enter image description here

  • Related