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 [6bfc0e032a](https://github.com/facebook/react/commit/6bfc0e032acc7e5ad6da2a09f3c4f47f3321da2c)
This commit is contained in:
kassens
2023-11-01 19:29:00 +00:00
parent 253126e424
commit 2d0b5da936
2 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
d947c2f1100dfd006fd91c6e9ed84d42ca7ab088
6bfc0e032acc7e5ad6da2a09f3c4f47f3321da2c
@@ -960,7 +960,7 @@ var ExhaustiveDeps = {
return false;
}
while (init.type === 'TSAsExpression') {
while (init.type === 'TSAsExpression' || init.type === 'AsExpression') {
init = init.expression;
} // Detect primitive constants
// const foo = 42
@@ -2232,8 +2232,7 @@ function getConstructionExpressionType(node) {
return null;
case 'TypeCastExpression':
return getConstructionExpressionType(node.expression);
case 'AsExpression':
case 'TSAsExpression':
return getConstructionExpressionType(node.expression);
}