@@ -116,6 +116,10 @@ export default {
116
116
else imports += " mapActions" ;
117
117
imports += ' } from "vuex"\n ' ;
118
118
}
119
+ // if Typescript toggle is on, import defineComponent
120
+ if (this .exportAsTypescript === " on" ) {
121
+ imports += ' import { defineComponent } from "vue"\n ' ;
122
+ }
119
123
// add imports for children
120
124
children .forEach ((name ) => {
121
125
imports += ` import ${ name} from '@/components/${ name} .vue';\n ` ;
@@ -162,21 +166,27 @@ export default {
162
166
}
163
167
// concat all code within script tags
164
168
// if exportAsTypescript is on, out should be <script lang="ts">
165
- console .log (" export as typescript:" , this .exportAsTypescript );
166
169
let output;
167
170
if (this .exportAsTypescript === ' on' ) {
168
171
output = " \n\n <script lang='ts'>\n " ;
172
+ output += imports + " \n export default defineComponent ({\n name: '" + componentName + " '" ;
169
173
} else {
170
174
output = " \n\n <script>\n " ;
175
+ output += imports + " \n export default {\n name: '" + componentName + " '" ;
171
176
}
172
- output += imports + " \n export default {\n name: '" + componentName + " '" ;
173
177
output += " ,\n components: {\n " ;
174
178
output += childrenComponentNames + " },\n " ;
175
179
output += data;
176
180
output += computed;
177
181
output += methods;
178
182
// eslint-disable-next-line no-useless-escape
179
- output += " };\n <\/ script>" ;
183
+ if (this .exportAsTypescript === ' on' ) {
184
+ output += " });\n <\/ script>" ;
185
+
186
+ } else {
187
+ output += " };\n <\/ script>" ;
188
+ }
189
+
180
190
console .log (' output' , output);
181
191
return output;
182
192
},
0 commit comments