Limit views exposed filter options to terms with associated nodes of content type X
$query = \Drupal::database()-&gt;select('taxonomy_index', 'ti');
  $query-&gt;condition('ti.tid', $key);
  $query-&gt;join('node', 'n', 'n.nid = ti.nid'); // join node table
  $query-&gt;condition('n.type', 'x'); // filter by type
  $query-&gt;fields('n', ['nid']); // add filtered nids
  $nodes = $query-&gt;execute()-&gt;fetchAssoc();