Closed
Description
Bug Report
Instead of words, just the code. The comments say what is wrong and what used to work in 4.7.4.
// Arguments are set to "unknown" because they receive data from network requests
// so runtime checks are mandatory to narrow type before use.
function SendBlob(data: unknown, encoding: unknown) {
if (encoding !== undefined && encoding !== 'utf8') {
throw new Error('encoding');
}
// Mouse hover to see detected type
// When using TS v4.8.2 it is {} | undefined
// When using TS v4.7.4 it is "utf8" | undefined
encoding;
};
🔎 Search Terms
"4.8.2" and I found a few but was told to file a new issue because I'm told it wasn't similar to the ones that I found and fought were similar.
I thought e.g. #50671 looks similar, not for the code but possibly for the deeper cause, since I don't think that many things changed in exactly this part of TS since 4.7.4.
🕗 Version & Regression Information
4.7.4 works
4.8.2 doesn't work