Skip to content

Commit d77945f

Browse files
committed
typeof now has string literal union type
Previously, it was just a string
1 parent 445421b commit d77945f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14609,7 +14609,9 @@ namespace ts {
1460914609

1461014610
function checkTypeOfExpression(node: TypeOfExpression): Type {
1461114611
checkExpression(node.expression);
14612-
return stringType;
14612+
const types: Type[] = [];
14613+
typeofEQFacts.forEach((_, s) => types.push(getLiteralTypeForText(TypeFlags.StringLiteral, s)));
14614+
return getUnionType(types);
1461314615
}
1461414616

1461514617
function checkVoidExpression(node: VoidExpression): Type {

0 commit comments

Comments
 (0)