Skip to content

Commit 8346adb

Browse files
committed
Fix crash when converting abstract mixins
Resolves #2011
1 parent 0904477 commit 8346adb

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Bug Fixes
1212

13+
- Fixed crash when converting abstract mixin class, #2011.
1314
- Readme files within monorepos now have `@link` tags resolved, #2029.
1415
- Correctly resolve unqualified links to class members within parameters, #2031.
1516
- TypeDoc will now consider other reflections with the same name as parents when resolving links, #2033.

src/lib/converter/types.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,16 @@ export function convertType(
153153
seenTypeSymbols.add(symbol);
154154
}
155155

156-
const converter = converters.get(node.kind);
156+
let converter = converters.get(node.kind);
157157
if (converter) {
158+
// Hacky fix for #2011, need to find a better way to choose the converter.
159+
if (
160+
converter === intersectionConverter &&
161+
!typeOrNode.isIntersection()
162+
) {
163+
converter = typeLiteralConverter;
164+
}
165+
158166
const result = converter.convertType(context, typeOrNode, node);
159167
if (symbol) seenTypeSymbols.delete(symbol);
160168
return result;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export class Component {}
2+
3+
type Constructor<T = Record<any, any>> = new (...args: any[]) => T;
4+
5+
export function Readable<TBase extends Constructor<Component>>(Base: TBase) {
6+
abstract class Reader extends Base {}
7+
return Reader;
8+
}

src/test/issueTests.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { deepStrictEqual as equal, ok } from "assert";
1+
import {
2+
deepStrictEqual as equal,
3+
notDeepStrictEqual as notEqual,
4+
ok,
5+
} from "assert";
26
import type { Application } from "../lib/application";
37
import {
48
DeclarationReflection,
@@ -671,6 +675,14 @@ export const issueTests: {
671675
equal(Comment.combineDisplayParts(fn.comment?.summary), "Docs");
672676
},
673677

678+
gh2011(project) {
679+
const readable = query(project, "Readable").signatures![0];
680+
const type = readable.type!;
681+
equal(type.type, "intersection" as const);
682+
notEqual(type.types[0], "intersection");
683+
notEqual(type.types[1], "intersection");
684+
},
685+
674686
gh2012(project) {
675687
project.hasOwnDocument = true;
676688
const model = query(project, "model");

0 commit comments

Comments
 (0)