surveyjs / custom-widgets

The collection of custom widgets for SurveyJS: Survey Library and Survey Creator :package:
https://surveyjs.io
MIT License
80 stars 78 forks source link

TypeScript definitions. #121

Open CalvinRodo opened 5 years ago

CalvinRodo commented 5 years ago

I'm using the Vue Version and typescript.

My import for surveyjs-widgets is failing due to a like of Typescript defitions.

tsv2013 commented 5 years ago

I guess are you talking about the lack of Typescript defitions? Yes the surveyjs-widgets library is a puge JS library and dosn't have TS definitions.

You can reference the https://github.com/surveyjs/surveyjs_vue_quickstart repo especially the https://github.com/surveyjs/surveyjs_vue_quickstart/blob/master/src/components/SurveyCreator.vue file as a sample hoe to use widgets in VueJS project.

matthewberryman commented 3 years ago

@tsv2013 The example you've linked to here is JavaScript, and the example linked in #127 it is also missing a type definition (I haven't looked at that example in detail, but I am guessing something about the TS version and config means it ignores it), so neither serve as an example of how to work around this problem of missing types for widgets (which I hope are added at some point). The hacky workaround is to add an empty definition file per https://stackoverflow.com/questions/54173833/how-to-allow-modules-that-have-missing-d-ts-type-definition with another alternative simply to create the src/@types/survey-widgets.d.ts file in the repo that is importing survey-widgets, with contents

declare module 'surveyjs-widgets';

and then modern versions of typescript at least should find it automatically, rather than having to specify the location per other solutions in the StackOverflow answer.