@rajpriyanshu
I guess the dht22 library you are playing with has been written years ago, maybe for mbed OS 2 and not for 5. (But that is not easy to tell as no libraries are sorted based on the mbed version they were written for…)
If it is for v2, you surely can not use it with Mbed Studio as the lowest mbed-os version that this IDE supports is V5.12.
I am sure in the online compiler one could select also ancient version of mbed-os before by clicking on the “mbed-os” library in the active project and then by clicking the “Revision” (placed top center on the menu bar). That way you could see a list with mbed versions like V5.4 etc. before. Tried the same right now and the latest selectable version is V5.13. So there must have been a decision to drop old versions even from the online compiler.
For sure there is even the command-line version of embed which is cumbersome to use but many tell that is the most advanced mbed-os tool. So that might be your last chance for using older mbed os than 5.12. However maybe even that might have dropped support for older mbed version by now.