Skip to content

Commit ff19b36

Browse files
committed
started more typescript to begin with
1 parent 112da10 commit ff19b36

File tree

10 files changed

+77
-63
lines changed

10 files changed

+77
-63
lines changed

.eslintrc.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ module.exports = {
88
'vue/no-deprecated-slot-attribute': 'off',
99
},
1010

11+
"parser": "vue-eslint-parser",
1112
parserOptions: {
1213
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
13-
parser: '@babel/eslint-parser',
14+
parser: { //attempt to speed up runtime using TS when coding
15+
"ts":'@typescript-eslint/parser',
16+
"<template>": "espree"
17+
},
1418
requireConfigFile: false,
1519
sourceType: 'module', // Allows for the use of imports
1620
},

src/components/nav-buttons/ExportMenu.vue

+23-21
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ Description:
1818
</q-btn>
1919
</template>
2020

21-
<script>
21+
<script lang="ts">
22+
import * as types from "types";
2223
import { useExportComponent } from "../composables/useExportComponent.js";
2324
import { mapState } from "vuex";
25+
import { defineComponent } from "vue";
2426
const { fs, ipcRenderer } = window;
2527

2628
import writeNested from "../../mixins/writeNested";
2729

2830

29-
export default {
31+
export default defineComponent({
3032
name: "ExportProjectComponent",
3133
mixins: [writeNested],
3234
methods: {
@@ -40,11 +42,11 @@ export default {
4042
message: "Choose location to save folder in",
4143
nameFieldLabel: "Application Name",
4244
})
43-
.then((result) => {
45+
.then((result:any) => {
4446
this.exportFile(result.filePath)
4547
alert('Successfully Exported')
4648
})
47-
.catch((err) => console.log(err));
49+
.catch((err:string) => console.log(err));
4850
},
4951
exportProject: function () {
5052

@@ -56,7 +58,7 @@ export default {
5658
* invokes: createRouterImports(this.componentMap['App'].children),
5759
* createExport(this.componentMap['App'].children)
5860
* */
59-
createRouter(location) {
61+
createRouter(location:string) {
6062
if (this.exportAsTypescript === "on") {
6163
fs.writeFileSync(
6264
path.join(location, "src", "router", "index.ts"),
@@ -75,8 +77,8 @@ export default {
7577
* @description import routed components from the /views/ dir
7678
* @argument: this.componentMap['App'].children
7779
*/
78-
createRouterImports(routes) {
79-
let str = "import { createRouter, createWebHistory } from 'vue-router';\n";
80+
createRouterImports(routes):string {
81+
let str:string = "import { createRouter, createWebHistory } from 'vue-router';\n";
8082
for(let view in routes) {
8183
str += `import ${view} from '../views/${view}.vue';\n`;
8284
}
@@ -85,8 +87,8 @@ export default {
8587
/**
8688
* @description creates the `export default` code in <script>
8789
*/
88-
createExport(routes) {
89-
let str = "export default createRouter({\n\thistory: createWebHistory(import.meta.env.BASE_URL),\n\troutes: [\n";
90+
createExport(routes):string {
91+
let str:string = "export default createRouter({\n\thistory: createWebHistory(import.meta.env.BASE_URL),\n\troutes: [\n";
9092
for(let view in routes) {
9193
// HomeView route is initialized to "localhost:3000/" url
9294
if (view === "HomeView") {
@@ -105,7 +107,7 @@ export default {
105107
* @description: creates component code <template>, <script>, <style>
106108
* invokes writeTemplate, writeScript, writeStyle
107109
*/
108-
createComponentCode(componentLocation, componentName, children, routes) {
110+
createComponentCode(componentLocation, componentName, children, routes):void {
109111
if (componentName === "App") {
110112
fs.writeFileSync(
111113
componentLocation + ".vue",
@@ -123,14 +125,14 @@ export default {
123125
}
124126
},
125127
// creates assets folder
126-
createAssetFile(targetLocation, assetLocation) {
128+
createAssetFile(targetLocation:string, assetLocation):void {
127129
let saved = remote.nativeImage.createFromPath(assetLocation);
128130
let urlData = saved.toPNG();
129131
fs.writeFileSync(targetLocation + ".png", urlData);
130132
},
131-
writeTemplateTag(componentName) {
132-
// create reference object
133-
const htmlElementMap = {
133+
writeTemplateTag(componentName:string):string {
134+
// create reference object - replace later
135+
const htmlElementMap:types.HtmlElementMap = {
134136
div: ["<div", "</div>"],
135137
button: ["<button", "</button>"],
136138
form: ["<form", "</form>"],
@@ -268,7 +270,7 @@ export default {
268270
/**
269271
* @description imports child components into <script>
270272
*/
271-
writeScript(componentName, children) {
273+
writeScript(componentName: string, children) {
272274
// add import mapstate and mapactions if they exist
273275
const currentComponent = this.componentMap[componentName];
274276
const routes = Object.keys(this.routes);
@@ -399,7 +401,7 @@ export default {
399401
*/
400402
/* UPDATE THIS TO GRAB INFORMATION FROM this.componentMap NOT this.routes*/
401403
/* this.componentMap does not have x-y positioning stored */
402-
writeStyle(componentName) {
404+
writeStyle(componentName:string) {
403405
let htmlArray = this.componentMap[componentName].htmlList;
404406
let styleString = "";
405407
console.log(componentName);
@@ -510,7 +512,7 @@ export default {
510512
}
511513
},
512514
createESLintRC(location) {
513-
let str;
515+
let str:string;
514516
if (this.exportAsTypescript === "on") {
515517
str += `require("@rushstack/eslint-patch/modern-module-resolution");\n\n`;
516518
}
@@ -548,14 +550,14 @@ export default {
548550
},
549551
createTSDeclaration(location) {
550552
if (this.exportAsTypescript === "on") {
551-
let str = `/// <reference types="vite/client" />`;
553+
let str:string = `/// <reference types="vite/client" />`;
552554
fs.writeFileSync(path.join(location, "env.d.ts"), str);
553555
} else {
554556
return;
555557
}
556558
},
557559
createStore(location) {
558-
let str = `import { createStore } from 'vuex';\n`;
560+
let str:string = `import { createStore } from 'vuex';\n`;
559561
str += `\nconst store = createStore({`;
560562
str += `\n\tstate () {`;
561563
str += `\n\t\treturn {`;
@@ -600,7 +602,7 @@ export default {
600602
},
601603
// create package.json file
602604
createPackage(location) {
603-
let str = `{`;
605+
let str:string = `{`;
604606
str += `\n\t"name": "My-OverVue-Project",`;
605607
str += `\n\t"version": "0.0.0",`;
606608
str += `\n\t"scripts": {`;
@@ -715,7 +717,7 @@ export default {
715717
"containerH"
716718
]),
717719
},
718-
};
720+
});
719721
</script>
720722

721723
<style scoped>

src/components/nav-buttons/GridDensity.vue

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<!--
2+
Description:
3+
Displays Grid Density Buttons
4+
Functionality includes: drop down menu for both height and width to increase or decrease grid lines by a set amount
5+
-->
16
<template>
27
<div id="gridDensity">
38
<q-btn-dropdown class="q-btn" color="purple" label="Width">

src/components/nav-buttons/ImportMenu.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@ Description:
1717
</q-btn>
1818
</template>
1919

20-
<script>
20+
<script lang="ts">
2121
import { mapActions } from "vuex";
2222
import ImportComponent from "../left-sidebar/ComponentTab/ImportComponent.vue"
2323
const Mousetrap = require("mousetrap");
2424
const { fs, ipcRenderer } = window;
25+
import { defineComponent } from "vue";
2526

26-
export default {
27+
export default defineComponent({
2728
name: "ImportMenu",
2829
components: {
2930
ImportComponent
3031
},
3132
methods: {
3233
...mapActions(["openProject"]),
3334
// opens project
34-
openJSONFile(data) {
35+
openJSONFile(data:string) {
3536
if (data === undefined) return;
3637
const jsonFile = JSON.parse(fs.readFileSync(data[0], "utf8"));
3738
this.openProject(jsonFile);
@@ -47,8 +48,8 @@ export default {
4748
},
4849
],
4950
})
50-
.then((res) => this.openJSONFile(res.filePaths))
51-
.catch((err) => console.log(err));
51+
.then((res:any) => this.openJSONFile(res.filePaths))
52+
.catch((err:string) => console.log(err));
5253
},
5354

5455
openProjectJSON() {
@@ -61,7 +62,7 @@ export default {
6162
this.openProjectJSON();
6263
});
6364
},
64-
};
65+
});
6566
</script>
6667

6768
<style scoped>

src/components/right-sidebar/GetStarted.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
</q-card>
3434
</template>
3535

36-
<script>
36+
<script lang="ts">
3737
import BasicFunctions from './tutorial/BasicFunctions.vue'
3838
import AdvancedFunctions from './tutorial/AdvancedFunctions.vue'
3939
import Landing from './tutorial/Landing.vue'
4040
import NewVersionInfo from './tutorial/NewVersionInfo.vue'
41+
import { defineComponent } from "vue";
4142
42-
export default {
43+
export default defineComponent({
4344
components: {
4445
BasicFunctions,
4546
AdvancedFunctions,
@@ -48,11 +49,10 @@ export default {
4849
},
4950
data() {
5051
return {
51-
tutorialPage: 'landing'
52+
tutorialPage: 'landing' as string,
5253
}
5354
}
54-
}
55-
55+
});
5656
</script>
5757

5858
<style lang="scss" scoped>

src/layouts/MyLayout.vue

+11-22
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Description:
138138
</q-layout>
139139
</template>
140140

141-
<script>
141+
<script lang="ts">
142142
// HomeSideDropDown contains RouteDisplay, VuexForm and Edit but we'll be separating these components across different tabs
143143
import RightSidebar from "../components/right-sidebar/RightSidebar.vue";
144144
import ExportMenu from "../components/nav-buttons/ExportMenu.vue";
@@ -149,19 +149,19 @@ import SlackLoginWindow from "../components/slack_login/SlackLoginWindow.vue";
149149
import ComponentTab from "../components/left-sidebar/ComponentTab/ComponentTab.vue";
150150
import StoreTab from "../components/left-sidebar/StoreTab/StoreTab.vue";
151151
import { mapState, mapActions } from "vuex";
152+
import { defineComponent } from "vue";
152153

153-
154-
export default {
154+
export default defineComponent({
155155
// Passed down from App.vue
156156
props: ["doneAction", "undoneAction", "undoTrigger", "redoTrigger"],
157157
data() {
158158
return {
159-
tab: "component",
160-
left: true,
161-
right: true,
162-
dashWidth: 950,
163-
originalWidth: 400,
164-
originalLeft: 400,
159+
tab: "component" as string,
160+
left: true as boolean,
161+
right: true as boolean,
162+
dashWidth: 950 as number,
163+
originalWidth: 400 as number,
164+
originalLeft: 400 as number,
165165
timer: null,
166166
};
167167
},
@@ -174,7 +174,7 @@ export default {
174174
ComponentTab,
175175
StoreTab,
176176
GridDensity
177-
},
177+
},
178178
computed: {
179179
...mapState(["exportAsTypescript"]),
180180
},
@@ -237,14 +237,8 @@ export default {
237237
this.$emit('redo')
238238
}
239239
},
240-
};
240+
});
241241

242-
function check (a){
243-
if(a === true){
244-
return checked
245-
}
246-
return
247-
}
248242
</script>
249243

250244
<style lang="scss">
@@ -262,10 +256,6 @@ function check (a){
262256
margin-right: 95px;
263257
}
264258

265-
// .text-white {
266-
// color: $menutext;
267-
// }
268-
269259
q-btn > i {
270260
color: $menutext;
271261
}
@@ -285,7 +275,6 @@ q-btn > i {
285275
border: 1px solid rgba($primary, .5);
286276
}
287277

288-
// Must change style lang='scss'
289278
.fa-undo,
290279
.fa-redo {
291280
padding: 0 5px;

src/store/state/icons.js renamed to src/store/state/icons.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const icons = {
1+
import { Icons } from "types"
2+
const icons: Icons = {
23
div: 'far fa-square fa-lg',
34
button: 'fas fa-toggle-off fa-lg',
45
form: 'fab fa-wpforms fa-lg',
@@ -20,7 +21,6 @@ const icons = {
2021
h5:['fa-regular fa-5'],
2122
h6:['fa-regular fa-6'],
2223
// element:['fas fa-toggle-on fa-lg']
23-
}
24+
};
2425

25-
26-
export default icons
26+
export default icons;

src/store/state/styleClassMap.js

-4
This file was deleted.

src/store/state/styleClassMap.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//add different style options here like background or font
2+
import { StyleClassMap } from "types"
3+
4+
const styleClassMap:StyleClassMap = {
5+
6+
};
7+
8+
export default styleClassMap;

types.ts

+9
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,13 @@ export type Component = {
9999
id: string,
100100
gridArea: [number, number, number, number],
101101
},
102+
};
103+
104+
export type Icons = {
105+
[type: string]: string | string[];
106+
};
107+
108+
export type StyleClassMap = {
109+
// insert here for style class map when implenting more
110+
102111
};

0 commit comments

Comments
 (0)