Home > Software design >  Why is TypeScript not expanding interface properties?
Why is TypeScript not expanding interface properties?

Time:08-16

I have an interface in TypeScript that I use to type the parameters of a function. However, when I look at the function signature in VSCode it is not showing me the properties of the interface (see below picture), which is not very helpful.

Is there a way to expand the properties to help the developer know what parameters are required by the function?

As a workaround, I tried to add documentation to the function parameters, but as you can see, they do not show up, only the return description and return type

export interface ActivitiesParams {
  activity_types?: string[] | string;
  until?: string;
  after?: string;
  direction?: string;
  date?: string;
  page_size?: number;
  page_token?: string;
}

Picture:

Intellisense in VSCode

CodePudding user response:

The autocomplete will do that job for you.

Just trigger it within the object you want to build.

enter image description here

Playground

  • Related