Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 93317d9

Browse files
authored
chore(ci): Enable typecheck (#189)
* Enable typecheck * Switch to tsd * Remove unnecessary patch
1 parent 6f1ffbc commit 93317d9

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

‎package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"test": "kcd-scripts test",
1212
"test:update": "npm test -- --updateSnapshot --coverage",
1313
"validate": "kcd-scripts validate",
14+
"typecheck": "tsd",
1415
"setup": "npm install && npm run validate -s"
1516
},
1617
"engines": {
@@ -60,7 +61,6 @@
6061
"@vue/compiler-sfc": "^3.1.1",
6162
"apollo-boost": "^0.4.9",
6263
"axios": "^0.20.0",
63-
"dtslint": "^4.1.0",
6464
"element-plus": "^1.0.2-beta.64",
6565
"eslint-plugin-vue": "^7.14.0",
6666
"graphql": "^15.5.0",
@@ -70,6 +70,7 @@
7070
"kcd-scripts": "^10.0.0",
7171
"lodash.merge": "^4.6.2",
7272
"msw": "^0.21.3",
73+
"tsd": "^0.17.0",
7374
"typescript": "^4.3.5",
7475
"vee-validate": "^4.3.5",
7576
"vue": "^3.0.4",

‎types/test.ts renamed to ‎types/index.test-d.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* eslint-disable @typescript-eslint/no-unused-expressions */
1+
import{expectType}from'tsd'
22
import {defineComponent} from 'vue'
3-
import {render, fireEvent, screen, waitFor} from '@testing-library/vue'
3+
import {render, fireEvent, screen, waitFor} from '.'
44

55
declare const elem: Element
66

@@ -16,29 +16,28 @@ export async function testRender() {
1616
const utils = render({template: '<div />'})
1717

1818
// single queries
19-
utils.getByText('foo')
20-
utils.queryByText('foo')
21-
await utils.findByText('foo')
19+
expectType<HTMLElement>(utils.getByText('foo'))
20+
expectType<HTMLElement|null>(utils.queryByText('foo'))
21+
expectType<HTMLElement>(await utils.findByText('foo'))
2222

2323
// multiple queries
24-
utils.getAllByText('bar')
25-
utils.queryAllByText('bar')
26-
await utils.findAllByText('bar')
24+
expectType<HTMLElement[]>(utils.getAllByText('bar'))
25+
expectType<HTMLElement[]>(utils.queryAllByText('bar'))
26+
expectType<HTMLElement[]>(await utils.findAllByText('bar'))
2727

2828
// helpers
2929
const {container, baseElement, unmount, debug, rerender} = utils
3030

31-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
32-
rerender({a: 1}) // $ExpectType Promise<void>
31+
expectType<void>(await rerender({a: 1}))
3332

34-
debug()// $ExpectType void
35-
debug(container)// $ExpectType void
36-
debug([elem, elem], 100, {highlight: false})// $ExpectType void
33+
expectType<void>(debug())
34+
expectType<void>(debug(container))
35+
expectType<void>(debug([elem, elem], 100, {highlight: false}))
3736

38-
unmount()// $ExpectType void
37+
expectType<void>(unmount())
3938

40-
container// $ExpectType Element
41-
baseElement// $ExpectType Element
39+
expectType<Element>(container)
40+
expectType<Element>(baseElement)
4241
}
4342

4443
export function testRenderOptions() {
@@ -50,20 +49,20 @@ export function testRenderOptions() {
5049

5150
export async function testFireEvent() {
5251
const {container} = render({template: 'button'})
53-
await fireEvent.click(container)// $ExpectType Promise<void>
54-
await fireEvent.touch(elem)// $ExpectType Promise<void>
52+
expectType<void>(await fireEvent.click(container))
53+
expectType<void>(await fireEvent.touch(elem))
5554
}
5655

5756
export async function testScreen() {
5857
render({template: 'button'})
5958

60-
await screen.findByRole('button')// $ExpectType Promise<HTMLElement>
59+
expectType<HTMLElement>(await screen.findByRole('button'))
6160
}
6261

6362
export async function testWaitFor() {
6463
const {container} = render({template: 'button'})
65-
await fireEvent.update(container)// $ExpectType Promise<void>
66-
await waitFor(() => {})
64+
expectType<void>(await fireEvent.update(container))
65+
expectType<void>(await waitFor(() => {}))
6766
}
6867

6968
export function testOptions() {
@@ -86,7 +85,7 @@ export function testOptions() {
8685

8786
export function testEmitted() {
8887
const {emitted} = render(SomeComponent)
89-
emitted().foo// $ExpectType unknown[]
88+
expectType<unknown[]>(emitted().foo)
9089
}
9190

9291
/*
@@ -96,4 +95,5 @@ eslint
9695
testing-library/no-debug: "off",
9796
testing-library/prefer-screen-queries: "off",
9897
@typescript-eslint/unbound-method: "off",
98+
@typescript-eslint/no-invalid-void-type: "off"
9999
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /