Skip to content

linter: typescript/no-misused-new false positive #21990

Description

@brianjhanson

I'm not a total typescript guru, so this could definitely be a "me" problem but based on the docs for the typescript/no-misused-new rule I would expect this example

interface TestInterface {
  new (config: Record<string, any>): TestInterface;
}

interface SomeObject {
  Test: TestInterface
}

class TestClass {
  constructor(config: Record<string, any>) {
    console.log({config});
  }
}

const someObject: SomeObject = {
  Test: TestClass
}

new someObject.Test({config: 'value'});

Specifically because of the second example of correct code:

interface I {
  new (): C;
}

Instead, I'm seeing an Oxc warning

Oxc Warning: Interfaces cannot be constructed, only classes.


Playground link

Metadata

Metadata

Assignees

Labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions