43 lines
866 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
The return type ``++any++`` should be avoided because it prevents the type safety checks normally done by the compiler. When a function returns a primitive type (i.e. number, string or boolean) it is safe to replace ``++any++`` with ``++number++``, ``++string++`` or ``++boolean++`` type respectively, or remove the return type completely and let compiler infer it.
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
----
function foo() : any { // Noncompliant
return 1;
}
----
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
----
function foo() {
return 1;
}
// or
function foo(): number {
return 1;
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]