An undocumented feature of the language seems to be using the pipe operator to overload arguments.
Example:
function foo(user : string | number) {
//...
}
Seems to be working fine until the case below. My question is (1) is it safe to continue to use the pipe operator this way? (2) if so, how can I fix the case below?
function _isString<T>(value : T) : boolean { return typeof value === 'string'; };
function foo(services : string | string[]) {
//doesn't compile
const aService : string[] = _isString(services) ? [services] : services;
//but this does
const bService : string[] = typeof services === 'string' ? [services] : services;
}