Built-In Types
aio-inputs has strong built-in types and properly infer type from your inputs.
The only reason for you to import these types is the benefit of autocompletion when you create your inputs in an external file or pass it as a props to another component. If so, use them types to make things easier.
But if you create your inputs directly in the useInputs() hook, or as external variable, You won't need them. Trust us to properly infer type for you and focus on your logic 💭.
Creation Types
When you create your inputs as an object or an Array.
- Array. CREATE IT
// To type an Array of inputs
import{CreateArrayInputs}from"aio-inputs"
constmyInputs:CreateArrayInputs= [...]
Copied
- Object. CREATE IT
// To type an Object of inputs
import{CreateObjectInputs}from"aio-inputs"
constmyInputs:CreateObjectInputs<'name' | 'age'> ={
name:{...}
age:{...}
},
Copied
Output Types
These types are available for created inputs. It is not for creating inputs. After calling useInputs(), these are possible output types.
- Input. SHOW PROPERTIES
// To type an Input
import{Input}from"aio-inputs"
Copied
- InputProps. They are part of input properties. SHOW PROPERTIES.
// To type an InputProps
import{InputProps}from"aio-inputs"
Copied
- Array
// To type an Array of inputs
import{ArrayInputs}from"aio-inputs"
Copied
- Object
// To type an Object of inputs
import{ObjectInputs}from"aio-inputs"
ObjectInputs<'name' | 'age'>
Copied
❤️ THANK YOU ❤️