surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.2k stars 809 forks source link

Custom widgets - how to use #1760

Open zenithA opened 5 years ago

zenithA commented 5 years ago

After doing the following steps:

Result:

Question: Is anything extra in particular (besides installing the surveyjs-widgets library also) needed to be done, in order for the types defined in surveyjs-widgets (ex: type="datepicker" ) be also available inside 'elements'?

tsv2013 commented 5 years ago

Here is the demo repository - https://github.com/surveyjs/surveyjs_angular_cli

zenithA commented 5 years ago

The problem is that for an environment configured with the following:

typescript - v3.2.4 survey-angular: 1.0.98 surveyjs-widgets: 1.0.98 jquery: 3.1.1 jquery-ui: 1.12.1 "noImplicitAny": true in tsConfig.json (I can't allow it to be set to false, but even if it is, the widget is still not loaded) => I get a ts compile error: TS7016 Could not find a declaration file for module surveyjs-widgets ( this is caused by the fact that the library is missing the d.ts file)

If setting noimplicitAny=false, the compile error disappears, but the datepicker element from surveyjs-widgets is not loaded and the following error is returned: JsonIncorrectTypeError: The property type is incorrect in the object. Please take a look at property: 'elements'. The following types are available: 'matrixdropdownbase', 'matrixdropdown', 'matrixdynamic', 'matrix', ...", etc

I have also tried creating a surveyjs-widgets.d.ts file where to declare the module, where I have included the following: declare module 'surveyjs-widgets' { export function jqueryuidatepicker(survey: any): any; } But also, even if the ts compile error disappears, the datepicker is not loaded and the error JsonIncorrectTypeError is still shown