Skip to content

Commit 1e0251a

Browse files
committed
test: more strict linking in dts tests
1 parent b49b9ef commit 1e0251a

18 files changed

+157
-212
lines changed

packages/dts-test/appUse.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createApp, App, Plugin } from './index'
1+
import { createApp, App, Plugin } from 'vue'
22

33
const app = createApp({})
44

packages/dts-test/compiler.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
expectType,
32
createBlock,
43
VNode,
54
Teleport,
@@ -9,7 +8,8 @@ import {
98
Fragment,
109
Suspense,
1110
defineComponent
12-
} from './index'
11+
} from 'vue'
12+
import { expectType } from './utils'
1313

1414
expectType<VNode>(createBlock(Teleport))
1515
expectType<VNode>(createBlock(Text))

packages/dts-test/component.test-d.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import {
2-
describe,
32
Component,
43
defineComponent,
54
PropType,
65
ref,
76
Ref,
8-
expectError,
9-
expectType,
107
ShallowUnwrapRef,
118
FunctionalComponent,
129
ComponentPublicInstance,
1310
toRefs,
14-
IsAny,
15-
SetupContext,
16-
expectAssignable
17-
} from './index'
11+
SetupContext
12+
} from 'vue'
13+
import { describe, expectAssignable, expectType, IsAny } from './utils'
1814

1915
declare function extractComponentOptions<Props, RawBindings>(
2016
obj: Component<Props, RawBindings>
@@ -371,7 +367,7 @@ describe('array props', () => {
371367
const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
372368

373369
// @ts-expect-error props should be readonly
374-
expectError((props.a = 1))
370+
props.a = 1
375371
expectType<any>(props.a)
376372
expectType<any>(props.b)
377373

@@ -392,7 +388,7 @@ describe('array props', () => {
392388
const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
393389

394390
// @ts-expect-error props should be readonly
395-
expectError((props.a = 1))
391+
props.a = 1
396392

397393
// TODO infer the correct keys
398394
// expectType<any>(props.a)

packages/dts-test/componentTypeExtensions.test-d.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { defineComponent, expectError, expectType } from './index'
1+
import { defineComponent } from 'vue'
2+
import { expectType } from './utils'
23

3-
declare module '@vue/runtime-core' {
4+
declare module 'vue' {
45
interface ComponentCustomOptions {
56
test?(n: number): void
67
}
@@ -31,20 +32,16 @@ export const Custom = defineComponent({
3132

3233
methods: {
3334
aMethod() {
34-
// @ts-expect-error
35-
expectError(this.notExisting)
3635
this.counter++
3736
this.state = 'running'
38-
3937
this.$.appContext.config.globalProperties.state = 'running'
4038

41-
expectError(
42-
// @ts-expect-error
43-
(this.$.appContext.config.globalProperties.state = 'not valid')
44-
)
45-
4639
// @ts-expect-error
47-
expectError((this.state = 'not valid'))
40+
this.notExisting
41+
// @ts-expect-error
42+
this.state = 'not valid'
43+
// @ts-expect-error
44+
this.$.appContext.config.globalProperties.state = 'not valid'
4845
}
4946
}
5047
})
@@ -57,10 +54,10 @@ expectType<JSX.Element>(<Custom ref={''} bar="bar" baz={1} />)
5754
// @ts-expect-error
5855
expectType<JSX.Element>(<Custom />)
5956
// @ts-expect-error
60-
expectError(<Custom bar="bar" />)
57+
;<Custom bar="bar" />
6158
// @ts-expect-error
62-
expectError(<Custom baz="baz" />)
59+
;<Custom baz="baz" />
6360
// @ts-expect-error
64-
expectError(<Custom baz={1} notExist={1} />)
61+
;<Custom baz={1} notExist={1} />
6562
// @ts-expect-error
66-
expectError(<Custom baz={1} custom="custom" />)
63+
;<Custom baz={1} custom="custom" />

0 commit comments

Comments
 (0)