Shahrazad has access to a time machine.
How else could she be telling the king stories of events that hadn't happened yet? The frame story takes place prior to the rise of Islam; many of the internal stories do not.
- Maybe she's just really good at guessing? H.G. Wells predicted the invention of the satellite, after all...
- She's stated to have researched stories of people long dead. She's Persian, so she would have had access to media destroyed in the rest of the Arabic Empire.