K.Walentkowski
K.Walentkowski

Reputation: 26

Validate.js, how to override private method in typescript module

I'd like to use Validate.js plugin in my Typescript project. The problem is that Validate.js has method

collectFormValues: function (form, options) 

with hardcoded selector for input fields and it is "name" attribute. I need to use data attr for some reasons.

index.d.ts

file contains "wrapper" interface which defines only 2 public methods so in typescript I don't have any possibility to access "collectFromValues". Any ideas?

Upvotes: 0

Views: 780

Answers (1)

jcalz
jcalz

Reputation: 328618

It sounds like it isn't exactly a "private" method, since it's listed in the validate.js documentation. It is meant to be public, but for some reason the type definition at DefinitelyTyped hasn't exposed a signature for it? I'd say your options, in increasing order of scope, are:

  • Use declaration merging techniques to add the missing declaration(s) in your own code without messing with the index.d.ts file.

  • Modify your local copy of index.d.ts to add the missing declaration(s).

  • Contribute the improved declaration file upstream so that it can be used by everyone.

Hope that helps; good luck.

Upvotes: 1

Related Questions