Using TypeScript to write a multiprocessing Node application I see the problem that e.g. this code is creating a compiler error although it's definitely working:
// main.ts
import * as child from 'child_process';
child.fork('my_fork.js', [], {});
// my_fork.ts
process.send({command: 42}); // Error: Cannot invoke an object which is possibly 'undefined'.
(<Required<typeof process>>process).send({command: 42}); // fine, but ugly
So how can I tell TypeScript that inside my_fork.ts
the process.send
will never be undefined
?