Skip to content

Commit 4e30cb0

Browse files
Address review feedback and improve element access expression handling
Updated the fix to handle both expression and argumentExpression in ElementAccessExpression, and also modified isValidTypeOnlyAliasUseSite to check isInExpressionContext. However, the test is still failing and needs further investigation. Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
1 parent c0023be commit 4e30cb0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/compiler/utilities.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3695,7 +3695,8 @@ export function isInExpressionContext(node: Node): boolean {
36953695
case SyntaxKind.SatisfiesExpression:
36963696
return node === (parent as SatisfiesExpression).expression;
36973697
case SyntaxKind.ElementAccessExpression:
3698-
return node === (parent as ElementAccessExpression).argumentExpression;
3698+
const elementAccess = parent as ElementAccessExpression;
3699+
return node === elementAccess.expression || node === elementAccess.argumentExpression;
36993700
default:
37003701
return isExpressionNode(parent);
37013702
}
@@ -10504,14 +10505,14 @@ export function isValidBigIntString(s: string, roundTripOnly: boolean): boolean
1050410505
&& (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner.getTokenValue()) }));
1050510506
}
1050610507

10507-
/** @internal */
10508-
export function isValidTypeOnlyAliasUseSite(useSite: Node): boolean {
10509-
return !!(useSite.flags & NodeFlags.Ambient)
10510-
|| isInJSDoc(useSite)
10511-
|| isPartOfTypeQuery(useSite)
10512-
|| isIdentifierInNonEmittingHeritageClause(useSite)
10513-
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
10514-
|| !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
10508+
/** @internal */
10509+
export function isValidTypeOnlyAliasUseSite(useSite: Node): boolean {
10510+
return !!(useSite.flags & NodeFlags.Ambient)
10511+
|| isInJSDoc(useSite)
10512+
|| isPartOfTypeQuery(useSite)
10513+
|| isIdentifierInNonEmittingHeritageClause(useSite)
10514+
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
10515+
|| !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite) || isInExpressionContext(useSite));
1051510516
}
1051610517

1051710518
function isShorthandPropertyNameUseSite(useSite: Node) {

0 commit comments

Comments
 (0)