I'm trying to use useSelect with TypeScript to get the current post type. In regular JavaScript, this code works fine (and is in fact code used in the main Gutenberg repo):
const postType = useSelect(
( select ) => select( 'core/editor' ).getCurrentPostType(),
[]
);
However, when I convert to TypeScript, this throws a type error:
Property 'getCurrentPostType' does not exist on type 'never'.ts(2339)
I can't see what's causing it, why the return type is <never>.
The code actually does work and compiles fine, but I would like to get it type safe. Any ideas on how I can resolve this would be much appreciated.