Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.9k
Open
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
import{useCallback}from'react';const[a,b,c='']='somestr'.split('.');const_myCallback=useCallback((value:number[]=[],operator?:string)=>[...value,operator],[a,b,c]);typeParams=Promise<{x:string[]}>;const_processParams=async(params:Params)=>{const{x:[_a,_b,_c='123']}=awaitparams;};
ESLint Config
module.exports={"rules":{"@typescript-eslint/no-useless-default-assignment":"error"}}
tsconfig
{"compilerOptions": {"strictNullChecks":true }}Expected Result
None of these uses should get flagged under this rule.
Actual Result
"Default value is useless because the (parameter|property) is not optional."
Arrays are assumed to be of indefinite length
const [a, b, c = ''] = 'somestr'.split('.');const { x: [_a, _b, _c = '123'] } = await params;
These are only useless assignments when the array is of sufficient length.
Something about useCallback makes arg defaults get flagged
(value: number[] = [], operator?: string) => [...value, operator]
This works in isolation, but inside of useCallback, it gets flagged.
Additional Info
No response