30 lines
782 B
Plaintext
Raw Normal View History

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.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
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
}
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
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);
}
----