angulartypescripttypedoc

Typedoc doesn't include decorators in the result JSON


I have upgraded my application to angular 15 and upgraded my typedoc version to 0.23.28 and typescript version to 4.8.4. Now When I try to generate the JSON, I can able to generate the JSON but it doesn't have decorators key values in it.

When I use angular 13 version and typedoc 0.22.9, typescript 4.4.3 I can get the JSON with the decorators key value pair in it.

I have reproduced this issue with basic angular project. I have created a angular project with the following versions

And I have created one Input called myName in the .src/app.component.ts

This is the command I was using to generate the JSON npx typedoc --entryPointStrategy expand ./src --json result.json

When I run this command, I am getting the result.json but it is not having decorators key value pair in it. I want the result JSON like before. How to get that I have provided the after and before output of JSON

Now

{
  "id": 7,
  "name": "myName",
  "kind": 1024,
  "kindString": "Property",
  "flags": {},
  "sources": [
    {
      "fileName": "app/app.component.ts",
      "line": 12,
      "character": 2
    }
  ],
  "type": {
    "type": "intrinsic",
    "name": "string"
  },
  "defaultValue": "'Gowthaman'"
}

Before

{
  "id": 6,
  "name": "myName",
  "kind": 1024,
  "kindString": "Property",
  "flags": {},
  "decorators": [
    {
      "name": "Input",
      "type": {
        "type": "reference",
        "qualifiedName": "InputDecorator",
        "package": "@angular/core",
        "name": "Input"
      },
      "arguments": {}
    }
  ],
  "sources": [
    {
      "fileName": "app.component.ts",
      "line": 12,
      "character": 2
    }
  ],
  "type": {
    "type": "intrinsic",
    "name": "string"
  },
  "defaultValue": "'Gowthaman'"
}


Solution

  • From typedocv0.23.0, they have removed the support for decorators. You can see that in the breaking changes in the changelog - https://github.com/TypeStrong/typedoc/blob/master/CHANGELOG.md#breaking-changes-3

    typedoc changelog

    In this github thread - https://github.com/TypeStrong/typedoc/issues/2346#issuecomment-1656806051 @gerrit0 has provided a plugin which you may find helpful. It will show how to add decorators by ourselves. You can refer to the thread.

    The Answer credits goes to @gerrit0

    Thank youuuuu!!! @gerrit0