Matt
Matt

Reputation: 51

How does Typescript ESDoc measure comment coverage?

I am writing in Angular4 and Typescript with the esdoc-coverage-plugin and esdoc-typescript-plugin.

In my codebase, every method, class, and member have a comment block in this form:

/** @method methodName
 * @desc method description
 * @param {type} paramName - description of paramName
 * @returns {type}
 */
methodName(param: type) {
    /** the if statement does this */
    if(something) {
        doSomething();
    } else {
        doSomethingElse();
    }
}

Some files reach 100% with this format, other files are stuck at 40%. Even after putting in placeholder comments above each line of code, even documenting each if-else branch in detail, I cannot raise the coverage. What am I missing?

I cannot provide a physical snippet of the code, but I can try and answer any follow up questions you have if you need more information to give me an answer, thank you.

Upvotes: 3

Views: 291

Answers (1)

Matt
Matt

Reputation: 51

Ended up answering this for myself. I was using dependency injection in my component constructors.

/** @constructor Component1
 * @param {Service1} service1 - details about service1
 * @param {Service2} service2 - details about service2
 */
constructor(private service1: Service1, private service2: Service2) {
    ...
}

This will leave you with no coverage on the members "service1" and "service2" of your class. So instead, I used a syntax reminiscent of my Java days and it got me full coverage, at the expense of being far more verbose.

private service1: Service1;
private service2: Service2;
/** @constructor Component1 */
constructor(service1: Service1, service2: Service2) {
    /** @private {Service1} service1 - details about service1 */
    this.service1 = service1;
    /** @private {Service2} service2 - details about service2 */
    this.service2 = service2;
    ...
}

Upvotes: 0

Related Questions