Question

Is there already support for XML Documentation inside TypeScript? It seems there isn't, but maybe I am overlooking something.

I'd like something like this:

export class Point {
   /// <summary>This is a Point class.</summary>

    constructor (public x: number, public y: number) { 
        /// <summary>Creates a new Point object</summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
    }
}
Was it helpful?

Solution

There is no mention of this in the language specification, so there is currently no support for this feature.

The only comment syntax in use is to create a dependency on a source file:

/// <reference path="..."/>

You can suggest features such as this on the project page - so it could be added to the language in the future if the idea gains traction.

OTHER TIPS

For what it's worth, samples from Microsoft do include this style of comment. From the Parallax sample:

    constructor(scrollableContent: HTMLElement, perspective: number) {
        /// <param name="scrollableContent">The container that will be parallaxed.</param>
        /// <param name="perspective">The ratio of how much back content should be 
        /// scrolled relative to forward content.  For example, if this value is 
        /// 0.5, and there are 2 surfaces, the front-most surface would be scrolled 
        /// normally, and the surface behind it would be scrolled half as much.</param>
        this.perspective = perspective;
        this.surface = [];
        this.content = scrollableContent;

        $(scrollableContent).scroll((event: JQueryEventObject) => {
            this.onContainerScroll(event);
        });
    }

Apparently JSDoc is now supported, at least in Visual Studio Code, as I'm currently using it there and it shows in the intellisense popups.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top