32 lines
810 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Declare a constructor inside an ``++interface++``, and you will get a simple method with the name "constructor". The same thing will happen if you create a ``++new++`` method inside the ``++interface++``: you'll get a simple method named "new".
Instead, the intent was probably to specify that the type did not originate from a TypeScript file. In such cases, just use the ``++declare class++`` syntax.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
interface TypeDeclaredElsewhere {
someMethod(): number;
new(b: boolean): TypeDeclaredElsewhere; // Noncompliant
constructor(b: boolean): void; // Noncompliant
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
declare class TypeDeclaredElsewhere {
someMethod(): number;
constructor(b: boolean);
}
----