Skip to content

Commit b7495ea

Browse files
committed
added typescript suppoer to vue 2
1 parent d8673d5 commit b7495ea

File tree

9 files changed

+144
-2284
lines changed

9 files changed

+144
-2284
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
!docs/.vitepress
22
dist
33
examples
4+
src

.eslintrc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ module.exports = {
55
},
66
extends: [
77
'eslint:recommended',
8-
'plugin:vue/recommended',
9-
'@vue/typescript/recommended'
8+
'plugin:vue/recommended', // Use recommended rules from the plugin
109
],
11-
parserOptions: {
12-
parser: '@typescript-eslint/parser'
13-
},
1410
rules: {
1511
// Customize your rules here
1612
}

package.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,16 @@
2828
"push": "clear && git config core.ignorecase false && branch=\"$(git symbolic-ref -q HEAD)\" || \"dev\" && branch=${branch##refs/heads/} && branch=${branch:-HEAD} && echo Pushing to Branch \"$branch\" && echo Please type your commit message && read msg && clear && git add . && git commit -m \"$msg\" && git push origin \"$branch\""
2929
},
3030
"devDependencies": {
31-
"@rollup/plugin-commonjs": "^24.0.1",
3231
"@rollup/plugin-node-resolve": "^15.0.1",
33-
"@vue/compiler-sfc": "^3.2.47",
34-
"@vue/eslint-config-typescript": "^11.0.2",
35-
"@vue/test-utils": "^2.2.10",
3632
"eslint": "^8.34.0",
3733
"eslint-plugin-vue": "^9.9.0",
38-
"jest": "^29.4.2",
39-
"lint-staged": "^13.1.1",
34+
"lint-staged": "^13.1.2",
4035
"rollup": "^2.6.1",
41-
"rollup-plugin-commonjs": "^10.1.0",
42-
"rollup-plugin-dts": "^5.1.1",
36+
"rollup-plugin-dts": "^5.1.0",
4337
"rollup-plugin-filesize": "^9.1.2",
44-
"rollup-plugin-node-resolve": "^5.2.0",
4538
"rollup-plugin-typescript2": "^0.34.1",
46-
"rollup-plugin-vue": "^6.0.0",
4739
"typescript": "^4.9.5",
48-
"vue": "2.6.0"
40+
"vue": "^2.6.0"
4941
},
5042
"bugs": {
5143
"url": "https://github.com/coders-tm/vue-number-format/issues"

rollup.config.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import vue from 'rollup-plugin-vue'
2-
import typescript from 'rollup-plugin-typescript2'
3-
import commonjs from 'rollup-plugin-commonjs'
4-
import resolve from 'rollup-plugin-node-resolve'
5-
import dts from 'rollup-plugin-dts'
6-
import filesize from 'rollup-plugin-filesize'
1+
import typescript from 'rollup-plugin-typescript2';
2+
import filesize from 'rollup-plugin-filesize';
3+
import resolve from '@rollup/plugin-node-resolve';
4+
import dts from 'rollup-plugin-dts';
75
import pkg from './package.json'
86

97
const banner = `/**
@@ -12,21 +10,20 @@ const banner = `/**
1210
* @license ${pkg.license}
1311
*/`
1412

13+
1514
export default [
1615
{
1716
input: 'src/index.ts',
1817
output: [
1918
{
20-
compact: true,
2119
file: pkg.main,
2220
format: 'cjs',
2321
exports: 'named',
24-
name: 'VueNumberFormat',
2522
banner
2623
},
2724
{
2825
file: pkg.module,
29-
format: 'esm',
26+
format: 'es',
3027
exports: 'named',
3128
banner
3229
}
@@ -40,15 +37,13 @@ export default [
4037
}
4138
}),
4239
resolve(),
43-
commonjs(),
44-
vue(),
4540
filesize()
4641
],
4742
external: ['vue']
4843
},
4944
{
50-
input: './.temp/types/index.d.ts',
45+
input: './.temp/types/src/index.d.ts',
5146
output: [{ file: 'dist/index.d.ts', format: 'es' }],
5247
plugins: [dts()]
5348
}
54-
]
49+
];

src/component.vue renamed to src/component.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
<template>
2-
<input
3-
v-number="config"
4-
type="text"
5-
autocomplete="off"
6-
:value="maskedValue"
7-
class="v-number"
8-
@change="change"
9-
@input="input"
10-
@blur="(evt) => $emit('blur', evt)"
11-
@focus="(evt) => $emit('focus', evt)"
12-
>
13-
</template>
141

15-
<script lang="ts">
162
import Vue from 'vue';
173
import directive from './directive'
184
import { cloneDeep, CustomInputEvent, Input } from './core'
@@ -122,6 +108,16 @@ export default Vue.extend({
122108
change() {
123109
this.$emit('change', this.emittedValue)
124110
}
125-
}
126-
});
127-
</script>
111+
},
112+
template: `<input
113+
v-number="config"
114+
type="text"
115+
autocomplete="off"
116+
:value="maskedValue"
117+
class="v-number"
118+
@change="change"
119+
@input="input"
120+
@blur="(evt) => $emit('blur', evt)"
121+
@focus="(evt) => $emit('focus', evt)"
122+
>`
123+
})

src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import component from './component.vue'
1+
import component from './component'
22
import directive from './directive'
33
import options, { Options as Config } from './options'
44
import NumberFormat from './number-format'
55

66
export { component, directive, options, NumberFormat }
77

8-
function install(app: any, config?: Config) {
9-
if (config) {
10-
Object.assign(options, config)
8+
export default {
9+
install(app: any, config?: Config) {
10+
if (config) {
11+
Object.assign(options, config)
12+
}
13+
app.directive('number', directive)
14+
app.component('VueNumber', component)
1115
}
12-
app.directive('number', directive)
13-
app.component('VueNumber', component)
1416
}
15-
16-
export default install

src/shims-vue.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

tsconfig.json

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,17 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
4-
"module": "es2015",
5-
"strict": true,
6-
"jsx": "preserve",
7-
"importHelpers": true,
8-
"moduleResolution": "node",
3+
"target": "ES2018",
4+
"module": "ESNext",
5+
"lib": ["ESNext", "DOM"],
6+
"moduleResolution": "Node",
97
"esModuleInterop": true,
10-
"allowSyntheticDefaultImports": true,
11-
"sourceMap": true,
12-
"baseUrl": ".",
13-
"types": [
14-
"jest",
15-
"node"
16-
],
17-
"paths": {
18-
"@/*": [
19-
"src/*"
20-
]
21-
},
22-
"lib": [
23-
"esnext",
24-
"dom",
25-
"dom.iterable",
26-
"scripthost"
27-
]
28-
},
29-
"include": [
30-
"src/**/*.ts",
31-
"src/**/*.tsx",
32-
"src/**/*.vue",
33-
"tests/**/*.ts",
34-
"tests/**/*.d.ts",
35-
"tests/**/*.tsx"
36-
],
37-
"exclude": [
38-
"node_modules"
39-
]
8+
"strict": true,
9+
"strictNullChecks": true,
10+
"strictFunctionTypes": true,
11+
"resolveJsonModule": true,
12+
"rootDir": ".",
13+
"skipLibCheck": true,
14+
"noUnusedLocals": true,
15+
"baseUrl": "."
16+
}
4017
}

0 commit comments

Comments
 (0)