-
Notifications
You must be signed in to change notification settings - Fork 136
Add TypeScript definitions for tcomb-form #394
base: master
Are you sure you want to change the base?
Conversation
@RedRoserade this is great, thanks for taking the time to write this definitions |
Why it's still doesn't merged? |
|
||
declare namespace form { | ||
|
||
type PlaceholderOptions = 'auto' | 'none'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type PlaceholderOptions = 'auto' | 'none' | 'labels';
labels
is the default value
Line 848 in 1984d52
auto: 'labels', |
|
||
type PlaceholderOptions = 'auto' | 'none'; | ||
|
||
type ErrorMessage = JSX.Element | ((value: any, path: Path, context: any) => JSX.Element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this type useful? Seems defined but not used
type ErrorMessage = JSX.Element | ((value: any, path: Path, context: any) => JSX.Element); | ||
|
||
type TcombI18NOptions = { | ||
add: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but I think they could be React.ReactNode
s instead of string
s
interface TemplateLocals { | ||
attrs: any; | ||
config: any; | ||
context: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to remove some any
here? What about using object
attrs: object;
config: object;
context: object;
label?: React.ReactNode; | ||
onChange: (value: any) => void; | ||
path: Path; | ||
typeInfo: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on
Line 50 in 1984d52
return { |
typeInfo
could be of type
type TypeInfo = {
type: t.Type<any>,
isMaybe: boolean,
isSubtype: boolean,
innerType: t.Type<any>,
getValidationErrorMessage?: (value: any, path: Path, context: any) => React.Node
}
My bad, there was a pending review which I didn't submit at the time, sorry @RedRoserade |
Can the above change request please be acted on? It would be really helpful to have Typescript definitions enabled. |
This adds TypeScript definitions for tcomb-form, based on the Guide.
A devDependency on
@types/react
was added for theForm
component and the otherComponent
classes.Similar to the type definition for tcomb-validation, gcanti/tcomb-validation#63, this extends the
tcomb
module, addinggetTcombFormFactory
andgetTcombFormOptions
tot.Type<T>
.I am, however, not sure if the type definitions are 100% complete or accurate. I'd appreciate your feedback to improve them.