Skip to content

Commit c559d47

Browse files
Remove unknown from ts intersections
1 parent ec15603 commit c559d47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ export function tsArrayOf(type: string): string {
158158
/** X & Y & Z; */
159159
export function tsIntersectionOf(...types: string[]): string {
160160
if (types.length === 1) return String(types[0]); // don’t add parentheses around one thing
161-
return types.map((t) => (TS_UNION_INTERSECTION_RE.test(t) ? `(${t})` : t)).join(" & ");
161+
return types
162+
.filter((t) => t !== "unknown")
163+
.map((t) => (TS_UNION_INTERSECTION_RE.test(t) ? `(${t})` : t))
164+
.join(" & ");
162165
}
163166

164167
/** NonNullable<T> */

0 commit comments

Comments
 (0)