I faced the same situation and it worked for me.
First, I defined a separate class with a property, which may be null :
export class Foo { id: number;
Then, in my main class, I set the foo property for this new type:
foo: Foo
After that, I was able to use it as follows:
var fooId = (this.foo || ({} as Foo)).id;
This is the closest I could get zero distribution in the current version of TypeScript.
source share