Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

75 lines
1.5 KiB
Plaintext

== Why is this an issue?
Union and intersection types are convenient but can make code harder to read and maintain. So if a particular union or intersection is used in multiple places, the use of a type alias is recommended.
=== Noncompliant code example
[source,javascript]
----
function foo(x:string|null|number) { // Noncompliant
// ...
}
function bar(x:string|null|number) {
// ...
}
function zoo(): string|null|number {
return null;
}
----
=== Compliant solution
[source,javascript]
----
type MyType = string | null | number;
function foo(x: MyType) {
// ...
}
function bar(x: MyType) {
// ...
}
function zoo(): MyType {
return null;
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Replace this [union|intersection] type with a type alias.
=== Highlighting
* Primary: first occurrence of the union/intersection
* Secondary: All other occurrences
** message: 'Following occurrence.'
'''
== Comments And Links
(visible only on this page)
=== on 14 Nov 2017, 22:02:10 Ann Campbell wrote:
\[~jeanchristophe.collet] there are no ``++//Noncompliant++`` comments.
=== on 15 Nov 2017, 09:19:00 Jean-Christophe Collet wrote:
That's because it's not a particular line that is non compliant, but the repetition of the specific union.
=== on 27 Nov 2017, 19:04:40 Ann Campbell wrote:
\[~jeanchristophe.collet] I've updated the highlighting to match the 'Noncompliant' comment.
endif::env-github,rspecator-view[]