Skip to content

Commit 2d0b5da

Browse files
committed
Support Flow as expressions in ESLint rules (#27590)
Support Flow `as` expressions in ESLint rules, e.g. `<expr> as <type>`. This is the same syntax as TypeScript as expressions. I just looked for any place referencing `TSAsExpression` (the TS node) or `TypeCastExpression` (the previous Flow syntax) and added a case for `AsExpression` as well. DiffTrain build for [6bfc0e0](6bfc0e0)
1 parent 253126e commit 2d0b5da

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d947c2f1100dfd006fd91c6e9ed84d42ca7ab088
1+
6bfc0e032acc7e5ad6da2a09f3c4f47f3321da2c

compiled/facebook-www/eslint-plugin-react-hooks.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ var ExhaustiveDeps = {
960960
return false;
961961
}
962962

963-
while (init.type === 'TSAsExpression') {
963+
while (init.type === 'TSAsExpression' || init.type === 'AsExpression') {
964964
init = init.expression;
965965
} // Detect primitive constants
966966
// const foo = 42
@@ -2232,8 +2232,7 @@ function getConstructionExpressionType(node) {
22322232
return null;
22332233

22342234
case 'TypeCastExpression':
2235-
return getConstructionExpressionType(node.expression);
2236-
2235+
case 'AsExpression':
22372236
case 'TSAsExpression':
22382237
return getConstructionExpressionType(node.expression);
22392238
}

0 commit comments

Comments
 (0)