Ok, that makes sense, thanks for the quick reply.
Would there be a way for me to change the "!_" to some other construct or identifier, for example "FUTURE", even if it was a compiler API option that wasn't available from the command line?
I ask because I'm considering using Streamline with TypeScript, and trying to figure out how to make it play nice with the type system. (this would never be possible if streamlined code wasn't valid Javascript syntax, so thank you for that!)
When the TypeScript compiler sees "!_" it will assume the value is "false" and the type is "boolean." However, if I'm able to use an identifier like FUTURE instead of !_, then I can make my own type for FUTURE and use that type in streamlined function signatures.
// Make the type system happy
interface Callback {
(err: any, value: any): void;
}
declare var FUTURE: ReturnAFuture;
// Declare a streamlined function with several function signatures
function asyncAdd2(n: number, _: Callback): number;
function asyncAdd2(n: number, _: ReturnAFuture): Future<number>;
function asyncAdd2(n: number): Promise<number>;
function asyncAdd2(n: number, _: any) {
return n + 2;
}
// Use the streamlined function
var future = asyncAdd2(3, FUTURE);
var result = future(_);
I'm still thinking about if this is a sensible idea, so any wisdom anyone else can share would be great.