Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[no-useless-constructor] should not report on different constructor typeΒ #3820

Closed
@JounQin

Description

@JounQin
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/no-useless-constructor": [2]
  }
}
import { INTERNAL_SERVER_ERROR } from './constants'

import type { ApiError, ApiErrorOptions } from 'shared'

export class ResponseError extends Error implements ApiError {
  declare code: string
  declare reason: string
  declare extra: object | undefined
  declare details: unknown[] | undefined

  constructor(optionOrMsg: Partial<ApiErrorOptions> | string) {
    const options =
      typeof optionOrMsg === 'string' ? { message: optionOrMsg } : optionOrMsg
    super(options.message)
    this.code = options.code || String(INTERNAL_SERVER_ERROR)
    this.reason = options.reason || 'Internal Server Error'
    this.extra = options.extra
    this.details = options.details
  }
}

export class RedirectError extends ResponseError {
  constructor(url: string) { // error reported, unexpected, it changes the constructor type
    super(url)
  }
}

Expected Result

No error

Actual Result

error

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 4.29.3
@typescript-eslint/parser 4.29.3
TypeScript 4.4.2
ESLint 7.32.0
node 12.22.5

Metadata

Metadata

Labels

accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updatingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions