57 lines
950 B
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)
include::message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]