Link Search Menu Expand Document

Generate Values [TS only]

Ponicode Generate Values allows you to generate example values that match a given type.

It can be applied to type declarations, class declarations, function input parameters, function return types, and variables. For now, it is only available for TypeScript.

Types and classes

You will see a CodeLens decoration above all type and class declarations, reading “Ponicode: Generate Values”.

Generate values decorator

When you click on it, a new tab will open, showing you all the values Ponicode was able to suggest for the selected type. You can select whether you want happy paths or edge cases by selecting the desired tab at the top of the page.

webview type

If you want to generate values only for one particular property of a type or an object, you can right click on the property and select “Ponicode: Generate Values”. For instance, in the example below, values will be only generated for the property “surname” rather than for the whole object “User”.

property

Once again, a tab will open showing you all the values Ponicode was able to suggest for the selected property:

property webview

Functions

You can also generate values for functions, by right clicking on a function declaration or a function call, and selecting “Ponicode: Generate Values”:

function

function right click

The “Generate Values” tab will allow you to choose between visualising values that match:

  • The input parameters of the function
  • The return type of the function To switch between input parameters and return type, you can use the buttons at the top of the page:

input param webview

return type webview

Variables

You can also generate values that match a variable’s type. Once again, right click on the desired variable and select “Ponicode: Generate Values”.