2

I created a TypeScript file and by dragging the ts file to HTML, Visual Studio added the reference in my HTML file.

Now although the ts file has type information, Intellisense in HTML doesn't provide them.

enter image description here

How do I make Intellisense prompt type information from the referenced ts file in HTML file?

1 Answer 1

1
+50

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

Sign up to request clarification or add additional context in comments.

2 Comments

But I'm using TypeScript hoping to bake type information into the code. I expect to write function getArea(radius : number) : number, and in another HTML file Visual Studio prompts the types.
Well VS Intellisense for HTML does not know about ts because it is only including JS file on the page. TypeScript does not generate JSDoc, you have to write it yourself. Because if you provide custom JSDoc, how will typescript know what to merge with its own generated JSDoc? TypeScript intellisense is only for TypeScript files, not in JS file because in JS language service, only JSDoc is used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.