The VS Code tooltip feature fails to display comments

After writing comments for my function in TypeScript, I wanted to see those comments displayed wherever the function was used. However, in the following code snippet:

/** 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";
};

When hovering over the function within the same file it was declared in, the tooltip includes the comment: tooltip with comment

However, in other files where I have used this function, the comments don't show up. For example, in the following code:

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

I encountered:

tooltip without comment

I attempted to add some configuration in VSCode settings.

Answer №1

Although this solution may seem outdated, I faced a similar problem and was able to resolve it by eliminating the space between the comment and the code block.

/** Retrieves the current language settings from localStorage.
 *  Defaults to "en" if not specified.
 */
export const getAppLanguage = () => {
  const langValue = window.localStorage.getItem("lang");
  
  if (langValue === "fa") return "fa";
  if (langValue === "en") return "en";

  window.localStorage.setItem("lang", "en");

  return "en";
};

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Filtering object properties from arrays in Angular HTML can be achieved using various methods such as

I am currently working on a unique "Presentation-Editor" tool where I can see all the presentations that have been created. For this overview, I want to showcase the first slide of each presentation as a preview. However, there is a challenge because I on ...

The intricate field name of a TypeScript class

I have a TypeScript class that looks like this - export class News { title: string; snapshot: string; headerImage: string; } In my Angular service, I have a method that retrieves a list of news in the following way - private searchNews(sor ...

Can you explain the significance of using square brackets in the typescript enum declaration?

While reviewing a typescript file within an Angular ngrx project titled collection.ts, I came across the declaration of enum constants. import { Action } from '@ngrx/store'; import { Book } from '../models/book'; export enum Collecti ...

What steps should I take to fix the error "property scrollIntoView of null cannot be read"?

I start a new project using Angular .html file: <a (click)="go()">toto</a> <div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam iaculis ex porttitor semper iaculis. Nam dapibus erat interdum, scelerisque magna et, finibus ...

One method for deducing types by analyzing the function's return value within a react prop

There is a component definition that accepts two generics: function AsyncFlatList<ApiResponse, Item>({}: { url: string; transformResponse: (response: ApiResponse) => Item[]; keyExtractor: (item: Item) => string; }) { // the implementati ...

What causes the return value of keyof to vary in this particular case?

type AppleNode = { type: 'Apple' name: string score: number } type BananaNode = { type: 'Banana' id: number score: number } type FruitNodes = AppleNode | BananaNode type fruitTest = { [P in keyof FruitNodes]: 21 } // Th ...

Leveraging TypeScript with Angular components

Situation: On my website, I have a section called the "main page" where all available books are displayed. The "main page" is represented by the blue box in the image provided and serves as a key component on my site. Additionally, there is a separate co ...

What could be the reason for my npm package installed globally to not be able to utilize ts-node?

Recently, I've been working on developing a CLI tool for my personal use. This tool essentially parses the standard output generated by hcitool, which provides information about nearby bluetooth devices. If you're interested in checking out the ...

Vue cannot detect the component that is provided by my plugin

This unique plugin, currently only includes a single component (coded in TypeScript): import _Vue, { PluginObject } from "Vue"; import MyComponent from "./MyComponent.vue"; const VuePlugin: PluginObject<void> = { install(Vue: typeof _Vue): void { ...

The geolocation feature is operational in the browser test, but it is not functioning properly on the

I am currently creating an application that requires accessing the user's location at a specific point in time. To achieve this, I have utilized the ionic native geolocation feature which communicates with the Google API for reverse geocoding. Everyt ...

The problem with the Custom Select Component: Error Arises When Utilizing the Generic Type <T,> with a Comma as Opposed to <T> Without a Comma

I recently developed a unique custom select component that extends the standard HTML select element. During the process, I made use of a generic type to accommodate a wide range of data types, but encountered an unexpected error. The issue seems to persist ...

Ensuring that the designated key of an object is an extension of Array

What is the best way to ensure that the specified keyof a type extends an array? Consider the following type example: type TestType = { arrayKey: Array<number>, notArrayKey: number } There is also a function that accesses the specified key ...

Style the date using moment

All languages had a question like this except for JavaScript. I am trying to determine, based on the variable "day," whether it represents today, tomorrow, or any other day. ...

Strategies for displaying error messages in case of zero search results

I am currently developing a note-taking application and facing an issue with displaying error messages. The error message is being shown even when there are no search results, which is not the intended behavior. Can someone help me identify what I am doing ...

A guide on incorporating and utilizing third-party Cordova plugins in Ionic 5

Attempting to implement this plugin in my Ionic 5 application: https://www.npmjs.com/package/cordova-plugin-k-nfc-acr122u I have added the plugin using cordova plugin add cordova-plugin-k-nfc-acr122u but I am unsure of how to use it. The plugin declares: ...

Troubleshooting ReactJs in Chrome during page load: encountering issues with undefined properties when utilizing the console

When debugging React on initial page load, I encounter a problem. Upon hovering over this, I can see the content, but using the console shows that this is undefined. Interestingly, this issue only arises when I refresh the page; clicking around does not tr ...

Exploring the elements within the ContentChildren directive in Angular

Presenting my component: import { Component, OnInit, ContentChildren, QueryList } from '@angular/core'; import { IconBoxComponent } from '../icon-box/icon-box.component'; @Component({ selector: 'app-three-icon-box', temp ...

IntelliJ does not provide alerts for return type inconsistencies in TypeScript

During the development of our web application using react+typescript+spring boot with IntelliJ, everything seemed to be going smoothly until I came across an unexpected issue. Take a look at this code snippet example: export class TreeRefreshOutcome { } e ...

Ensuring Input Validity in Angular4 and Symfony3

Currently, I am utilizing angular 4 and symfony3. In my application, there is a textarea that is required. However, when I only press enter (code 13) in this textarea without entering any other character, the form gets submitted. How can I prevent this spe ...

Exploring the Differences Between ionViewWillEnter and ionViewDidEnter

When considering whether to reinitiate a cached task, the choice between ionDidLoad is clear. However, when we need to perform a task every time a view is entered, deciding between ionViewWillEnter and ionViewDidEnter can be challenging. No specific guid ...