Fixes type predicate crash bug

This commit is contained in:
Tingan Ho 2015-06-18 23:04:05 +08:00
parent 6db4faf488
commit 752e0ba003
2 changed files with 11 additions and 0 deletions

View file

@ -5761,6 +5761,7 @@ namespace ts {
let signature = getResolvedSignature(expr);
if (signature.typePredicate &&
expr.arguments[signature.typePredicate.parameterIndex] &&
getSymbolAtLocation(expr.arguments[signature.typePredicate.parameterIndex]) === symbol) {
if (!assumeTrue) {

View file

@ -23,6 +23,10 @@ function hasMissingIsKeyword(): x {
return true;
}
function hasMissingParameter(): x is A {
return true;
}
function hasMissingTypeInTypeGuardType(x): x is {
return true;
}
@ -132,4 +136,10 @@ function b6([a, b, p1], p2, p3): p1 is A {
function b7({a, b, c: {p1}}, p2, p3): p1 is A {
return true;
}
// Should not crash the compiler
var x: A;
if (hasMissingParameter()) {
x.propA;
}