We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c559d47 commit 334f806Copy full SHA for 334f806
src/utils.ts
@@ -157,11 +157,10 @@ export function tsArrayOf(type: string): string {
157
158
/** X & Y & Z; */
159
export function tsIntersectionOf(...types: string[]): string {
160
+ types = types.filter((t) => t !== "unknown");
161
+ if (types.length === 0) return "unknown";
162
if (types.length === 1) return String(types[0]); // don’t add parentheses around one thing
- return types
- .filter((t) => t !== "unknown")
163
- .map((t) => (TS_UNION_INTERSECTION_RE.test(t) ? `(${t})` : t))
164
- .join(" & ");
+ return types.map((t) => (TS_UNION_INTERSECTION_RE.test(t) ? `(${t})` : t)).join(" & ");
165
}
166
167
/** NonNullable<T> */
0 commit comments