alexlurvey / form-compiler

Code generate react hooks from a TypeScript file to manage your forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

form-compiler

Status: WIP

Main Idea is to take an input TypeScript file and build out a directory structure that matches the main Form interface and generate file for managing the form.

Currently generates state management files based on rstream and a file of React hooks.

Running

yarn build path/to/FormInterface.ts --interface MainInterfaceName --out-dir path/to/build/dir

  • --interface defaults to 'Form'
  • --out-dir defaults to 'build'

To build the sample app with the test interface:

cd test-app && yarn install && cd ..
yarn dev
cd test-app
yarn start

Caveats

  • Not all TypeScript syntax is supported. Look at ITestForm.ts for what is supported. Any combination of the following should work:
    • Primitives, tuples, and arrays of primitives.
    • Nested interfaces.
    • Arrays of interfaces.

About

Code generate react hooks from a TypeScript file to manage your forms


Languages

Language:TypeScript 97.8%Language:JavaScript 1.2%Language:HTML 1.0%