0

I have a method in utils file that is commented like this, the body is not important.

/**
 * Calculates width of the column.
 *
 * @param {string} text text.
 * @param {boolean} hasTooltip does title have tooltip?
 * @return {number} width of the column.
 */
const getColumnWidth = (text, hasTooltip) => {
  const padding = 8;
  const tooltipWidth = hasTooltip ? 22 : 0;
  const sortArrowWidth = 26;

  const context = document.createElement('canvas').getContext('2d');
  context.font = getComputedStyle(document.body).font;
  return context.measureText(text).width + padding + tooltipWidth + sortArrowWidth;
}

export {
  ...
  getColumnWidth
};

Then this method is imported in another file.

import {
  ...
  getColumnWidth
} from "c/dceSoftwareUtils";

The problem is when i use intellisense (ctrl + space) i see import instead of method comment: enter image description here

But i need it to be displayed same way as getComputedStyle: enter image description here

I believe this is caused by imported method being seen as property and not a method. How can i change this?

Zobla
  • 123
  • 2
  • 7
  • What you're showing in your screenshots is consistent with not having actually exported `getColumnWidth`. If I create a module with `export const getColumnWidth = ...` in it, then import it into another, I see what you're expecting to see. But if I don't have the `export`, I see what you've shown in your first screenshot. – T.J. Crowder Mar 24 '22 at 11:45
  • Re your edit (thanks for that!): I also see what I expect with that form of export (since it comes to the same thing). – T.J. Crowder Mar 24 '22 at 11:47
  • So you see actual comment with this form of export, like in the last screenshot? Not in my case. Could it be that something in the settings of vscode needs to be changed? – Zobla Mar 24 '22 at 11:53
  • Yes, I can. I wouldn't expect this to be settings-related, and don't recall doing anything to enable it. Sorry not to be more help! – T.J. Crowder Mar 24 '22 at 11:58

0 Answers0