survey-vue-ui doesn't work with Typescript: no declaration for type Survey
See original GitHub issueAre 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)?
- Create a blank project
- Follow this guide https://surveyjs.io/Documentation/Library?id=get-started-vue
- Use Typescript components by adding
lang="ts"
to the<script>
tag in the Vue SFC - The IDE or Typescript compiler reports the problem importing the
Survey
component fromsurvey-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:
- Created a year ago
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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
@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
Thank you, Andrew