mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Stop binding type predicate types twice (#22210)
This commit is contained in:
parent
fabd325867
commit
7a31192ecb
@ -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)) {
|
||||
|
||||
18
tests/baselines/reference/typeGuardOnContainerTypeNoHang.js
Normal file
18
tests/baselines/reference/typeGuardOnContainerTypeNoHang.js
Normal 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 = {}));
|
||||
@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
|
||||
}
|
||||
6
tests/cases/compiler/typeGuardOnContainerTypeNoHang.ts
Normal file
6
tests/cases/compiler/typeGuardOnContainerTypeNoHang.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export namespace TypeGuards {
|
||||
export function IsObject(value: any) : value is {[index:string]:any} {
|
||||
return typeof(value) === 'object'
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user