@@ -28036,7 +28036,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2803628036 }
2803728037
2803828038 function getInstanceType(constructorType: Type, left: Expression, leftType: Type, right: Expression) {
28039- // if rightType is an object type with a custom `[Symbol.hasInstance]` method, and that method has a type
28039+ // if constructorType is an object type with a custom `[Symbol.hasInstance]` method, and that method has a type
2804028040 // predicate, use the type predicate to perform narrowing. This allows normal `object` types to participate
2804128041 // in `instanceof`, as per Step 2 of https://tc39.es/ecma262/#sec-instanceofoperator.
2804228042 const hasInstanceMethodType = getSymbolHasInstanceMethodOfObjectType(constructorType);
@@ -33895,6 +33895,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3389533895 // If candidate is undefined, it means that no candidates had a suitable arity. In that case,
3389633896 // skip the checkApplicableSignature check.
3389733897 if (reportErrors) {
33898+ // If the call expression is a synthetic call to a `[Symbol.hasInstance]` method then we will produce a head
33899+ // message when reporting diagnostics that explains how we got to `right[Symbol.hasInstance](left)` from
33900+ // `left instanceof right`, as it pertains to "Argument" related messages reported for the call.
3389833901 if (!headMessage && isCallExpression(node) && isSyntheticHasInstanceMethodCall(node)) {
3389933902 headMessage = Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method;
3390033903 }
@@ -34332,9 +34335,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3433234335 return resolveErrorCall(node);
3433334336 }
3433434337
34335- // If the call expression is a synthetic call to a `[Symbol.hasInstance]` method then we will produce a head
34336- // message when reporting diagnostics that explains how we got to `right[Symbol.hasInstance](left)` from
34337- // `left instanceof right`, as it pertains to "Argument" related messages reported for the call.
3433834338 return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
3433934339 }
3434034340
@@ -37201,7 +37201,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3720137201 }
3720237202 if (!cache.hasSimpleUnrestrictedSingleCallSignature) {
3720337203 // If rightType has a `[Symbol.hasInstance]` method that is not `(value: unknown) => boolean`, we
37204- // must check the expression as if it were a call to `right[Symbol.hasInstance](left)1 . The call to
37204+ // must check the expression as if it were a call to `right[Symbol.hasInstance](left)` . The call to
3720537205 // `getResolvedSignature`, below, will check that leftType is assignable to the type of the first
3720637206 // parameter.
3720737207 const syntheticCall = createSyntheticHasInstanceMethodCall(left, leftType, right, rightType, hasInstanceMethodType);
0 commit comments