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

56 lines
1.2 KiB
Plaintext

== Why is this an issue?
An intersection type combines multiple types into one. This allows you to add together existing types to get a single type that has all the features you need. However an intersection with a type without members doesn't change the resulting type. In the opposite the usage of ``++any++`` or ``++never++`` as part of an intersection will always results in ``++any++`` or ``++never++`` respectively. This is almost certainly an error.
=== Noncompliant code example
[source,javascript]
----
function foo(p: MyType & null) { // Noncompliant
// ...
}
function bar(p: MyType & any) { // Noncompliant
// ...
}
----
=== Compliant solution
[source,javascript]
----
function foo(p: MyType | null) {
// ...
}
// or
function foo(p: MyType & AnotherType) {
// ...
}
function bar(p: any) {
// ...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
* Remove this type without members or change this type intersection.
* Simplify this intersection as it always has type ["any" | "never"].
=== Highlighting
type without members or full intersection if it has ``++any++`` or ``++never++``
endif::env-github,rspecator-view[]