Skip to content

Commit

Permalink
fix: type guard does not using earsed signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Feb 1, 2022
1 parent 3d315d6 commit c8284be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31872,7 +31872,7 @@ namespace ts {

// cache this type on the class symbol?
function createClassMetaPropertyExpressionType(targetClass: Type): Type {
// Create a synthetic type `ClassMetaProperty { hasInstance(value: unknown): unknown is TargetClass }`
// Create a synthetic type `ClassMetaProperty { hasInstance(value: unknown): value is TargetClass }`
const symbol = createSymbol(SymbolFlags.None, "ClassMetaProperty" as __String);

// class.hasInstance
Expand All @@ -31882,7 +31882,8 @@ namespace ts {

const arg0 = createSymbol(SymbolFlags.None, "value" as __String);
arg0.type = unknownType;
const classConstructor = getSingleSignature(targetClass, SignatureKind.Construct, /** allow members */ true);
// TODO: is it possible that cannot get construct signature from a class?
const classConstructor = getErasedSignature(getSingleSignature(targetClass, SignatureKind.Construct, /** allow members */ true)!);
const classInstance = classConstructor ? getReturnTypeOfSignature(classConstructor) : errorType;
const hasInstanceReturnType = createTypePredicate(TypePredicateKind.Identifier, "value", 0, classInstance);
const signature = createSignature(
Expand Down

0 comments on commit c8284be

Please sign in to comment.