question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

survey-vue-ui doesn't work with Typescript: no declaration for type Survey

See original GitHub issue

Are you requesting a feature, reporting a bug or asking a question?

Reporting a possible bug with survey-vue-ui and the VueJS getting started project.

This report is vaguely similar to #4036, albeit it can’t be patched by using a fully qualified type.

What is the current behavior?

This code taken from the example:


<template>
  <Survey :survey="survey" />
</template>

<script>
import 'survey-core/modern.min.css';
import { StylesManager, Model } from 'survey-core';
import { Survey } from 'survey-vue-ui'; 
// NOTE: The text in the get-started-vue example is missing the closing apostrophe. I added it for the sake of a mcve.
// The documentation refers to GitHub as GutHub. Don't forget to feed your developers :)

StylesManager.applyTheme("modern");

const surveyJson = {
  elements: [{
    name: "FirstName",
    title: "Enter your first name:",
    type: "text"
  }, {
    name: "LastName",
    title: "Enter your last name:",
    type: "text"
  }]
};

export default {
  name: 'MyFirstSurvey',
  components: {
    Survey
  },
  data() {
    const survey = new Model(surveyJson);
    return {
      survey
    }
  },
}
</script>

Produces the following error:

TS2305: Module '"node_modules/survey-vue-ui/survey-vue-ui"' has no exported member 'Survey'.

I’ve installed packages as suggested by the documentation, i.e.:

npm install survey-vue-ui --save

What is the expected behavior?

  • The code from the get-started-vue project works with surveyjs and Typescript.
  • The documentation is updated to reflect changes in the survey-core API 1.19.28

How would you reproduce the current behavior (if this is a bug)?

  1. Create a blank project
  2. Follow this guide https://surveyjs.io/Documentation/Library?id=get-started-vue
  3. Use Typescript components by adding lang="ts" to the <script> tag in the Vue SFC
  4. The IDE or Typescript compiler reports the problem importing the Survey component from survey-vue-ui

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

import { Model } from 'survey-core';
import { SurveyModel } from 'survey-vue-ui';

Specify your

  • browser: N/A.
  • browser version: N/A.
  • typescript version: 4.1.3
  • surveyjs platform (angular or react or jquery or knockout or vue): vue
  • surveyjs version: 1.9.28
  • survey-vue-ui version: 1.9.28

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
andrewtelnovcommented, May 16, 2022

@metaturso @RomanTsukanov I have fixed our d.ts generator. Indeed it did not generate vue d.ts correctly after we change our webpack entries for vue, it stopped work. It will be fine in v1.9.30.

Thank you, Andrew

1reaction
andrewtelnovcommented, May 26, 2022

@metaturso I have installed “npm i survey-vue-ui” and in file “survey-vue-ui.d.ts” I have the following class on one line: 341

export declare class Survey extends BaseVue {
  constructor();
  survey: SurveyModel;
  model: SurveyModel;
  processedCompletedHtmlValue: string;
  updater: number;
  get pageId(): string;
  get navId(): string;
  protected getModel(): Base;
  get vueSurvey(): SurveyModel;
  onPropertyChanged(value: string, oldValue: string): void;
  forceUpdate(): void;
  protected onMounted(): void;
  beforeDestroy(): void;
  get hasTitle(): boolean;
  get hasCompletedPage(): boolean;
  get css(): any;
  getProcessedCompletedHtml(): string;
  getCompletedStateClasses(): any;
  start(): void;
  doTrySaveAgain(): void;
}

Thank you, Andrew

Read more comments on GitHub >

github_iconTop Results From Across the Web

1.9.14 no longer builds with typescript, "missing Survey.Model"
It looks like types have been changed, and no longer correspond to the documentation. What is the current behavior?
Read more >
Could not find a declaration file for module 'module-name ...
When a module is not yours - try to install types from @types : ... foo.d.ts declare module 'foo' { export function getRandomNumber():...
Read more >
How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type · Try `npm...
Read more >
Documentation - Do's and Don'ts - TypeScript
Don't ever use the types Number , String , Boolean , Symbol , or Object These types ... Don't ever have a generic...
Read more >
TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. ... development experience by catching errors and providing fixes before you even run your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found