feature: TypeScript

This commit is contained in:
Cindy Chang
2024-07-03 12:08:16 +08:00
parent ba4f70213d
commit 1991b4df63
4 changed files with 32 additions and 3 deletions

7
shims-vue.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
// shims-vue.d.ts
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}

View File

@@ -4,6 +4,6 @@
<style scoped></style> <style scoped></style>
<script setup> <script setup lang="ts">
import { RouterView } from "vue-router"; import { RouterView } from "vue-router";
</script> </script>

View File

@@ -10,7 +10,7 @@
</main> </main>
</template> </template>
<script> <script lang='ts'>
import { onBeforeMount, } from 'vue'; import { onBeforeMount, } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { storeToRefs, mapActions, mapState, } from 'pinia'; import { storeToRefs, mapActions, mapState, } from 'pinia';
@@ -41,7 +41,7 @@ export default {
const setHighlightedNavItemOnLanding = () => { const setHighlightedNavItemOnLanding = () => {
const currentPath = router.currentRoute.value.path; const currentPath = router.currentRoute.value.path;
const pathSegments = currentPath.split('/').filter(segment => segment !== ''); const pathSegments: string[] = currentPath.split('/').filter(segment => segment !== '');
if(pathSegments.length === 1) { if(pathSegments.length === 1) {
if(pathSegments[0] === 'files') { if(pathSegments[0] === 'files') {
pageAdminStore.setActivePage('ALL'); pageAdminStore.setActivePage('ALL');

22
tsconfig.json Normal file
View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": ["webpack-env", "jest"],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom"],
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
"exclude": ["node_modules"]
}