8

TypeScript 中是否已经支持 XML 文档?似乎没有,但也许我忽略了一些东西。

我想要这样的东西:

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>
    }
}
4

3 回答 3

5

语言规范中没有提到这一点,因此目前不支持此功能。

唯一使用的注释语法是创建对源文件的依赖:

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

您可以在项目页面上建议诸如此类的功能- 如果该想法获得牵引力,将来可以将其添加到语言中。

于 2012-10-02T08:53:42.293 回答
1

显然,现在至少在 Visual Studio Code 中支持 JSDoc,因为我目前在那里使用它,它显示在智能感知弹出窗口中。

于 2016-12-28T11:58:15.657 回答
0

值得一提的是,来自 Microsoft 的示例确实包含这种评论风格。来自视差样本:

    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);
        });
    }
于 2012-10-06T04:49:42.167 回答