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

Enhancement: [no-misused-promises] Check when an abstract method implementation returns a promise instead of void #8739

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@alythobani

Description

@alythobani

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&showAST=es&fileType=.tsx&code=FBA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

abstractclassA{thing:number|null=null;abstractsetThing():void;setAndPrintThing():void{this.setThing();console.log(this.thing);}}classBextendsA{// Expected no-misused-promises error hereasyncsetThing():Promise<void>{constthing=awaitfetchThing();this.thing=thing;}}asyncfunctionfetchThing():Promise<number>{returnawaitnewPromise<number>((resolve)=>{setTimeout(()=>{resolve(5);},1000);});}constb=newB();// Prints null instead of 5b.setAndPrintThing();function_setAndPrintThing(setThing:()=>void):void{setThing();console.log(b.thing);}// Correctly triggers no-misused-promises error://  "Promise returned in function argument where a void return was expected"_setAndPrintThing(b.setThing.bind(this));

ESLint Config

{"rules":{"@typescript-eslint/no-misused-promises":"error"}}

tsconfig

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

Expected Result

Line 14 (whereB.setThing is implemented) should show an error like "Promise returned in abstract method implementation where a void return was expected"

Actual Result

There's no error on line 14

Additional Info

I'm not sure why the playground link doesn't seem to be working, but hopefully you can see my code sample anyway and it makes sense.

Based on theno-misused-promises page it looks like maybe this should be another category underchecksVoidReturn?

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp