Me cuesta entender por qué no aplica mi tipo anulable
aquí hay un ejemplo
interface Book { name: string; author: string; reference: string; category: string; } async function handleFetch<T>(endpoint: string, params: object): Promise<T | null> { const querystring = Object.entries(params) .map(([key, value]) => `${key}=${value}`) .join('&'); try { const response = await fetch(`/api/${endpoint}?${querystring}`); const data = await response.json(); if (response.ok) { return data[0] || null; } return null; } catch { throw new Error('Internal error'); } } export default { getBook: (reference: string) => { return handleFetch<Book>('books', { reference }); }, }; Puedo ver que el método devuelve un tipo anulable 
pero al exportarlo ya no es anulable 
Siento que me estoy perdiendo algo, pero nunca me había encontrado con eso antes.
gracias
La única causa de esto que se me ocurre es que la opción del compilador strictNullChecks está desactivada. Esto también está incluido en la opción del compilador "strict" .
Intenta agregar:
"strict": true,O:
"strictNullChecks": true, a su archivo tsconfig.json en la sección "compilerOptions" .
En modo estricto, su código parece funcionar bien. Vea este arenero .