VS Code 工具提示提示不显示注释

问题描述 投票:0回答:1

我已经在打字稿中为我的函数编写了注释,我希望在使用该函数的所有地方都看到注释。但对于这段代码:

/** Checks localStorage for "lang".
 *  Returns "fa" if not specified.
 */

export const getAppLanguages = () => {
  const value = window.localStorage.getItem("lang");
  if (value === "fa") return "fa";
  if (value === "en") return "en";
  window.localStorage.setItem("lang", "fa");
  return "fa";
};

当我将鼠标悬停在其声明的同一文件中的函数上时,提示包含注释: tool tip with comment

但在我使用此函数的其他文件中,它不显示注释,例如以下代码:

const initialState: initialLanguageStateType = {
  appLanguage:
    (getAppLanguages() as AppLanguageEnum.fa | AppLanguageEnum.en) ||
    AppLanguageEnum.fa,
};

我遇到过:

tool tip without comment

我尝试在 vscode 设置中添加一些配置。

typescript visual-studio-code comments
1个回答
0
投票

我知道这已经很旧了,但我也遇到了同样的问题,我通过删除注释和代码之间的空格来解决

/** Checks localStorage for "lang".
 *  Returns "fa" if not specified.
 */
export const getAppLanguages = () => {
  const value = window.localStorage.getItem("lang");
  if (value === "fa") return "fa";
  if (value === "en") return "en";
  window.localStorage.setItem("lang", "fa");
  return "fa";
};
© www.soinside.com 2019 - 2024. All rights reserved.