Stay updated with my tutorials. Also, I will delight you with some bonus content.
If you use TWA SDK you need to call showAlert method from package root:
showAlert
import WebApp from '@twa-dev/sdk' ... WebApp.showAlert('This alert ');
Alert will looks like the following: