Skip to content

Commit 92c6302

Browse files
committed
Updated project export functionality
- added algorithm to create TS declaration file Co-authored by Bryan Bart <[email protected]>
1 parent bd31cdd commit 92c6302

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/components/file_system_interface/ExportProject.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,16 @@ export default {
415415
str += `\t}\n}`
416416
fs.writeFileSync(path.join(location, ".eslintrc.cjs"), str);
417417
},
418+
createTSConfig(location) {
419+
if (this.exportAsTypescript === "on") {
420+
let str = `{\n\t"extends": "@vue/tsconfig/tsconfig.web.json",\n\t"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],\n\t"compilerOptions": {\n\t\t"baseUrl": ".",\n\t\t"paths": {\n\t\t\t"@/*": ["./src/*"]\n\t\t}\n\t},`;
421+
str += `\t"references": [\n`
422+
str += `\t\t{\n\t\t\t"path": "./tsconfig.vite-config.json"\n\t\t}\n\t]\n}`
423+
fs.writeFileSync(path.join(location, "tsconfig.json"), str);
424+
} else {
425+
return;
426+
}
427+
},
418428
createTSViteConfig(location) {
419429
if (this.exportAsTypescript === "on") {
420430
let str = `{\n\t"extends": "@vue/tsconfig/tsconfig.node.json",\n\t"include": ["vite.config.*"],\n\t"compilerOptions": {\n\t\t"composite": true,\n\t\t"types": ["node", "viteset"]\n\t}\n}`;
@@ -423,12 +433,10 @@ export default {
423433
return;
424434
}
425435
},
426-
createTSConfig(location) {
436+
createTSDeclaration(location) {
427437
if (this.exportAsTypescript === "on") {
428-
let str = `{\n\t"extends": "@vue/tsconfig/tsconfig.web.json",\n\t"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],\n\t"compilerOptions": {\n\t\t"baseUrl": ".",\n\t\t"paths": {\n\t\t\t"@/*": ["./src/*"]\n\t\t}\n\t},`;
429-
str += `\t"references": [\n`
430-
str += `\t\t{\n\t\t\t"path": "./tsconfig.vite-config.json"\n\t\t}\n\t]\n}`
431-
fs.writeFileSync(path.join(location, "tsconfig.json"), str);
438+
let str = `/// <reference types="vite/client" />`;
439+
fs.writeFileSync(path.join(location, "env.d.ts"), str);
432440
} else {
433441
return;
434442
}
@@ -490,6 +498,7 @@ export default {
490498
this.createESLintRC(data);
491499
this.createTSConfig(data);
492500
this.createTSViteConfig(data);
501+
this.createTSDeclaration(data);
493502
this.createPackage(data);
494503
// exports images to the /assets folder
495504
// eslint-disable-next-line no-unused-vars

0 commit comments

Comments
 (0)