This question already has an answer here:
In Avengers: Infinity War, Doctor Strange looked into the alternating futures to see the outcome of the battle against Thanos. And out of millions of possible outcomes he said that only in one outcome they came out as victorious. In the climax Doctor Strange said to Tony that "it is the only way" before disintegrating (death). That means the current events will only lead to the victory. So how can he see the future beyond his own death? Time travel is a different thing and peeking into the future is different. Isn't it?