Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Using TypeScript utility types breaks the generated type in documentation.json #1424

Open
TomONeill opened this issue Dec 12, 2023 · 0 comments
Assignees

Comments

@TomONeill
Copy link

Overview of the issue

Using TypeScript utility types like Uncapitalize<> results in a literal string in the documentation.json of said utility type, instead of the compiled type.

Operating System, Node.js, npm, compodoc version(s)

Windows 11 Enterprise (23H2)

Node v20.9.0
npm 10.2.4

@compodoc/compodoc@1.1.22

Compodoc installed globally or locally ?

Locally

Motivation for or Use Case

We're using Storybook together with Compodoc and since we're also using utility types like Uncapitalize in several instances, this results in the Controls being unable to propagate the right type/value.

Reproduce the error
  1. Create a class with either a property or method with a utility type (like Uncapitalize).
@Injectable({
    providedIn: 'root'
})
export class MyService {
    public myMethod(myParam: Uncapitalize<"ExampleA" | "ExampleB">): void {
    }
}
  1. Run compodoc

Result:

{
    "name": "MyService",
    "id": "injectable-MyService-xxxx",
    "file": "xxx/src/lib/my.service.ts",
    "properties": [],
    "methods": [
        {
            "name": "myMethod",
            "args": [
                {
                    "name": "myParam",
                    "type": "Uncapitalize<>",
                    "deprecated": false,
                    "deprecationMessage": ""
                }
            ]
        }
    ]
}

note that the result was modified to better point out the issue

Notice how type literally has string Uncapitalize with an empty generic. I expected "exampleA" | "exampleB" as type.

Related issues

#1329

But in this issue another problem is pointed out (keyof typeof) even though it relates to the problem pointed out in this issue.

Suggest a Fix

-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants