首页 > 解决方案 > HTML 文件中的 TypeScript 智能感知

问题描述

我创建了一个 TypeScript 文件,并通过将 ts 文件拖到 HTML 中,Visual Studio 在我的 HTML 文件中添加了引用。

现在虽然 ts 文件有类型信息,但 HTML 中的 Intellisense 不提供它们。

在此处输入图像描述

如何从 HTML 文件中引用的 ts 文件中生成 Intellisense 提示类型信息?

标签: typescriptvisual-studio-2017

解决方案


You can write JSDoc as mentioned in this MSDN for HTML Editor Intellisense.

https://msdn.microsoft.com/en-us/library/mt162307.aspx?f=255&MSPPError=-2147217396

/** @description Determines the area of a circle that has the specified radius parameter.  
 * @param {number} radius The radius of the circle.  
 * @return {number}  
 */  
function getArea(radius) {  
    var areaVal;  
    areaVal = Math.PI * radius * radius;  
    return areaVal;  
}  

enter image description here


推荐阅读