Skip to content

feat(packages/code-block): generate inputs for functions #13

Description

@NicolasLopes7

Is your feature request related to a problem? Please describe.

Developers often have to test their functions with different inputs to ensure their code works as expected. However, manually needing to create the function, and log the result can be boring. So, to make that a way easier I've thought about generating the inputs for the functions.

Describe the solution you'd like

I would like to request a new feature that automates the process of generating inputs for functions in JS/TS code. Specifically, if the root node of the AST is a variable assigned to an arrow function or a regular function, the feature should retrieve all the parameters and their possible types and generate input fields accordingly.

For example, if there is a function defined as:

const sum = (a: number, b: number) => a + b

The editor should generate two number input fields to allow users to provide input for the parameters a and b. Also, should replace the original node on the AST to incorporate the generated inputs.

Additional context

This feature could leverage the @typescript-eslint/parser to extract information from TypeScript code and generate input fields accordingly. This would help to document and streamline the process of testing and debugging code, as well as one more motivation to use this as a widget in other sites!

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions