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

前端 未结 2 728
萌比男神i
萌比男神i 2020-12-16 13:57

When I build my application I get. error TS2339: Property \'split\' does not exist on type \'string | string[]\'. Property \'split\' does not exist on type \'string[

2条回答
  •  独厮守ぢ
    2020-12-16 14:34

    Brian Ball's solution is working, another approach for handling this situation is square brackets [ ].

    For instance

    req.headers.authorization[split](//define your conditions here)
    

    For exmaple:

    req.headers.authorization[split](",")
    

提交回复
热议问题