-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
π Search Terms
refine regression 4.3 refine never
π Version & Regression Information
Worked with 4.2, stopped working with 4.3 beta
β― Playground Link
π» Code
type Hash = string & {__hash: true};
function getHashLength(hash: Hash): number {
// A best effort check in case our function is used by people writing JS
if (typeof hash !== `string`)
throw new Error(`This doesn't look like a hash`);
return hash.length;
}π Actual behavior
The hash variable is incorrectly refined to never.
π Expected behavior
The hash variable should remain Hash, since the typeof check is coherent with Hash.
whzx5byb
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue