Skip to content

Commit 29cdadc

Browse files
committed
Slight rearrange
1 parent 4970249 commit 29cdadc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37404,12 +37404,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3740437404
return undefined;
3740537405
}
3740637406

37407-
// Only a single-argument function can be inferred to be a type predicate
37408-
if (func.parameters.length !== 1) return undefined;
37409-
3741037407
// The body must be an expression, or a block containing a lone return statement
3741137408
if (!func.body) return undefined;
3741237409

37410+
const functionFlags = getFunctionFlags(func);
37411+
// Only a normal single-argument function can be inferred to be a type predicate
37412+
if (functionFlags !== FunctionFlags.Normal || func.parameters.length !== 1) return undefined;
37413+
3741337414
let returnExpression: Expression | undefined;
3741437415
if (func.body.kind === SyntaxKind.Block) {
3741537416
const body = func.body as Block;
@@ -37421,9 +37422,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3742137422
}
3742237423
if (!returnExpression) return undefined;
3742337424

37424-
const functionFlags = getFunctionFlags(func);
37425-
if (functionFlags !== FunctionFlags.Normal) return undefined;
37426-
3742737425
const predicate = checkIfExpressionRefinesAnyParameter(returnExpression);
3742837426
if (predicate) {
3742937427
const [i, type] = predicate;

0 commit comments

Comments
 (0)