Get all orders which contains a certain product type
You're close. Products themselves aren't Purchasebles. 

However, Variants of products are. And you can have more than one Variant of a Product.

So, we need to get all Variants of a particular Product type and then feed your query:

{# get products of a certain type #}
{% set productIds = craft.products.type('classes').ids() %}

{# get the variants from those product Ids #}
{% set theVariants = craft.variants.productId(productIds).all() %}

{# grab orders #}
{% set orders = craft.orders.completed(true).hasPurchasables(theVariants).limit(null).all() %}


You'll probably want to limit the orders returned at some point depending on how you're displaying or querying them.