error TS2339: Property 'split' does not exist on type 'string | string[]'. Property 'split' does not exist on type 'string[]'

The type you are trying to invoke split on is string|string[], which means that value may be either a string or a string[], in order for TypeScript to be happy, BOTH types must have a split method. If you are confident that it will always be a string, either update the definition (if possible) or cast to a string before calling split:

(<string>req.headers.authorization).split

or

(req.headers.authorization as string).split

Tags:

Typescript