Ibn Al-Jawzi reports that Ad-Dhahhaak, Ibn Abbaas and Muqaatil said that
was abrogated by
ذكر الآية الرابعة: قوله تعالى "من كان يريد حرث الآخرة نزد له في حرثه". هذا محكم، وقوله "ومن كان يريد حرث الدنيا نؤته منها"، للمفسرين فيه قولان:
الأول أنه منسوخ بقوله "عجلنا له فيها ما نشاء لمن نريد"، رواه الضحاك عن ابن عباس رضي الله عنهما، وبه قال مقاتل. والثاني أنه محكم لأنه خبر، قاله قتادة، ووجهه ما بيناه في نظيرها في آل عمران عند قوله "ومن يرد ثواب الدنيا نؤته منها"
اهـ
Ibn Al-Jawzi says that Qataada disagreed because 42:20 is a statement of fact. Ibn Al-Jawzi also opined that it is not abrogated and cites his previous argument for a similar case in Chapter 3.
The verses are indeed statements of fact. Furthermore, they do no contradict each other. 42:20 states that we get what we work for. That is always true. Verse 17:18 simply says that those who
only want this world will get it and will have no share of the good life in the Hereafter, so where is any contradiction?
And if that's not enough, Chapter 17 was revealed before Chapter 42.