Skip to content

Commit 26a8fee

Browse files
committed
chore: add tsd tests for typings
This adds a new Ci task to check that the typings are as expected. It uses `tsd` (as done on `vue-next`), and adds a basic test in `test-dts`for the wrapper inference.
1 parent cf6c284 commit 26a8fee

File tree

4 files changed

+853
-14
lines changed

4 files changed

+853
-14
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ jobs:
3030
- run: yarn build
3131
env:
3232
CI: true
33+
- run: yarn tsd

package.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"module": "dist/vue-test-utils.esm-bundler.js",
1010
"files": [
1111
"dist",
12-
"README.md"
12+
"README.md",
13+
"dist/index.d.ts"
1314
],
1415
"dependencies": {
1516
"lodash": "^4.17.15"
@@ -21,6 +22,7 @@
2122
"@rollup/plugin-node-resolve": "^7.1.3",
2223
"@types/estree": "^0.0.42",
2324
"@types/jest": "^24.9.1",
25+
"@types/node": "12.12.35",
2426
"@types/lodash": "^4.14.149",
2527
"@vue/compiler-sfc": "^3.0.0-alpha.13",
2628
"babel-jest": "^25.2.3",
@@ -33,6 +35,7 @@
3335
"rollup": "^1.31.1",
3436
"rollup-plugin-typescript2": "^0.26.0",
3537
"ts-jest": "^25.0.0",
38+
"tsd": "0.11.0",
3639
"typescript": "^3.7.5",
3740
"vue": "^3.0.0-alpha.13",
3841
"vue-jest": "vuejs/vue-jest#next",
@@ -48,6 +51,7 @@
4851
},
4952
"scripts": {
5053
"test": "yarn jest --runInBand tests",
54+
"tsd": "tsd",
5155
"build": "yarn rollup -c rollup.config.js",
5256
"lint": "prettier -c --parser typescript \"(src|tests)/**/*.ts?(x)\"",
5357
"lint:fix": "yarn lint --write"
@@ -61,5 +65,12 @@
6165
"*.ts": [
6266
"prettier --parser=typescript --write"
6367
]
68+
},
69+
"tsd": {
70+
"directory": "test-dts",
71+
"compilerOptions": {
72+
"strict": false,
73+
"lib": ["esnext", "dom"]
74+
}
6475
}
6576
}

test-dts/index.d-test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expectType } from 'tsd'
2+
import { defineComponent } from 'vue'
3+
import { mount } from '../src'
4+
5+
const App = defineComponent({
6+
props: {
7+
a: String
8+
},
9+
template: ''
10+
})
11+
12+
const wrapper = mount(App)
13+
expectType<any>(wrapper.vm.a) // should be string

0 commit comments

Comments
 (0)