Skip to content

Bug: [no-misused-promises] Possible false positive in 5.27.0 #5121

Closed
@doberkofler

Description

@doberkofler

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 have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.7.2&sourceType=module&code=C4TwDgpgBAJghsOAVc0C8UDeBXAzhAJwEsYAuKAO2wFsAjQgXwG4AoFgM2woGNgiB7CrARwA4hGAA1OABsSCCAAowcAnAD85AEoRu-AjAA8uYMQoBzADRQuAawr8A7hQB8UAD6VsMmQEpyAAoE-NRE+IZ2Ds5umCxQUAQS2ARCQSFhEAB0ibj8MgBuSipqvqwMbBAAHmD6wFBwuCA8UJw8fIJQ+DKKeIQk5FR0hP5QaaHh8IgokB5ePjFxUHoUJsKIUBhwjnBEdZNiEtJyk0o4+MQwDL71uKPB4xCG+9PQnlTzrPFE7FCK+1AAQjQGHefiwi3iiWAySEsXi8KgmSR+0sEKgzEW5UWUJhcxkZRYQA&eslintrc=N4KAkARApgHgLlAdgEwM4QFwAIDa5IAOANgK4DmAlohgAJwCeBUqAxgE4UFwC0zRVcAPR8B3NlBYB7ALbSkyKMggAafBGLkqtBk1YcuvVP0RCAhkSIQQWLAF1VNiGxJFmmLKBuO6jZu048IiaCiJLc0hSoJKiK3ARsMpFu2HheXtBsCWwq1mkeuXlYECwAFhIA1qgAapIUyABKUHAkbIjuAGbmMQVeAL49ttb9vUA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

export async function sel(key: pkType): Promise<showProfileType | null> {
	const data = await dataGetValidate('!LAS_MOD_User_JSON.getEmpl', {emplid: key.emplid}) as Promise<showProfileType | null>;
	if (data !== null) {
		return {
			...data, // eslint-disable-line @typescript-eslint/no-misused-promises
			removeimg: false,
			removesign: false,
		};
	}

	return null;
}

ESLint Config

{
  "parser": "/Users/doberkofler/MyDev/ljs_app/trunk/periscope/node_modules/@typescript-eslint/parser/dist/index.js",
  "parserOptions": {
    "project": [
      "./tsconfig.json",
      "./test/selenium/tsconfig.json"
    ]
  },
  "plugins": [
    "@typescript-eslint"
  ],
  "rules": {
    "@typescript-eslint/no-misused-promises": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
    "skipLibCheck": true,
    "noEmit": true,
    "downlevelIteration": true,
    "sourceMap": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": false,
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedIndexedAccess": false,
    "useUnknownInCatchVariables": true,
    "exactOptionalPropertyTypes": false,
    "esModuleInterop": true,
    "declaration": false,
    "importHelpers": true,
    "moduleResolution": "node",
    "target": "es2017",
    "module": "esnext",
    "jsx": "react",
    "baseUrl": "../",
    "outDir": "../temp",
    "removeComments": true,
    "lib": [
      "dom"
    ],
    "paths": {
      "@alias_root/*": [
        "./*"
      ]
    }
  },
  "compileOnSave": false,
  "include": [
    "src/**/*",
    "test/unittest/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}

Expected Result

I would not expect the warning (this still worked in version 5.26.0)

Actual Result

The warning Expected a non-Promise value to be spreaded in an object @typescript-eslint/no-misused-promises in shown since the upgrade to version 5.27.0

Additional Info

Unfortunately, I was not able to reproduce the error in the playground

Versions

package version
@typescript-eslint/eslint-plugin 5.27.0
@typescript-eslint/parser 5.27.0
TypeScript 4.7.2
ESLint 8.16.0
node 18.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix: user errorissue was fixed by correcting the configuration / correcting the codepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions