Nullable type not being applied when exporting

Solution 1:

The only cause of this I can think of would be that the strictNullChecks compiler option is off. This is also included by the "strict" compiler option

Try adding:

"strict": true,

Or:

"strictNullChecks": true,

to your tsconfig.json file under the "compilerOptions" section.

In strict mode, your code seems to work fine. See this sandbox.