Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug: [no-unsafe-argument] doesn't flag unsafe argument with a type constraint #10415

Open
Labels
accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@ronami

Description

@ronami

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

https://typescript-eslint.io/play/#ts=4.8.4&fileType=.tsx&code=CYUwxgNghgTiAEYD2A7AzgF3hkmCMAXPABQZEoCuAtgEYgwCU8AvAHzwBuSAlsANwAoUJFgJk6LDkwAmIgB4AKvBAAPHCmBp4lWvVakiCpm049%2BAgQHpL8AGZRuELchhwwGCAE8BUjHmJ48FBaUCieDIJWNmgAFkgUEMB2DhA%2BuBjSAUEhYRECQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tieQEMAZolp9oAc1gBbRC3RRE0aB2iRwYAL4h1QA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

declareconsttest1:(t:number)=>void;declareconsttest2:<Textendsnumber>(t:T)=>void;// fails correctlytest1(1asany);// should failtest2(1asany);

ESLint Config

module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-unsafe-argument":"error"},};

tsconfig

{"compilerOptions": {"strictNullChecks":true  }}

Expected Result

I expect all use-cases to be consistent and report this as an error.

Actual Result

The use-cases with a type constraint doesn't report this as an error.

Additional Info

This seems similar to#10314, and it looks like the fix should be similar.

I'll add that I see similar inconsistencies onno-unsafe-assignment andno-unsafe-return (false positives, in which the rule reports unnecessarily):

// no-unsafe-returndeclareconsttest1:(callback:()=>unknown)=>void;declareconsttest2:<T>(callback:()=>T)=>void;declareconsttest3:<Textendsunknown>(callback:()=>T)=>void;// passes correctlytest1(()=>1asany);// should passtest2(()=>1asany);// should passtest3(()=>1asany);// no-unsafe-assignmentdeclareconsttest4:(t:{t:unknown})=>void;declareconsttest5:<Textendsunknown>(t:{t:T})=>void;// pass correctlytest4({t:1asany});// should passtest5({t:1asany});

I'll be happy also to report them (separately or as part of this issue) if this makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp