Upvote:0
I don't know about Shanghai, but Taiwan should be visa-free to US passport for a long time
Upvote:2
According to Visa policy of China:
...the outbound flight's first stop or destination must be in a different country than the inbound flight's.
This tells me that your inbound and outbound flights from and to Taipei would disqualify you from using the visa-free transit.