Stop binding type predicate types twice (#22210)

This commit is contained in:
Wesley Wigham 2018-02-28 15:43:13 -08:00 committed by GitHub
parent fabd325867
commit 7a31192ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 12 deletions

View File

@ -2071,7 +2071,7 @@ namespace ts {
seenThisKeyword = true;
return;
case SyntaxKind.TypePredicate:
return checkTypePredicate(node as TypePredicateNode);
break; // Binding the children will handle everything
case SyntaxKind.TypeParameter:
return bindTypeParameter(node as TypeParameterDeclaration);
case SyntaxKind.Parameter:
@ -2204,17 +2204,6 @@ namespace ts {
return bindAnonymousDeclaration(<Declaration>node, SymbolFlags.TypeLiteral, InternalSymbolName.Type);
}
function checkTypePredicate(node: TypePredicateNode) {
const { parameterName, type } = node;
if (parameterName && parameterName.kind === SyntaxKind.Identifier) {
checkStrictModeIdentifier(parameterName);
}
if (parameterName && parameterName.kind === SyntaxKind.ThisType) {
seenThisKeyword = true;
}
bind(type);
}
function bindSourceFileIfExternalModule() {
setExportContextFlag(file);
if (isExternalModule(file)) {

View File

@ -0,0 +1,18 @@
//// [typeGuardOnContainerTypeNoHang.ts]
export namespace TypeGuards {
export function IsObject(value: any) : value is {[index:string]:any} {
return typeof(value) === 'object'
}
}
//// [typeGuardOnContainerTypeNoHang.js]
"use strict";
exports.__esModule = true;
var TypeGuards;
(function (TypeGuards) {
function IsObject(value) {
return typeof (value) === 'object';
}
TypeGuards.IsObject = IsObject;
})(TypeGuards = exports.TypeGuards || (exports.TypeGuards = {}));

View File

@ -0,0 +1,15 @@
=== tests/cases/compiler/typeGuardOnContainerTypeNoHang.ts ===
export namespace TypeGuards {
>TypeGuards : Symbol(TypeGuards, Decl(typeGuardOnContainerTypeNoHang.ts, 0, 0))
export function IsObject(value: any) : value is {[index:string]:any} {
>IsObject : Symbol(IsObject, Decl(typeGuardOnContainerTypeNoHang.ts, 0, 29))
>value : Symbol(value, Decl(typeGuardOnContainerTypeNoHang.ts, 1, 29))
>value : Symbol(value, Decl(typeGuardOnContainerTypeNoHang.ts, 1, 29))
>index : Symbol(index, Decl(typeGuardOnContainerTypeNoHang.ts, 1, 54))
return typeof(value) === 'object'
>value : Symbol(value, Decl(typeGuardOnContainerTypeNoHang.ts, 1, 29))
}
}

View File

@ -0,0 +1,19 @@
=== tests/cases/compiler/typeGuardOnContainerTypeNoHang.ts ===
export namespace TypeGuards {
>TypeGuards : typeof TypeGuards
export function IsObject(value: any) : value is {[index:string]:any} {
>IsObject : (value: any) => value is { [index: string]: any; }
>value : any
>value : any
>index : string
return typeof(value) === 'object'
>typeof(value) === 'object' : boolean
>typeof(value) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(value) : any
>value : any
>'object' : "object"
}
}

View File

@ -0,0 +1,6 @@
export namespace TypeGuards {
export function IsObject(value: any) : value is {[index:string]:any} {
return typeof(value) === 'object'
}
}