Skip to content

Commit

Permalink
Fix crash when converting abstract mixins
Browse files Browse the repository at this point in the history
Resolves #2011
  • Loading branch information
Gerrit0 committed Aug 26, 2022
1 parent 0904477 commit 8346adb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Bug Fixes

- Fixed crash when converting abstract mixin class, #2011.
- Readme files within monorepos now have `@link` tags resolved, #2029.
- Correctly resolve unqualified links to class members within parameters, #2031.
- TypeDoc will now consider other reflections with the same name as parents when resolving links, #2033.
Expand Down
10 changes: 9 additions & 1 deletion src/lib/converter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ export function convertType(
seenTypeSymbols.add(symbol);
}

const converter = converters.get(node.kind);
let converter = converters.get(node.kind);
if (converter) {
// Hacky fix for #2011, need to find a better way to choose the converter.
if (
converter === intersectionConverter &&
!typeOrNode.isIntersection()
) {
converter = typeLiteralConverter;
}

const result = converter.convertType(context, typeOrNode, node);
if (symbol) seenTypeSymbols.delete(symbol);
return result;
Expand Down
8 changes: 8 additions & 0 deletions src/test/converter2/issues/gh2011.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class Component {}

type Constructor<T = Record<any, any>> = new (...args: any[]) => T;

export function Readable<TBase extends Constructor<Component>>(Base: TBase) {
abstract class Reader extends Base {}
return Reader;
}
14 changes: 13 additions & 1 deletion src/test/issueTests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { deepStrictEqual as equal, ok } from "assert";
import {
deepStrictEqual as equal,
notDeepStrictEqual as notEqual,
ok,
} from "assert";
import type { Application } from "../lib/application";
import {
DeclarationReflection,
Expand Down Expand Up @@ -671,6 +675,14 @@ export const issueTests: {
equal(Comment.combineDisplayParts(fn.comment?.summary), "Docs");
},

gh2011(project) {
const readable = query(project, "Readable").signatures![0];
const type = readable.type!;
equal(type.type, "intersection" as const);
notEqual(type.types[0], "intersection");
notEqual(type.types[1], "intersection");
},

gh2012(project) {
project.hasOwnDocument = true;
const model = query(project, "model");
Expand Down

0 comments on commit 8346adb

Please sign in to comment.