Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS7016 Could not find a declaration file for module surveyjs-wigets #30

Open
zenithA opened this issue Jul 16, 2019 · 3 comments
Open
Labels

Comments

@zenithA
Copy link

zenithA commented Jul 16, 2019

After installing the library, the import is not possible becuase the missing declaration file (.d.ts).
I have attempted to create one in @types, but might happen that it is still wrongly declared, as for instance elements of type "datepicker" are still not visible
Questions:

  1. Is it correct to create a custom d.ts file for the library or there is another better option?
  2. If it is, what should this file contain in order to be able to use elements of type "datepicker" (the others do not matter, so declaration for any other type is not needed) ?
@tsv2013
Copy link
Member

tsv2013 commented Jul 16, 2019

This sample angular-cli repo also uses surveyjs-widgets package and it builds and runs ok for me.
We're using surveyjs-widgets via the following code:

import * as widgets from 'surveyjs-widgets';

Please check this file - https://github.com/surveyjs/surveyjs_angular_cli/blob/master/src/app/survey.component.ts

If you are still experiencing the issue please provide us with a steps to reproduce the issue.

According to the second question - surveyjs-widgets are using 3rd party JavaScrip libraries and probably some of them don't have typings as well. And this quesion should be asked in the corresponding repository, e.g. here for jQuery datepicker - https://github.com/jquery/jquery-ui

@zenithA
Copy link
Author

zenithA commented Jul 19, 2019

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

@pj-alvarado10
Copy link

It is a difficult problem, a fast solution is create the d.ts file in @types like you do it, but we can declare the next module to allow any types:

declare module 'surveyjs-widgets' {
    var _a: any;
    export = _a;
}

about the datepicker, I don't know yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants