Skip to content

Commit ee42325

Browse files
committed
chore: remove tsd
TSD has weird regressions with vue-next 3.0.9, maybe due to TS 4.2. Instead of figthing it, let's adopt what the other Vue project did and replace TSD with a plain `tsc` check. See vuejs/core@97dedeb for example for a similar commit on vue-next
1 parent a3cb7f3 commit ee42325

File tree

9 files changed

+63
-546
lines changed

9 files changed

+63
-546
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"rollup": "^2.44.0",
3636
"rollup-plugin-typescript2": "^0.30.0",
3737
"ts-jest": "25.3.1",
38-
"tsd": "0.14.0",
3938
"typescript": "^4.2.3",
4039
"vitepress": "^0.12.2",
4140
"vue": "3.0.7",
@@ -54,7 +53,7 @@
5453
"scripts": {
5554
"test": "yarn jest --runInBand tests",
5655
"test:build": "yarn jest --runInBand tests -use-build",
57-
"tsd": "tsd",
56+
"tsd": "tsc -p test-dts/tsconfig.tsd.json",
5857
"build": "yarn rollup -c rollup.config.js",
5958
"lint": "prettier -c --parser typescript \"(src|tests)/**/*.ts?(x)\"",
6059
"lint:fix": "yarn lint --write",

test-dts/getComponent.d-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectType } from 'tsd'
1+
import { expectType } from './index'
22
import { defineComponent, ComponentPublicInstance } from 'vue'
33
import { mount } from '../src'
44

test-dts/index.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This directory contains a number of d.ts assertions using tsd:
2+
// https://github.com/SamVerschueren/tsd
3+
// The tests checks type errors and will probably show up red in VSCode, and
4+
// it's intended. We cannot use directives like @ts-ignore or @ts-nocheck since
5+
// that would suppress the errors that should be caught.
6+
7+
export function describe(_name: string, _fn: () => void): void
8+
9+
export function expectType<T>(value: T): void
10+
export function expectError<T>(value: T): void
11+
export function expectAssignable<T, T2 extends T = T>(value: T2): void
12+
13+
export type IsUnion<T, U extends T = T> = (T extends any
14+
? (U extends T ? false : true)
15+
: never) extends false
16+
? false
17+
: true

test-dts/mount.d-test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { expectError, expectType } from 'tsd'
1+
import { expectError, expectType } from './index'
22
import {
33
DefineComponent,
44
defineComponent,
5-
FunctionalComponent,
6-
reactive
5+
FunctionalComponent
76
} from 'vue'
87
import { Options, Vue } from 'vue-class-component'
98
import { mount } from '../src'
@@ -49,8 +48,8 @@ mount(AppWithDefine, {
4948
props: { a: 'Hello', c: 2 }
5049
})
5150

52-
// wrong prop type should not compile
5351
expectError(
52+
// @ts-expect-error wrong prop type should not compile
5453
mount(AppWithDefine, {
5554
props: { a: 2 }
5655
})
@@ -77,9 +76,9 @@ mount(AppWithProps, {
7776
props: { a: 'Hello', b: 2 }
7877
})
7978

80-
// wrong prop type should not compile
8179
expectError(
8280
mount(AppWithProps, {
81+
// @ts-expect-error wrong prop type should not compile
8382
props: { a: 2 }
8483
})
8584
)
@@ -127,7 +126,7 @@ mount(AppWithoutProps, {
127126

128127
// Functional tests
129128

130-
// wrong props
129+
// @ts-expect-error wrong props
131130
expectError((props: { a: 1 }) => {}, {
132131
props: {
133132
a: '222'
@@ -208,6 +207,7 @@ class ClassComponent extends Vue {
208207
}
209208
}
210209

210+
// @ts-expect-error changeMessage expects an argument
211211
expectError(mount(ClassComponent, {}).vm.changeMessage())
212212
mount(ClassComponent, {}).vm.changeMessage('')
213213

@@ -234,6 +234,7 @@ mount(Foo, {
234234

235235
expectError(
236236
mount(
237+
// @ts-expect-error
237238
defineComponent({
238239
props: {
239240
baz: String,

test-dts/plugins.d-test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectError, expectType } from 'tsd'
1+
import { expectError } from './index'
22
import { ComponentPublicInstance } from 'vue'
33
import { config, VueWrapper } from '../src'
44

@@ -40,7 +40,11 @@ config.plugins.VueWrapper.install(PluginWithOptionalOptions2, { msg: 'hello' })
4040

4141
// uncertain if it is possible to forbid this usage
4242
// expectError(config.plugins.VueWrapper.install(PluginWithoutOptions, {}))
43+
// @ts-expect-error option has the wrong type
4344
expectError(config.plugins.VueWrapper.install(PluginWithOptions, { msg: true }))
45+
// @ts-expect-error option is mandatory
4446
expectError(config.plugins.VueWrapper.install(PluginWithOptions, {}))
47+
// @ts-expect-error option is mandatory
4548
expectError(config.plugins.VueWrapper.install(PluginWithOptionalOptions, {}))
49+
// @ts-expect-error option is mandatory
4650
expectError(config.plugins.VueWrapper.install(PluginWithOptionalOptions2, {}))

test-dts/shallowMount.d-test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectError, expectType } from 'tsd'
1+
import { expectError, expectType } from './index'
22
import { defineComponent } from 'vue'
33
import { Options, Vue } from 'vue-class-component'
44
import { shallowMount } from '../src'
@@ -26,8 +26,8 @@ shallowMount(AppWithDefine, {
2626
props: { a: 'Hello', c: 2 }
2727
})
2828

29-
// wrong prop type should not compile
3029
expectError(
30+
// @ts-expect-error wrong prop type should not compile
3131
shallowMount(AppWithDefine, {
3232
props: { a: 2 }
3333
})
@@ -56,9 +56,9 @@ shallowMount(AppWithProps, {
5656
props: { a: 'Hello', b: 2 }
5757
})
5858

59-
// wrong prop type should not compile
6059
expectError(
6160
shallowMount(AppWithProps, {
61+
// @ts-expect-error wrong prop type should not compile
6262
props: { a: 2 }
6363
})
6464
)
@@ -107,5 +107,6 @@ class ClassComponent extends Vue {
107107
}
108108
}
109109

110+
// @ts-expect-error changeMessage expects an argument
110111
expectError(shallowMount(ClassComponent, {}).vm.changeMessage())
111112
shallowMount(ClassComponent, {}).vm.changeMessage('')

test-dts/tsconfig.tsd.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"skipLibCheck": true,
6+
"experimentalDecorators": true,
7+
"strictNullChecks": false
8+
},
9+
"exclude": [
10+
"../src",
11+
],
12+
"include": [
13+
"../dist",
14+
"../test-dts"
15+
]
16+
}

test-dts/wrapper.d-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectType } from 'tsd'
1+
import { expectType } from './index'
22
import { defineComponent } from 'vue'
33
import { mount } from '../src'
44

0 commit comments

Comments
 (0)