mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
documentation changes based on review
Co-Authored-By: shati-patel <42641846+shati-patel@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c8d60c9e2a
commit
b741a65e9b
@@ -8,10 +8,10 @@ In TypeScript the keywords <code>constructor</code> and <code>new</code> for
|
||||
member declarations are used to declare constructors in classes and interfaces
|
||||
respectively.
|
||||
However, a member declaration with the name <code>new</code> in an interface
|
||||
or <code>constructor</code> in a class, will declare ordinary methods named
|
||||
<code>new</code> or <code>constructor</code> rather than constructors.
|
||||
or <code>constructor</code> in a class, will declare an ordinary method named
|
||||
<code>new</code> or <code>constructor</code> rather than a constructor.
|
||||
Similarly, the keyword <code>function</code> is used to declare functions in
|
||||
some contexts, however, using the name <code>function</code> for a class
|
||||
some contexts. However, using the name <code>function</code> for a class
|
||||
or interface member declaration declares a method named <code>function</code>.
|
||||
</p>
|
||||
|
||||
@@ -48,8 +48,8 @@ in the first place.
|
||||
</example>
|
||||
<references>
|
||||
|
||||
<li>TypeScript specification: <a href="https://github.com/microsoft/TypeScript/blob/master/doc/spec.md#3.8.9">Constructor Type Literals</a></li>
|
||||
<li>TypeScript specification: <a href="https://github.com/microsoft/TypeScript/blob/master/doc/spec.md#8.3.1">Constructor Parameters</a></li>
|
||||
<li>TypeScript specification: <a href="https://github.com/microsoft/TypeScript/blob/master/doc/spec.md#3.8.9">Constructor Type Literals</a>.</li>
|
||||
<li>TypeScript specification: <a href="https://github.com/microsoft/TypeScript/blob/master/doc/spec.md#8.3.1">Constructor Parameters</a>.</li>
|
||||
|
||||
</references>
|
||||
</qhelp>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @name Suspicious method name declaration
|
||||
* @description A method declaration with a name that would be a special keyword in another
|
||||
* @description A method declaration with a name that is a special keyword in another
|
||||
* context is suspicious.
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
|
||||
@@ -2,7 +2,7 @@ var foo: MyInterface = 123 as any;
|
||||
|
||||
interface MyInterface {
|
||||
function (): number; // OK. Highly unlikely that it is an accident when there are other named methods in the interface.
|
||||
(): number; // OK: What was probaly meant above.
|
||||
(): number; // OK: What was probably meant above.
|
||||
new:() => void; // OK! This is a property, not a method, we ignore those.
|
||||
constructor(): string; // NOT OK! This a called "constructor"
|
||||
new(): Date; // OK! This a constructor signature.
|
||||
@@ -49,4 +49,4 @@ declare class Quz {
|
||||
}
|
||||
|
||||
var bla = new Foo();
|
||||
var blab = new Baz();
|
||||
var blab = new Baz();
|
||||
|
||||
Reference in New Issue
Block a user