Skip to content

Upgrade to Vue3 with Typescript #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
"extends": [
"plugin:vue/essential",
"plugin:prettier/recommended",
"eslint:recommended"
"eslint:recommended",
"@vue/typescript"
],
"rules": {
"prettier/prettier": "error",
"no-console": "warn"
},
"parserOptions": {
"parser": "babel-eslint"
"parser": "@typescript-eslint/parser"
},
"overrides": [
{
Expand All @@ -26,4 +27,4 @@
}
}
]
}
}
22 changes: 12 additions & 10 deletions dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
{{ slotProps.model.name }} <span class="muted">#{{ slotProps.model.id }}</span>
</span>
</template>
<template v-slot:addTreeNodeIcon="slotProps">
<template v-slot:addTreeNodeIcon>
<span class="icon">📂</span>
</template>
<template v-slot:addLeafNodeIcon="slotProps">
<template v-slot:addLeafNodeIcon>
<span class="icon">+</span>
</template>
<template v-slot:editNodeIcon="slotProps">
<template v-slot:editNodeIcon>
<span class="icon">📃</span>
</template>
<template v-slot:delNodeIcon="slotProps">
<template v-slot:delNodeIcon>
<span class="icon">✂️</span>
</template>
<template v-slot:leafNodeIcon="slotProps">
<template v-slot:leafNodeIcon>
<span class="icon">🍃</span>
</template>
<template v-slot:treeNodeIcon="slotProps">
Expand All @@ -50,9 +50,11 @@
</pre>
</div>
</template>
<script>
<script lang="ts">
import { defineComponent } from 'vue'
import { VueTreeList, Tree, TreeNode } from '../src'
export default {

export default defineComponent({
components: {
VueTreeList
},
Expand Down Expand Up @@ -137,8 +139,8 @@ export default {

getNewTree() {
var vm = this
function _dfs(oldNode) {
var newNode = {}
function _dfs(oldNode: TreeNode) {
var newNode = {} as TreeNode

for (var k in oldNode) {
if (k !== 'children' && k !== 'parent') {
Expand All @@ -158,7 +160,7 @@ export default {
vm.newTree = _dfs(vm.data)
}
}
}
})
</script>
<style lang="less" rel="stylesheet/less">
.vtl {
Expand Down
4 changes: 1 addition & 3 deletions dev/index.js → dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
import Vue from 'vue'
import App from './App.vue'

new Vue({
render: h => h(App)
}).$mount('#app')
Vue.createApp(App).mount('#app')
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
preset: '@vue/cli-plugin-unit-jest',
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
snapshotSerializers: ['jest-serializer-vue'],
collectCoverageFrom: ['src/**/*.{js,vue}'],
coveragePathIgnorePatterns: ['src/index.js']
Expand Down
Loading