Search code examples
javascripttypescriptcommentsjsdoc

Which comment format is correct for TypeScript with annotations?


I've been searching for an example of commenting on code that is annotated, all I can find are examples of comments on non annotated code. Can anyone clarify the correct or approved standard way of writing this?

/**
 * Description.
 */
@Component({...})
class MyClass{...}

Or would this be written as

@Component({...})
/**
 * Description.
 */
class MyClass{...}

Solution

  • CompoDoc has an example of them using the first variation of the syntax you described. So, that means this (quoting their example) :

    /**
     * @ignore
     */
    @Component({
        selector: 'app-root',
        templateUrl: './app.component.html',
        styleUrls: ['./app.component.css']
    })
    export class AppComponent {}
    

    However as shows this issue, there's currently no fixed or official specification on how to write your TSDoc.