File tree Expand file tree Collapse file tree
packages/eslint-plugin-react-hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7913,6 +7913,25 @@ const testsFlow = {
79137913 }
79147914 ` ,
79157915 } ,
7916+ // Flow type aliases in type assertions should not be flagged as missing dependencies
7917+ {
7918+ code : normalizeIndent `
7919+ function MyComponent() {
7920+ type ColumnKey = 'id' | 'name';
7921+ type Item = {id: string, name: string};
7922+
7923+ const columns = useMemo(
7924+ () => [
7925+ {
7926+ type: 'text',
7927+ key: 'id',
7928+ } as TextColumn<ColumnKey, Item>,
7929+ ],
7930+ [],
7931+ );
7932+ }
7933+ ` ,
7934+ } ,
79167935 ] ,
79177936 invalid : [
79187937 {
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import type {
2121 VariableDeclarator ,
2222} from 'estree' ;
2323
24- import { getAdditionalEffectHooksFromSettings } from '../shared/Utils' ;
24+ import { getAdditionalEffectHooksFromSettings } from '../shared/Utils' ;
2525
2626type DeclaredDependency = {
2727 key : string ;
@@ -80,7 +80,6 @@ const rule = {
8080 const rawOptions = context . options && context . options [ 0 ] ;
8181 const settings = context . settings || { } ;
8282
83-
8483 // Parse the `additionalHooks` regex.
8584 // Use rule-level additionalHooks if provided, otherwise fall back to settings
8685 const additionalHooks =
@@ -565,8 +564,12 @@ const rule = {
565564 continue ;
566565 }
567566 // Ignore Flow type parameters
568- // @ts -expect-error We don't have flow types
569- if ( def . type === 'TypeParameter' ) {
567+ if (
568+ // @ts -expect-error We don't have flow types
569+ def . type === 'TypeParameter' ||
570+ // @ts -expect-error Flow-specific AST node type
571+ dependencyNode . parent ?. type === 'GenericTypeAnnotation'
572+ ) {
570573 continue ;
571574 }
572575
You can’t perform that action at this time.
0 commit comments