Skip to content

Commit 67e73a0

Browse files
thabarbadosdangreen
authored andcommitted
feat: typescript support (#757)
* chore: add typescript add typescript and change project configs BREAKING CHANGE: add typescript * refactor: rewrite code to typescript * fix: change interface name * feat: remove unused global var * feat: remove old types folder * feat: add eslintignore * feat: add typescript to sandboxes * feat: rewrite stories to typescript * feat: rewrite tests to typescript * feat: fix app exports and props types * feat: add tests for type definitions * fix: fix clean-publish config * fix: fix clean-publish config again * feat: add storybook build check
1 parent 34ce7f9 commit 67e73a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1100
-521
lines changed

.clean-publish

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"withoutPublish": true,
3-
"tempDir": "package"
3+
"tempDir": "package",
4+
"fields": ["tsd"],
5+
"files": ["docs"]
46
}

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/*
2+
node_modules/*

.eslintrc.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
module.exports = {
22
root: true,
33
parserOptions: {
4-
sourceType: 'module',
4+
sourceType: 'module'
55
},
66
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
77
extends: [
88
'standard',
99
'plugin:prettier/recommended',
1010
'plugin:vue/recommended',
1111
'plugin:prettier-vue/recommended',
12+
'plugin:vue/vue3-essential',
13+
'@vue/eslint-config-typescript'
1214
],
1315
// required to lint *.vue files
1416
plugins: ['prettier'],
@@ -19,9 +21,6 @@ module.exports = {
1921
// allow debugger during development
2022
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
2123
'prettier/prettier': 'error',
22-
quotes: [2, 'single', 'avoid-escape'],
23-
},
24-
globals: {
25-
LIB_VERSION: true,
26-
},
27-
};
24+
quotes: [2, 'single', 'avoid-escape']
25+
}
26+
}

.github/workflows/checks.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,44 @@ jobs:
2626
uses: andresz1/size-limit-action@master
2727
with:
2828
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
typings:
30+
runs-on: ubuntu-latest
31+
name: typings
32+
steps:
33+
- name: Checkout the repository
34+
uses: actions/checkout@v2
35+
- name: Install pnpm
36+
uses: pnpm/[email protected]
37+
with:
38+
version: 6
39+
- name: Install Node.js
40+
uses: actions/setup-node@v2
41+
with:
42+
node-version: 16
43+
cache: 'pnpm'
44+
- name: Install dependencies
45+
run: pnpm install
46+
- name: Prebuild
47+
run: pnpm build
48+
- name: Check typings
49+
if: success()
50+
run: pnpm test:typings
51+
storybook:
52+
runs-on: ubuntu-latest
53+
name: storybook
54+
steps:
55+
- name: Checkout the repository
56+
uses: actions/checkout@v2
57+
- name: Install pnpm
58+
uses: pnpm/[email protected]
59+
with:
60+
version: 6
61+
- name: Install Node.js
62+
uses: actions/setup-node@v2
63+
with:
64+
node-version: 16
65+
cache: 'pnpm'
66+
- name: Install dependencies
67+
run: pnpm install
68+
- name: Check storybook
69+
run: pnpm build:storybook

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
webpackFinal: async config => {
88
config.resolve.alias['vue-chartjs'] = path.resolve(
99
__dirname,
10-
'../src/index.js'
10+
'../src/index.ts'
1111
)
1212
return config
1313
}

package.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"Charts"
3838
],
3939
"sideEffects": false,
40-
"main": "./src/index.js",
41-
"typings": "./dist/index.d.ts",
40+
"main": "./src/index.ts",
41+
"types": "./dist/index.d.ts",
4242
"publishConfig": {
4343
"main": "./dist/index.cjs",
4444
"module": "./dist/index.js",
@@ -47,17 +47,20 @@
4747
"scripts": {
4848
"prepublishOnly": "pnpm test && pnpm build && del ./package && clean-publish",
4949
"postpublish": "del ./package",
50-
"build": "rollup -c",
50+
"emitDeclarations": "tsc --emitDeclarationOnly",
51+
"build": "rollup -c & pnpm emitDeclarations",
5152
"unit": "jest -c jest.config.json",
5253
"test": "pnpm lint && pnpm unit",
5354
"test:size": "size-limit",
54-
"lint": "eslint --ext .js,.vue src test",
55+
"test:typings": "tsd",
56+
"lint": "eslint 'src/**/*.ts'",
5557
"format": "prettier --write src test",
5658
"release": "standard-version",
5759
"docs:dev": "vuepress dev docs",
5860
"docs:build": "vuepress build docs",
5961
"commit": "cz",
60-
"start:storybook": "start-storybook -p 6006"
62+
"start:storybook": "start-storybook -p 6006",
63+
"build:storybook": "del ./storybook-static; NODE_ENV=production build-storybook"
6164
},
6265
"peerDependencies": {
6366
"chart.js": "^3.7.0"
@@ -75,7 +78,9 @@
7578
"@swc/core": "^1.2.120",
7679
"@swc/helpers": "^0.3.2",
7780
"@swc/jest": "^0.2.15",
81+
"@types/jest": "^27.4.1",
7882
"@vitejs/plugin-vue": "^2.2.2",
83+
"@vue/eslint-config-typescript": "^10.0.0",
7984
"@vue/test-utils": "^2.0.0-rc.17",
8085
"@vue/vue3-jest": "^27.0.0-alpha.4",
8186
"babel-jest": "^27.4.5",
@@ -106,9 +111,14 @@
106111
"simple-git-hooks": "^2.7.0",
107112
"size-limit": "^7.0.8",
108113
"standard-version": "^9.3.2",
114+
"tsd": "^0.19.1",
115+
"typescript": "^4.6.2",
109116
"vite": "^2.8.6",
110117
"vue": "^3.2.31",
111118
"vue-loader": "^17.0.0",
112119
"vuepress": "^0.14.4"
120+
},
121+
"tsd": {
122+
"directory": "./test"
113123
}
114124
}

0 commit comments

Comments
 (0)