Skip to content

Commit 1c55e5d

Browse files
committed
Address code review feedback
1 parent fe70a62 commit 1c55e5d

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/compiler/binder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,8 @@ namespace ts {
12851285
}
12861286

12871287
function isDottedName(node: Expression): boolean {
1288-
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression && isDottedName((<PropertyAccessExpression>node).expression);
1288+
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword ||
1289+
node.kind === SyntaxKind.PropertyAccessExpression && isDottedName((<PropertyAccessExpression>node).expression);
12891290
}
12901291

12911292
function bindExpressionStatement(node: ExpressionStatement): void {

src/compiler/checker.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16838,16 +16838,18 @@ namespace ts {
1683816838
// that reference function, method, class or value module symbols; or variable, property or
1683916839
// parameter symbols with declarations that have explicit type annotations. Such references are
1684016840
// resolvable with no possibility of triggering circularities in control flow analysis.
16841-
if (node.kind === SyntaxKind.Identifier) {
16842-
const symbol = getResolvedSymbol(<Identifier>node);
16843-
return getExplicitTypeOfSymbol(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
16844-
}
16845-
if (node.kind === SyntaxKind.PropertyAccessExpression) {
16846-
const type = getTypeOfDottedName((<PropertyAccessExpression>node).expression);
16847-
if (type) {
16848-
const prop = getPropertyOfType(type, (<PropertyAccessExpression>node).name.escapedText);
16849-
return prop && getExplicitTypeOfSymbol(prop);
16850-
}
16841+
switch (node.kind) {
16842+
case SyntaxKind.Identifier:
16843+
const symbol = getResolvedSymbol(<Identifier>node);
16844+
return getExplicitTypeOfSymbol(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
16845+
case SyntaxKind.ThisKeyword:
16846+
return checkThisExpression(node);
16847+
case SyntaxKind.PropertyAccessExpression:
16848+
const type = getTypeOfDottedName((<PropertyAccessExpression>node).expression);
16849+
if (type) {
16850+
const prop = getPropertyOfType(type, (<PropertyAccessExpression>node).name.escapedText);
16851+
return prop && getExplicitTypeOfSymbol(prop);
16852+
}
1685116853
}
1685216854
}
1685316855

src/compiler/parser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,6 +3211,7 @@ namespace ts {
32113211
const type = parseType();
32123212
if (typePredicateVariable) {
32133213
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typePredicateVariable.pos);
3214+
node.assertsModifier = undefined;
32143215
node.parameterName = typePredicateVariable;
32153216
node.type = type;
32163217
return finishNode(node);
@@ -3232,9 +3233,7 @@ namespace ts {
32323233
const node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate);
32333234
node.assertsModifier = parseExpectedToken(SyntaxKind.AssertsKeyword);
32343235
node.parameterName = parseIdentifier();
3235-
if (parseOptional(SyntaxKind.IsKeyword)) {
3236-
node.type = parseType();
3237-
}
3236+
node.type = parseOptional(SyntaxKind.IsKeyword) ? parseType() : undefined;
32383237
return finishNode(node);
32393238
}
32403239

0 commit comments

Comments
 (0)