TypeScript已经支持XML文档吗?

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>
    }
}
3个回答

5

目前语言规范中并未提及该功能,因此目前不支持此功能。

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

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

您可以在项目页面上建议这样的功能 - 如果这个想法得到支持,它将被添加到未来的语言中。

谢谢,已添加功能请求。 - Peter Kiers
1
有功能请求的链接吗?我想要支持它。 - Amr
我在typescript.codeplex.com/discussions/397660上发布了评论:Anders Hejlsberg写道,他们的目标是使用JSDoc而不是Xml文档。 - Peter Kiers

1

显然,JSDoc现在得到支持,至少在Visual Studio Code中是这样,因为我目前正在使用它,并且它会显示在智能感知弹出窗口中。


谢谢,这在我的VSCode中运行良好,并且官方页面在这里:https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript - Sam

0

就我所知,微软的示例确实包含这种注释风格。例如Parallax示例:

    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);
        });
    }

我在CodePlex上添加了一条评论,Anders Hejlsberg的回复是他们倾向于使用JsDoc。http://typescript.codeplex.com/discussions/397660 - Peter Kiers

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接