Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed as not planned
Closed as not planned
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
// no-unsafe-argument:declareconsta:{foo:any};functionfoo(x:{foo:string}):{foo:string}{returnx;}// Unsafe argument of type `{ foo: any; }` assigned to a parameter of type `{ foo: string; }`.foo(a);declareconstb:any[]|number;functionbar(x:string[]|number):string[]|number{returnx;}// Unsafe argument of type `number | any[]` assigned to a parameter of type `number | string[]`.bar(b);// similarly with `no-unsafe-return`declareconstc:{foo:any};exportfunctionhello():{foo:string}{// Unsafe return of type `{ foo: any }` from function with return type `{ foo: string }`.returna;}declareconstd:any[]|number;exportfunctionworld():string[]|number{// Unsafe return of type `any[]` from function with return type `number | string[]`.returnb;}
ESLint Config
module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-unsafe-assignment":"error","@typescript-eslint/no-unsafe-return":"error",},};
tsconfig
{"compilerOptions": {"strictNullChecks":true }}
Expected Result
I expected the rule to fail on these, similarly to how it fails on similar boxed values likePromise<any>
, orany[]
, along with a combination of boxed values.
Actual Result
The code example is reporting no lint errors.
Additional Info
Theno-unsafe-*
rule family misses some edge case checks, mostly around boxed values (like arrays, objects, promises, etc.). While you get a warning for mostany
values wrapped in a box, I found some the rule misses around union and object types.
I made a simplified implementation to test-run on typescript-eslint's own repo andfound one issue here (matchingstring[] | undefined
withany[]
).