It will be best if the sensor is connected 5-10cm away from the device. The sensor connected directly to the connector will be heated by the device through paths and goldpins and you can not help it.
As far as dht11 / 12 is concerned, I already subtract these 2-3 degrees in the program from the read temperature, which are overstated. But you have to check it yourself experimentally if the result is overstated with any other sensor in the temperature range you want to measure.
Unfortunately, I don't have dht22, so I won't tell you anything specific about its accuracy or results.