This demo makes typeof Symbol.toStringTag type symbol:
const promise = Promise.resolve();
const toStr: typeof Symbol.toStringTag | void = typeof Symbol === 'function' ? Symbol.toStringTag : undefined;
if (toStr) {
console.log(promise[toStr] === 'Promise');
}
And results in error:
Element implicitly has an 'any' type because expression of type 'symbol' can't be used to index type 'Promise'.(7053)
Is there a way to narrow down toStr symbol type instead of using symbols explicitly like promise[Symbol.toStringTag]?