You lose the spyware if you use AOSP (except any that’s baked into your OEM’s kernel blobs), but you also lose a lot of functionality. You can regain some by using a community-maintained AOSP-based OS like Lineage, but chances are that a bunch of device-specific hardware/software features will still be missing.