diff --git a/src/lib/converter/plugins/SourcePlugin.ts b/src/lib/converter/plugins/SourcePlugin.ts index 67ccbc790..fc77e3564 100644 --- a/src/lib/converter/plugins/SourcePlugin.ts +++ b/src/lib/converter/plugins/SourcePlugin.ts @@ -94,10 +94,13 @@ export class SourcePlugin extends ConverterComponent { if (isNamedNode(node)) { position = ts.getLineAndCharacterOfPosition( sourceFile, - node.name.end + node.name.getStart() ); } else { - position = ts.getLineAndCharacterOfPosition(sourceFile, node.pos); + position = ts.getLineAndCharacterOfPosition( + sourceFile, + node.getStart() + ); } if (reflection instanceof DeclarationReflection) { diff --git a/src/lib/converter/symbols.ts b/src/lib/converter/symbols.ts index 16cea538c..67dfc4025 100644 --- a/src/lib/converter/symbols.ts +++ b/src/lib/converter/symbols.ts @@ -466,7 +466,9 @@ function convertClassOrInterface( context.trigger( ConverterEvents.CREATE_DECLARATION, constructMember, - classDeclaration.getChildren().find(ts.isConstructorDeclaration) + ts.isClassDeclaration(classDeclaration) + ? classDeclaration.members.find(ts.isConstructorDeclaration) + : void 0 ); const constructContext = reflectionContext.withScope(constructMember); diff --git a/src/test/converter/class/specs-with-lump-categories.json b/src/test/converter/class/specs-with-lump-categories.json index f1d8369c3..6924d7272 100644 --- a/src/test/converter/class/specs-with-lump-categories.json +++ b/src/test/converter/class/specs-with-lump-categories.json @@ -753,6 +753,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 27, @@ -1025,6 +1028,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 43, @@ -1043,7 +1049,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Constructor param" + "shortText": "Constructor param" }, "type": { "type": "intrinsic", @@ -1057,7 +1063,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Private string property" + "shortText": "Private string property" }, "type": { "type": "intrinsic", @@ -1071,7 +1077,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Public number property" + "shortText": "Public number property" }, "type": { "type": "intrinsic", @@ -1085,7 +1091,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Public implicit any property\n" + "shortText": "Public implicit any property\n" }, "type": { "type": "intrinsic", @@ -1530,6 +1536,7 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": {}, "signatures": [ { "id": 96, @@ -1546,7 +1553,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "X component of the Vector" + "shortText": "X component of the Vector" }, "type": { "type": "intrinsic", @@ -1560,7 +1567,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Y component of the Vector" + "shortText": "Y component of the Vector" }, "type": { "type": "intrinsic", @@ -1574,7 +1581,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Vector name\n" + "shortText": "Vector name\n" }, "type": { "type": "intrinsic", @@ -1672,6 +1679,7 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": {}, "signatures": [ { "id": 105, @@ -1688,7 +1696,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "X component of the Vector" + "shortText": "X component of the Vector" }, "type": { "type": "intrinsic", @@ -1702,7 +1710,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Y component of the Vector" + "shortText": "Y component of the Vector" }, "type": { "type": "intrinsic", @@ -1716,7 +1724,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Z component of the Vector" + "shortText": "Z component of the Vector" }, "type": { "type": "intrinsic", @@ -1730,7 +1738,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Vector name\n" + "shortText": "Vector name\n" }, "type": { "type": "intrinsic", @@ -2661,6 +2669,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 168, @@ -2688,7 +2699,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Constructor parameter.\n" + "shortText": "Constructor parameter.\n" }, "type": { "type": "reference", @@ -2830,6 +2841,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 178, diff --git a/src/test/converter/class/specs.json b/src/test/converter/class/specs.json index 798dd88e0..5bad6ca2a 100644 --- a/src/test/converter/class/specs.json +++ b/src/test/converter/class/specs.json @@ -753,6 +753,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 27, @@ -1021,6 +1024,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 43, @@ -1039,7 +1045,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Constructor param" + "shortText": "Constructor param" }, "type": { "type": "intrinsic", @@ -1053,7 +1059,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Private string property" + "shortText": "Private string property" }, "type": { "type": "intrinsic", @@ -1067,7 +1073,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Public number property" + "shortText": "Public number property" }, "type": { "type": "intrinsic", @@ -1081,7 +1087,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Public implicit any property\n" + "shortText": "Public implicit any property\n" }, "type": { "type": "intrinsic", @@ -1526,6 +1532,7 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": {}, "signatures": [ { "id": 96, @@ -1542,7 +1549,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "X component of the Vector" + "shortText": "X component of the Vector" }, "type": { "type": "intrinsic", @@ -1556,7 +1563,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Y component of the Vector" + "shortText": "Y component of the Vector" }, "type": { "type": "intrinsic", @@ -1570,7 +1577,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Vector name\n" + "shortText": "Vector name\n" }, "type": { "type": "intrinsic", @@ -1668,6 +1675,7 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": {}, "signatures": [ { "id": 105, @@ -1684,7 +1692,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "X component of the Vector" + "shortText": "X component of the Vector" }, "type": { "type": "intrinsic", @@ -1698,7 +1706,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Y component of the Vector" + "shortText": "Y component of the Vector" }, "type": { "type": "intrinsic", @@ -1712,7 +1720,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Z component of the Vector" + "shortText": "Z component of the Vector" }, "type": { "type": "intrinsic", @@ -1726,7 +1734,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Vector name\n" + "shortText": "Vector name\n" }, "type": { "type": "intrinsic", @@ -2657,6 +2665,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 168, @@ -2684,7 +2695,7 @@ "kindString": "Parameter", "flags": {}, "comment": { - "text": "Constructor parameter.\n" + "shortText": "Constructor parameter.\n" }, "type": { "type": "reference", @@ -2826,6 +2837,9 @@ "kind": 512, "kindString": "Constructor", "flags": {}, + "comment": { + "shortText": "Constructor short text." + }, "signatures": [ { "id": 178, diff --git a/src/test/converter2.test.ts b/src/test/converter2.test.ts index c94d34167..fdcbceb70 100644 --- a/src/test/converter2.test.ts +++ b/src/test/converter2.test.ts @@ -224,6 +224,12 @@ const issueTests: Record void> = { "Property methods declared in interface should still allow comment inheritance" ); }, + + gh1626(project) { + const ctor = query(project, "Foo.constructor"); + equal(ctor.sources?.[0]?.line, 2); + equal(ctor.sources?.[0]?.character, 4); + }, }; describe("Converter2", () => { @@ -233,7 +239,6 @@ describe("Converter2", () => { app.bootstrap({ name: "typedoc", excludeExternals: true, - disableSources: true, tsconfig: join(base, "tsconfig.json"), plugin: [], }); diff --git a/src/test/converter2/issues/gh1626.ts b/src/test/converter2/issues/gh1626.ts new file mode 100644 index 000000000..596e309fb --- /dev/null +++ b/src/test/converter2/issues/gh1626.ts @@ -0,0 +1,3 @@ +export class Foo { + constructor() {} +} diff --git a/src/test/renderer/specs/classes/classes.GenericClass.html b/src/test/renderer/specs/classes/classes.GenericClass.html index 5c79b845e..58fdc3e12 100644 --- a/src/test/renderer/specs/classes/classes.GenericClass.html +++ b/src/test/renderer/specs/classes/classes.GenericClass.html @@ -158,31 +158,41 @@

Parameters

  • p1: any
    -

    Constructor param

    +
    +

    Constructor param

    +
  • p2: T
    -

    Private string property

    +
    +

    Private string property

    +
  • p3: number
    -

    Public number property

    +
    +

    Public number property

    +
  • p4: number
    -

    Public implicit any property

    +
    +

    Public implicit any property

    +
  • p5: string
    -

    Readonly property

    +
    +

    Readonly property

    +
  • diff --git a/src/test/renderer/specs/classes/flattened.FlattenedClass.html b/src/test/renderer/specs/classes/flattened.FlattenedClass.html index 6c78c4bbc..ba5e21837 100644 --- a/src/test/renderer/specs/classes/flattened.FlattenedClass.html +++ b/src/test/renderer/specs/classes/flattened.FlattenedClass.html @@ -129,7 +129,9 @@

    Parameters

  • options: { anotherValue?: string; moreOptions?: { moreValues: number }; value?: string }
    -

    The inline typed options object.

    +
    +

    The inline typed options object.

    +