Open eviltwin opened 3 years ago
Any progress on this issue?
would also benefit from this fix :)
are there plans to publish/re-publish 1.3.2 with typing updates for typescript support?
While we wait for a publish, you can add your own typings in a .d.ts
file like so. Not ideal, but does the job.
import { Decorator } from 'final-form'
declare module 'final-form-calculate' {
interface FFUpdatesByName<TFormValues> {
[FieldName: string]: (value: any, allValues?: TFormValues, prevValues?: TFormValues) => any
}
type FFUpdatesForAll<TFormValues = object> = (
value: any,
field: string,
allValues?: TFormValues,
prevValues?: TFormValues,
) => { [FieldName: string]: any }
type FFUpdates<TFormValues> = FFUpdatesByName<TFormValues> | FFUpdatesForAll<TFormValues>
interface FFCalculation<TFormValues> {
field: FieldPattern
updates: FFUpdates<TFormValues>
isEqual?: (a: any, b: any) => boolean
}
export default function createDecorator<TFormValues = object>(
...calculations: FFCalculation<TFormValues>[]
): Decorator<TFormValues>
}
Are you submitting a bug report or a feature request?
bug report/feature request/feature missing that shouldn't be missing?
What is the current behavior?
TypeScript types for
createDecorator
in v1.3.2 are missing theFormValues
generic argument introduced by #39 . I can confirm that they're present when downloading the source bundle from the release on github, but downloading the package bundle from NPM shows them to be missing. The tag in github is correct, so I'm not sure how NPM didn't pick them up...This is a frustrating issue right now, since the typings of
react-final-form
reject the unparameterised decorator's types as being incompatible with the parameterisedForm
's types, so we can't just use the typings as they stand (without suppressing the error).What is the expected behavior?
The types introduced in #39 should have been in v1.3.2, as noted in the PR and the release notes.
At this point, I think the only path forwards is to tag a new release v1.3.3 that actually includes the types...
Sandbox Link
https://codesandbox.io/s/bold-bogdan-j4qh6?file=/src/App.tsx
What's your environment?
final-form-calculate: 1.3.2 final-form: 4.20.1
Other information
You can confirm that the types are not updated in the package published on NPM by grabbing its url like so:
Download the tarball, decompress it and view
pacakge/dist/index.d.ts
line 26, which lacks the generic type parameter:Or by viewing the file on unpkg here: https://unpkg.com/browse/final-form-calculate@1.3.2/dist/index.d.ts