Q:

How to check for the property type of an `unknown` value?

I have the following function, which could receive an unknown value:
function formatReason(detail: unknown): string {
    if (detail
        && detail instanceof Object
        && detail.constructor.name === 'Object'
        && detail.hasOwnProperty('description')
        && typeof detail['description'] === 'number'
    ) {
        const output = detail['description'];
        return output;
    }

    return '';
}

The detail parameter could be any value. If it's an object with a description property of type string, the function should return that property value, otherwise empty string.
First, do you recommend using any or unknown for the detail parameter?
Second, no matter what I do, the type for output ends up to be any. How can I make sure it is string?

A:

There isn't a great way to write this code until this suggestion is implemented.  In the meantime, it's up to you whether you prefer any or unknown (with some casts if you are using noImplicitAny, as I'd generally recommend).  I wouldn't worry about the type of the output local variable because you've declared the return type of the function as string anyway.

