diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 782363dd6df..86c9c97bdd5 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -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(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)) { diff --git a/tests/baselines/reference/typeGuardOnContainerTypeNoHang.js b/tests/baselines/reference/typeGuardOnContainerTypeNoHang.js new file mode 100644 index 00000000000..238676b7974 --- /dev/null +++ b/tests/baselines/reference/typeGuardOnContainerTypeNoHang.js @@ -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 = {})); diff --git a/tests/baselines/reference/typeGuardOnContainerTypeNoHang.symbols b/tests/baselines/reference/typeGuardOnContainerTypeNoHang.symbols new file mode 100644 index 00000000000..eacc6b7f100 --- /dev/null +++ b/tests/baselines/reference/typeGuardOnContainerTypeNoHang.symbols @@ -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)) + } + +} diff --git a/tests/baselines/reference/typeGuardOnContainerTypeNoHang.types b/tests/baselines/reference/typeGuardOnContainerTypeNoHang.types new file mode 100644 index 00000000000..cc7d90e76df --- /dev/null +++ b/tests/baselines/reference/typeGuardOnContainerTypeNoHang.types @@ -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" + } + +} diff --git a/tests/cases/compiler/typeGuardOnContainerTypeNoHang.ts b/tests/cases/compiler/typeGuardOnContainerTypeNoHang.ts new file mode 100644 index 00000000000..faab957a4a2 --- /dev/null +++ b/tests/cases/compiler/typeGuardOnContainerTypeNoHang.ts @@ -0,0 +1,6 @@ +export namespace TypeGuards { + export function IsObject(value: any) : value is {[index:string]:any} { + return typeof(value) === 'object' + } + +} \ No newline at end of file