]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: more strict linking in dts tests
authorEvan You <yyx990803@gmail.com>
Fri, 3 Feb 2023 13:41:33 +0000 (21:41 +0800)
committerEvan You <yyx990803@gmail.com>
Fri, 3 Feb 2023 13:41:33 +0000 (21:41 +0800)
18 files changed:
packages/dts-test/appUse.test-d.ts
packages/dts-test/compiler.test-d.ts
packages/dts-test/component.test-d.ts
packages/dts-test/componentTypeExtensions.test-d.tsx
packages/dts-test/defineComponent.test-d.tsx
packages/dts-test/defineCustomElement.test-d.ts
packages/dts-test/functionalComponent.test-d.tsx
packages/dts-test/h.test-d.ts
packages/dts-test/inject.test-d.ts
packages/dts-test/package.json
packages/dts-test/reactivity.test-d.ts
packages/dts-test/reactivityMacros.test-d.ts
packages/dts-test/ref.test-d.ts
packages/dts-test/setupHelpers.test-d.ts
packages/dts-test/tsx.test-d.tsx
packages/dts-test/utils.d.ts [moved from packages/dts-test/index.d.ts with 88% similarity]
packages/dts-test/watch.test-d.ts
pnpm-lock.yaml

index 526aa888a0b01f0335815f6ea90d94a5cf103e47..c1bebcd53e369ab1e58271cdc82cfc7c8bc00f12 100644 (file)
@@ -1,4 +1,4 @@
-import { createApp, App, Plugin } from './index'
+import { createApp, App, Plugin } from 'vue'
 
 const app = createApp({})
 
index 974b49492a42cec53ff57ac1cc1f81248419e8ff..c6282373983ca64deb712150af55e78f942968aa 100644 (file)
@@ -1,5 +1,4 @@
 import {
-  expectType,
   createBlock,
   VNode,
   Teleport,
@@ -9,7 +8,8 @@ import {
   Fragment,
   Suspense,
   defineComponent
-} from './index'
+} from 'vue'
+import { expectType } from './utils'
 
 expectType<VNode>(createBlock(Teleport))
 expectType<VNode>(createBlock(Text))
index 5678c8e1ceb66c98365ab82ae391918389cc8334..5535419f1988ab3766847a953c36f7c9a196e14b 100644 (file)
@@ -1,20 +1,16 @@
 import {
-  describe,
   Component,
   defineComponent,
   PropType,
   ref,
   Ref,
-  expectError,
-  expectType,
   ShallowUnwrapRef,
   FunctionalComponent,
   ComponentPublicInstance,
   toRefs,
-  IsAny,
-  SetupContext,
-  expectAssignable
-} from './index'
+  SetupContext
+} from 'vue'
+import { describe, expectAssignable, expectType, IsAny } from './utils'
 
 declare function extractComponentOptions<Props, RawBindings>(
   obj: Component<Props, RawBindings>
@@ -371,7 +367,7 @@ describe('array props', () => {
     const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
 
     // @ts-expect-error props should be readonly
-    expectError((props.a = 1))
+    props.a = 1
     expectType<any>(props.a)
     expectType<any>(props.b)
 
@@ -392,7 +388,7 @@ describe('array props', () => {
     const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
 
     // @ts-expect-error props should be readonly
-    expectError((props.a = 1))
+    props.a = 1
 
     // TODO infer the correct keys
     // expectType<any>(props.a)
index e26c272c70307685c39007bb9de84af2fb6a10fb..4b3c5d7d195cd21131a1f26c3f8514f5caab3857 100644 (file)
@@ -1,6 +1,7 @@
-import { defineComponent, expectError, expectType } from './index'
+import { defineComponent } from 'vue'
+import { expectType } from './utils'
 
-declare module '@vue/runtime-core' {
+declare module 'vue' {
   interface ComponentCustomOptions {
     test?(n: number): void
   }
@@ -31,20 +32,16 @@ export const Custom = defineComponent({
 
   methods: {
     aMethod() {
-      // @ts-expect-error
-      expectError(this.notExisting)
       this.counter++
       this.state = 'running'
-
       this.$.appContext.config.globalProperties.state = 'running'
 
-      expectError(
-        // @ts-expect-error
-        (this.$.appContext.config.globalProperties.state = 'not valid')
-      )
-
       // @ts-expect-error
-      expectError((this.state = 'not valid'))
+      this.notExisting
+      // @ts-expect-error
+      this.state = 'not valid'
+      // @ts-expect-error
+      this.$.appContext.config.globalProperties.state = 'not valid'
     }
   }
 })
@@ -57,10 +54,10 @@ expectType<JSX.Element>(<Custom ref={''} bar="bar" baz={1} />)
 // @ts-expect-error
 expectType<JSX.Element>(<Custom />)
 // @ts-expect-error
-expectError(<Custom bar="bar" />)
+;<Custom bar="bar" />
 // @ts-expect-error
-expectError(<Custom baz="baz" />)
+;<Custom baz="baz" />
 // @ts-expect-error
-expectError(<Custom baz={1} notExist={1} />)
+;<Custom baz={1} notExist={1} />
 // @ts-expect-error
-expectError(<Custom baz={1} custom="custom" />)
+;<Custom baz={1} custom="custom" />
index 1ad6ee1f38f6f13738309a09251c003080151a93..0d2e35d79833ed49e1b3a9c5f80437e3c185cca2 100644 (file)
@@ -1,20 +1,16 @@
 import {
-  describe,
-  test,
   Component,
   defineComponent,
   PropType,
   ref,
   reactive,
   createApp,
-  expectError,
-  expectType,
   ComponentPublicInstance,
   ComponentOptions,
   SetupContext,
-  IsUnion,
   h
-} from './index'
+} from 'vue'
+import { describe, expectType, IsUnion } from './utils'
 
 describe('with object props', () => {
   interface ExpectedProps {
@@ -178,7 +174,7 @@ describe('with object props', () => {
       expectType<ExpectedProps['lll']>(props.lll)
 
       // @ts-expect-error props should be readonly
-      expectError((props.a = 1))
+      props.a = 1
 
       // setup context
       return {
@@ -220,7 +216,7 @@ describe('with object props', () => {
       expectType<ExpectedProps['kkk']>(props.kkk)
 
       // @ts-expect-error props should be readonly
-      expectError((props.a = 1))
+      props.a = 1
 
       // should also expose declared props on `this`
       expectType<ExpectedProps['a']>(this.a)
@@ -248,7 +244,7 @@ describe('with object props', () => {
       expectType<ExpectedProps['kkk']>(this.kkk)
 
       // @ts-expect-error props on `this` should be readonly
-      expectError((this.a = 1))
+      this.a = 1
 
       // assert setup context unwrapping
       expectType<number>(this.c)
@@ -305,18 +301,14 @@ describe('with object props', () => {
   )
 
   // @ts-expect-error missing required props
-  expectError(<MyComponent />)
+  let c = <MyComponent />
+  // @ts-expect-error wrong prop types
+  c = <MyComponent a={'wrong type'} b="foo" dd={{ n: 1 }} ddd={['foo']} />
+  // @ts-expect-error wrong prop types
+  c = <MyComponent ggg="baz" />
 
-  expectError(
-    // @ts-expect-error wrong prop types
-    <MyComponent a={'wrong type'} b="foo" dd={{ n: 1 }} ddd={['foo']} />
-  )
-  expectError(
-    // @ts-expect-error wrong prop types
-    <MyComponent ggg="baz" />
-  )
   // @ts-expect-error
-  expectError(<MyComponent b="foo" dd={{ n: 'string' }} ddd={['foo']} />)
+  ;<MyComponent b="foo" dd={{ n: 'string' }} ddd={['foo']} />
 
   // `this` should be void inside of prop validators and prop default factories
   defineComponent({
@@ -353,17 +345,18 @@ describe('type inference w/ optional props declaration', () => {
 
   expectType<JSX.Element>(<MyComponent msg="1" a={['1']} />)
   // @ts-expect-error
-  expectError(<MyComponent />)
+  ;<MyComponent />
   // @ts-expect-error
-  expectError(<MyComponent msg="1" />)
+  ;<MyComponent msg="1" />
 })
 
 describe('type inference w/ direct setup function', () => {
   const MyComponent = defineComponent((_props: { msg: string }) => {})
   expectType<JSX.Element>(<MyComponent msg="foo" />)
   // @ts-expect-error
-  expectError(<MyComponent />)
-  expectError(<MyComponent msg="1" />)
+  ;<MyComponent />
+  // @ts-expect-error
+  ;<MyComponent msg={1} />
 })
 
 describe('type inference w/ array props declaration', () => {
@@ -371,7 +364,7 @@ describe('type inference w/ array props declaration', () => {
     props: ['a', 'b'],
     setup(props) {
       // @ts-expect-error props should be readonly
-      expectError((props.a = 1))
+      props.a = 1
       expectType<any>(props.a)
       expectType<any>(props.b)
       return {
@@ -382,7 +375,7 @@ describe('type inference w/ array props declaration', () => {
       expectType<any>(this.$props.a)
       expectType<any>(this.$props.b)
       // @ts-expect-error
-      expectError((this.$props.a = 1))
+      this.$props.a = 1
       expectType<any>(this.a)
       expectType<any>(this.b)
       expectType<number>(this.c)
@@ -390,7 +383,7 @@ describe('type inference w/ array props declaration', () => {
   })
   expectType<JSX.Element>(<MyComponent a={[1, 2]} b="b" />)
   // @ts-expect-error
-  expectError(<MyComponent other="other" />)
+  ;<MyComponent other="other" />
 })
 
 describe('type inference w/ options API', () => {
@@ -609,17 +602,17 @@ describe('with mixins', () => {
 
       // props should be readonly
       // @ts-expect-error
-      expectError((this.aP1 = 'new'))
+      this.aP1 = 'new'
       // @ts-expect-error
-      expectError((this.z = 1))
+      this.z = 1
 
       // props on `this` should be readonly
       // @ts-expect-error
-      expectError((this.bP1 = 1))
+      this.bP1 = 1
 
       // string value can not assigned to number type value
       // @ts-expect-error
-      expectError((this.c = '1'))
+      this.c = '1'
 
       // setup context properties should be mutable
       this.d = 5
@@ -635,13 +628,13 @@ describe('with mixins', () => {
 
   // missing required props
   // @ts-expect-error
-  expectError(<MyComponent />)
+  ;<MyComponent />
 
   // wrong prop types
   // @ts-expect-error
-  expectError(<MyComponent aP1="ap" aP2={'wrong type'} bP1="b" z={'z'} />)
+  ;<MyComponent aP1="ap" aP2={'wrong type'} bP1="b" z={'z'} />
   // @ts-expect-error
-  expectError(<MyComponent aP1={1} bP2={[1]} />)
+  ;<MyComponent aP1={1} bP2={[1]} />
 })
 
 describe('with extends', () => {
@@ -700,13 +693,13 @@ describe('with extends', () => {
 
   // missing required props
   // @ts-expect-error
-  expectError(<MyComponent />)
+  ;<MyComponent />
 
   // wrong prop types
   // @ts-expect-error
-  expectError(<MyComponent aP2={'wrong type'} z={'z'} />)
+  ;<MyComponent aP2={'wrong type'} z={'z'} />
   // @ts-expect-error
-  expectError(<MyComponent aP1={3} />)
+  ;<MyComponent aP1={3} />
 })
 
 describe('extends with mixins', () => {
@@ -805,19 +798,19 @@ describe('extends with mixins', () => {
 
   // missing required props
   // @ts-expect-error
-  expectError(<MyComponent mP3 p3 /* z='z' */ />)
+  ;<MyComponent mP3 p3 /* z='z' */ />
   // missing required props from mixin
   // @ts-expect-error
-  expectError(<MyComponent /* mP3 */ p3 z="z" />)
+  ;<MyComponent /* mP3 */ p3 z="z" />
   // missing required props from extends
   // @ts-expect-error
-  expectError(<MyComponent mP3 /* p3 */ z="z" />)
+  ;<MyComponent mP3 /* p3 */ z="z" />
 
   // wrong prop types
   // @ts-expect-error
-  expectError(<MyComponent p2={'wrong type'} z={'z'} />)
+  ;<MyComponent p2={'wrong type'} z={'z'} />
   // @ts-expect-error
-  expectError(<MyComponent mP1={3} />)
+  ;<MyComponent mP1={3} />
 
   // #3468
   const CompWithD = defineComponent({
@@ -875,14 +868,14 @@ describe('compatibility w/ createApp', () => {
 })
 
 describe('defineComponent', () => {
-  test('should accept components defined with defineComponent', () => {
+  describe('should accept components defined with defineComponent', () => {
     const comp = defineComponent({})
     defineComponent({
       components: { comp }
     })
   })
 
-  test('should accept class components with receiving constructor arguments', () => {
+  describe('should accept class components with receiving constructor arguments', () => {
     class Comp {
       static __vccOpts = {}
       constructor(_props: { foo: string }) {}
@@ -915,29 +908,29 @@ describe('emits', () => {
       emit('click', 1)
       emit('input', 'foo')
       //  @ts-expect-error
-      expectError(emit('nope'))
+      emit('nope')
       //  @ts-expect-error
-      expectError(emit('click'))
+      emit('click')
       //  @ts-expect-error
-      expectError(emit('click', 'foo'))
+      emit('click', 'foo')
       //  @ts-expect-error
-      expectError(emit('input'))
+      emit('input')
       //  @ts-expect-error
-      expectError(emit('input', 1))
+      emit('input', 1)
     },
     created() {
       this.$emit('click', 1)
       this.$emit('input', 'foo')
       //  @ts-expect-error
-      expectError(this.$emit('nope'))
+      this.$emit('nope')
       //  @ts-expect-error
-      expectError(this.$emit('click'))
+      this.$emit('click')
       //  @ts-expect-error
-      expectError(this.$emit('click', 'foo'))
+      this.$emit('click', 'foo')
       //  @ts-expect-error
-      expectError(this.$emit('input'))
+      this.$emit('input')
       //  @ts-expect-error
-      expectError(this.$emit('input', 1))
+      this.$emit('input', 1)
     },
     mounted() {
       // #3599
@@ -947,15 +940,15 @@ describe('emits', () => {
         this.$emit('click', 1)
         this.$emit('input', 'foo')
         //  @ts-expect-error
-        expectError(this.$emit('nope'))
+        this.$emit('nope')
         //  @ts-expect-error
-        expectError(this.$emit('click'))
+        this.$emit('click')
         //  @ts-expect-error
-        expectError(this.$emit('click', 'foo'))
+        this.$emit('click', 'foo')
         //  @ts-expect-error
-        expectError(this.$emit('input'))
+        this.$emit('input')
         //  @ts-expect-error
-        expectError(this.$emit('input', 1))
+        this.$emit('input', 1)
       })
     }
   })
@@ -970,14 +963,14 @@ describe('emits', () => {
       emit('foo', 123)
       emit('bar')
       //  @ts-expect-error
-      expectError(emit('nope'))
+      emit('nope')
     },
     created() {
       this.$emit('foo')
       this.$emit('foo', 123)
       this.$emit('bar')
       //  @ts-expect-error
-      expectError(this.$emit('nope'))
+      this.$emit('nope')
     }
   })
 
@@ -990,9 +983,9 @@ describe('emits', () => {
       expectType<((n: number) => any) | undefined>(props.onClick)
       emit('click', 1)
       //  @ts-expect-error
-      expectError(emit('click'))
+      emit('click')
       //  @ts-expect-error
-      expectError(emit('click', 'foo'))
+      emit('click', 'foo')
     }
   })
 
@@ -1047,7 +1040,7 @@ describe('inject', () => {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
-      expectError((this.foobar = 1))
+      this.foobar = 1
     }
   })
 
@@ -1059,7 +1052,7 @@ describe('inject', () => {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
-      expectError((this.foobar = 1))
+      this.foobar = 1
     }
   })
 
@@ -1079,7 +1072,7 @@ describe('inject', () => {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
-      expectError((this.foobar = 1))
+      this.foobar = 1
     }
   })
 
@@ -1088,9 +1081,9 @@ describe('inject', () => {
     props: ['a', 'b'],
     created() {
       //  @ts-expect-error
-      expectError((this.foo = 1))
+      this.foo = 1
       //  @ts-expect-error
-      expectError((this.bar = 1))
+      this.bar = 1
     }
   })
 })
@@ -1145,15 +1138,15 @@ describe('extract instance type', () => {
   expectType<number>(compA.baseA)
 
   //  @ts-expect-error
-  expectError((compA.a = true))
+  compA.a = true
   //  @ts-expect-error
-  expectError((compA.b = 'foo'))
+  compA.b = 'foo'
   //  @ts-expect-error
-  expectError((compA.c = 1))
+  compA.c = 1
   //  @ts-expect-error
-  expectError((compA.mA = 'foo'))
+  compA.mA = 'foo'
   //  @ts-expect-error
-  expectError((compA.baseA = 1))
+  compA.baseA = 1
 })
 
 describe('async setup', () => {
@@ -1285,7 +1278,7 @@ import {
   AllowedComponentProps,
   ComponentCustomProps,
   ExtractPropTypes
-} from './index'
+} from 'vue'
 
 // code generated by tsc / vue-tsc, make sure this continues to work
 // so we don't accidentally change the args order of DefineComponent
index 14a4b52a3b820b378a2a1dd1c9ba18d5ffc6a2cf..4e7cf228372f93cfba0dd09ce7c797715447107e 100644 (file)
@@ -1,4 +1,5 @@
-import { defineCustomElement, expectType, expectError, describe } from './index'
+import { defineCustomElement } from 'vue'
+import { expectType, describe } from './utils'
 
 describe('inject', () => {
   // with object inject
@@ -14,7 +15,7 @@ describe('inject', () => {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
-      expectError((this.foobar = 1))
+      this.foobar = 1
     }
   })
 
@@ -26,7 +27,7 @@ describe('inject', () => {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
-      expectError((this.foobar = 1))
+      this.foobar = 1
     }
   })
 
@@ -46,7 +47,7 @@ describe('inject', () => {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
-      expectError((this.foobar = 1))
+      this.foobar = 1
     }
   })
 
@@ -55,9 +56,9 @@ describe('inject', () => {
     props: ['a', 'b'],
     created() {
       //  @ts-expect-error
-      expectError((this.foo = 1))
+      this.foo = 1
       //  @ts-expect-error
-      expectError((this.bar = 1))
+      this.bar = 1
     }
   })
 })
index fdcf346fb703f1979a01969bee9308893bce7fb8..383debcb7fe10ade48a7432a17124edf297923e8 100644 (file)
@@ -1,11 +1,5 @@
-import {
-  h,
-  Text,
-  FunctionalComponent,
-  expectError,
-  expectType,
-  Component
-} from './index'
+import { h, Text, FunctionalComponent, Component } from 'vue'
+import { expectType } from './utils'
 
 // simple function signature
 const Foo = (props: { foo: number }) => h(Text, null, props.foo)
@@ -15,11 +9,11 @@ expectType<JSX.Element>(<Foo foo={1} />)
 expectType<JSX.Element>(<Foo foo={1} key="1" />)
 expectType<JSX.Element>(<Foo foo={1} ref="ref" />)
 // @ts-expect-error
-expectError(<Foo />)
+;<Foo />
 //  @ts-expect-error
-expectError(<Foo foo="bar" />)
+;<Foo foo="bar" />
 //  @ts-expect-error
-expectError(<Foo baz="bar" />)
+;<Foo baz="bar" />
 
 // Explicit signature with props + emits
 const Bar: FunctionalComponent<
@@ -30,11 +24,11 @@ const Bar: FunctionalComponent<
 
   emit('update', 123)
   //  @ts-expect-error
-  expectError(emit('nope'))
+  emit('nope')
   //  @ts-expect-error
-  expectError(emit('update'))
+  emit('update')
   //  @ts-expect-error
-  expectError(emit('update', 'nope'))
+  emit('update', 'nope')
 }
 
 // assigning runtime options
@@ -42,22 +36,22 @@ Bar.props = {
   foo: Number
 }
 //  @ts-expect-error
-expectError((Bar.props = { foo: String }))
+Bar.props = { foo: String }
 
 Bar.emits = {
   update: value => value > 1
 }
 //  @ts-expect-error
-expectError((Bar.emits = { baz: () => void 0 }))
+Bar.emits = { baz: () => void 0 }
 
 // TSX
 expectType<JSX.Element>(<Bar foo={1} />)
 //  @ts-expect-error
-expectError(<Foo />)
+;<Foo />
 //  @ts-expect-error
-expectError(<Bar foo="bar" />)
+;<Bar foo="bar" />
 //  @ts-expect-error
-expectError(<Foo baz="bar" />)
+;<Foo baz="bar" />
 
 const Baz: FunctionalComponent<{}, string[]> = (props, { emit }) => {
   expectType<{}>(props)
index 6116fff74a9f6b8f11edb522b2df27918e92a266..92246f0f96b042ad9f4986156598cc0ba075664e 100644 (file)
@@ -1,5 +1,4 @@
 import {
-  describe,
   h,
   defineComponent,
   ref,
@@ -7,29 +6,28 @@ import {
   Teleport,
   Suspense,
   Component,
-  expectError,
-  expectAssignable,
   resolveComponent
-} from './index'
+} from 'vue'
+import { describe, expectAssignable } from './utils'
 
 describe('h inference w/ element', () => {
   // key
   h('div', { key: 1 })
   h('div', { key: 'foo' })
   //  @ts-expect-error
-  expectError(h('div', { key: [] }))
+  h('div', { key: [] })
   //  @ts-expect-error
-  expectError(h('div', { key: {} }))
+  h('div', { key: {} })
   // ref
   h('div', { ref: 'foo' })
   h('div', { ref: ref(null) })
   h('div', { ref: _el => {} })
   //  @ts-expect-error
-  expectError(h('div', { ref: [] }))
+  h('div', { ref: [] })
   //  @ts-expect-error
-  expectError(h('div', { ref: {} }))
+  h('div', { ref: {} })
   //  @ts-expect-error
-  expectError(h('div', { ref: 123 }))
+  h('div', { ref: 123 })
   // slots
   const slots = { default: () => {} } // RawSlots
   h('div', {}, slots)
@@ -40,20 +38,20 @@ describe('h inference w/ Fragment', () => {
   h(Fragment, ['hello'])
   h(Fragment, { key: 123 }, ['hello'])
   // @ts-expect-error
-  expectError(h(Fragment, 'foo'))
+  h(Fragment, 'foo')
   //  @ts-expect-error
-  expectError(h(Fragment, { key: 123 }, 'bar'))
+  h(Fragment, { key: 123 }, 'bar')
 })
 
 describe('h inference w/ Teleport', () => {
   h(Teleport, { to: '#foo' }, 'hello')
   h(Teleport, { to: '#foo' }, { default() {} })
   // @ts-expect-error
-  expectError(h(Teleport))
+  h(Teleport)
   // @ts-expect-error
-  expectError(h(Teleport, {}))
+  h(Teleport, {})
   // @ts-expect-error
-  expectError(h(Teleport, { to: '#foo' }))
+  h(Teleport, { to: '#foo' })
 })
 
 describe('h inference w/ Suspense', () => {
@@ -64,7 +62,7 @@ describe('h inference w/ Suspense', () => {
     default: () => 'foo'
   })
   //  @ts-expect-error
-  expectError(h(Suspense, { onResolve: 1 }))
+  h(Suspense, { onResolve: 1 })
 })
 
 describe('h inference w/ functional component', () => {
@@ -72,11 +70,11 @@ describe('h inference w/ functional component', () => {
   h(Func, { foo: 'hello' })
   h(Func, { foo: 'hello', bar: 123 })
   //  @ts-expect-error
-  expectError(h(Func, { foo: 123 }))
+  h(Func, { foo: 123 })
   //  @ts-expect-error
-  expectError(h(Func, {}))
+  h(Func, {})
   //  @ts-expect-error
-  expectError(h(Func, { bar: 123 }))
+  h(Func, { bar: 123 })
 })
 
 describe('h support w/ plain object component', () => {
@@ -106,11 +104,11 @@ describe('h inference w/ defineComponent', () => {
   // should allow extraneous props (attrs fallthrough)
   h(Foo, { bar: 1, foo: 'ok', class: 'extra' })
   // @ts-expect-error should fail on missing required prop
-  expectError(h(Foo, {}))
+  h(Foo, {})
   //  @ts-expect-error
-  expectError(h(Foo, { foo: 'ok' }))
+  h(Foo, { foo: 'ok' })
   // @ts-expect-error should fail on wrong type
-  expectError(h(Foo, { bar: 1, foo: 1 }))
+  h(Foo, { bar: 1, foo: 1 })
 })
 
 // describe('h inference w/ defineComponent + optional props', () => {
@@ -123,11 +121,11 @@ describe('h inference w/ defineComponent', () => {
 //   // should allow extraneous props (attrs fallthrough)
 //   h(Foo, { bar: 1, foo: 'ok', class: 'extra' })
 //   // @ts-expect-error should fail on missing required prop
-//   expectError(h(Foo, {}))
+//   h(Foo, {})
 //   // @ts-expect-error
-//   expectError(h(Foo, { foo: 'ok' }))
+//   h(Foo, { foo: 'ok' })
 //   // @ts-expect-error should fail on wrong type
-//   expectError(h(Foo, { bar: 1, foo: 1 }))
+//   h(Foo, { bar: 1, foo: 1 })
 // })
 
 // describe('h inference w/ defineComponent + direct function', () => {
@@ -138,11 +136,11 @@ describe('h inference w/ defineComponent', () => {
 //   // should allow extraneous props (attrs fallthrough)
 //   h(Foo, { bar: 1, foo: 'ok', class: 'extra' })
 //   // @ts-expect-error should fail on missing required prop
-//   expectError(h(Foo, {}))
+//   h(Foo, {})
 //   //  @ts-expect-error
-//   expectError(h(Foo, { foo: 'ok' }))
+//   h(Foo, { foo: 'ok' })
 //   // @ts-expect-error should fail on wrong type
-//   expectError(h(Foo, { bar: 1, foo: 1 }))
+//   h(Foo, { bar: 1, foo: 1 })
 // })
 
 // #922 and #3218
@@ -223,7 +221,7 @@ describe('Boolean prop implicit false', () => {
     visible: true
   })
   // @ts-expect-error
-  expectError(h(RequiredComponent, {}))
+  h(RequiredComponent, {})
 })
 
 // #2357
index 69e06f170aff996d187bda0ba8c7c11d8f435a70..c34485a61dc02344b45a2f50e9cf4cc45ed9fdd5 100644 (file)
@@ -1,4 +1,5 @@
-import { provide, inject, InjectionKey, expectType } from './index'
+import { provide, inject, InjectionKey } from 'vue'
+import { expectType } from './utils'
 
 const key: InjectionKey<number> = Symbol()
 
index 72f0e322acf3e6eb81ee1704c40057f63a17b791..6894c323925d13d6d42f9b0b9168a31bc0bdc46d 100644 (file)
@@ -2,9 +2,6 @@
   "name": "dts-test",
   "private": true,
   "dependencies": {
-    "vue": "workspace:*",
-    "@vue/runtime-core": "workspace:*",
-    "@vue/runtime-dom": "workspace:*",
-    "@vue/reactivity": "workspace:*"
+    "vue": "workspace:*"
   }
 }
index 337f05e147e41a7e65caa3942e2586d5dca26c03..4504f9e352d1c049babd3730c6d15dc6cdacf7c7 100644 (file)
@@ -1,21 +1,12 @@
-import {
-  ref,
-  readonly,
-  shallowReadonly,
-  describe,
-  expectError,
-  expectType,
-  Ref,
-  reactive,
-  markRaw
-} from './index'
+import { ref, readonly, shallowReadonly, Ref, reactive, markRaw } from 'vue'
+import { describe, expectType } from './utils'
 
 describe('should support DeepReadonly', () => {
   const r = readonly({ obj: { k: 'v' } })
   // @ts-expect-error
-  expectError((r.obj = {}))
+  r.obj = {}
   // @ts-expect-error
-  expectError((r.obj.k = 'x'))
+  r.obj.k = 'x'
 })
 
 // #4180
index 6bc5f17cba862120634cdedaf8a8d61a64aa7e66..9f9b5faed7d8d9e20df6aac6914dc3df1c0489ce 100644 (file)
@@ -1,13 +1,7 @@
-import {
-  expectType,
-  ref,
-  computed,
-  Ref,
-  ComputedRef,
-  WritableComputedRef
-} from './index'
+import { ref, computed, Ref, ComputedRef, WritableComputedRef } from 'vue'
 import 'vue/macros-global'
 import { RefType, RefTypes } from 'vue/macros'
+import { expectType } from './utils'
 
 // wrapping refs
 
index accaaeee8d7ae468c0dd4277bcabac2e00b24a97..dbf54de09c8821ec9657309610926e8f07126d68 100644 (file)
@@ -5,15 +5,14 @@ import {
   isRef,
   unref,
   reactive,
-  expectType,
   proxyRefs,
   toRef,
   toRefs,
   ToRefs,
   shallowReactive,
-  readonly,
-  describe
-} from './index'
+  readonly
+} from 'vue'
+import { expectType, describe } from './utils'
 
 function plainType(arg: number | Ref<number>) {
   // ref coercing
index 4d79fc8f479ab053db899e9f933f9387b941a004..8ad085f9bce5dabb1475836db4fe7f326de27626 100644 (file)
@@ -1,13 +1,12 @@
 import {
-  expectType,
   defineProps,
   defineEmits,
   useAttrs,
   useSlots,
   withDefaults,
-  Slots,
-  describe
-} from './index'
+  Slots
+} from 'vue'
+import { describe, expectType } from './utils'
 
 describe('defineProps w/ type declaration', () => {
   // type declaration
index ce1aec82043a07debe59eb6bf3aa59b951bca9a6..8dba0a8068f15b45352009b5a70f746bca554772 100644 (file)
@@ -1,13 +1,6 @@
 // TSX w/ defineComponent is tested in defineComponent.test-d.tsx
-import {
-  KeepAlive,
-  Suspense,
-  Fragment,
-  Teleport,
-  expectError,
-  expectType,
-  VNode
-} from './index'
+import { KeepAlive, Suspense, Fragment, Teleport, VNode } from 'vue'
+import { expectType } from './utils'
 
 expectType<VNode>(<div />)
 expectType<JSX.Element>(<div />)
@@ -15,7 +8,7 @@ expectType<JSX.Element>(<div id="foo" />)
 expectType<JSX.Element>(<input value="foo" />)
 
 // @ts-expect-error style css property validation
-expectError(<div style={{ unknown: 123 }} />)
+;<div style={{ unknown: 123 }} />
 
 // allow array styles and nested array styles
 expectType<JSX.Element>(<div style={[{ color: 'red' }]} />)
@@ -24,7 +17,7 @@ expectType<JSX.Element>(
 )
 
 // @ts-expect-error unknown prop
-expectError(<div foo="bar" />)
+;<div foo="bar" />
 
 // allow key/ref on arbitrary element
 expectType<JSX.Element>(<div key="foo" />)
@@ -47,15 +40,15 @@ expectType<JSX.Element>(<Teleport to="#foo" />)
 expectType<JSX.Element>(<Teleport to="#foo" key="1" />)
 
 // @ts-expect-error
-expectError(<Teleport />)
+;<Teleport />
 // @ts-expect-error
-expectError(<Teleport to={1} />)
+;<Teleport to={1} />
 
 // KeepAlive
 expectType<JSX.Element>(<KeepAlive include="foo" exclude={['a']} />)
 expectType<JSX.Element>(<KeepAlive key="1" />)
 // @ts-expect-error
-expectError(<KeepAlive include={123} />)
+;<KeepAlive include={123} />
 
 // Suspense
 expectType<JSX.Element>(<Suspense />)
@@ -64,4 +57,4 @@ expectType<JSX.Element>(
   <Suspense onResolve={() => {}} onFallback={() => {}} onPending={() => {}} />
 )
 // @ts-expect-error
-expectError(<Suspense onResolve={123} />)
+;<Suspense onResolve={123} />
similarity index 88%
rename from packages/dts-test/index.d.ts
rename to packages/dts-test/utils.d.ts
index 2945d492de83339eda723bb2d4aa2eea5c7c5c59..012f9772954e2b012a22c51c5ba4d5f5281675b4 100644 (file)
@@ -1,13 +1,10 @@
 // This directory contains a number of d.ts assertions
 // use \@ts-expect-error where errors are expected.
 
-export * from 'vue'
-
 export function describe(_name: string, _fn: () => void): void
 export function test(_name: string, _fn: () => any): void
 
 export function expectType<T>(value: T): void
-export function expectError<T>(value: T): void
 export function expectAssignable<T, T2 extends T = T>(value: T2): void
 
 export type IsUnion<T, U extends T = T> = (
index 2c16cabd9a4d3d4d2f91f74a62b78c00309b85ac..9d727999bccc033a76f2978dd968005fddd03ac0 100644 (file)
@@ -1,4 +1,5 @@
-import { ref, computed, watch, expectType, defineComponent } from './index'
+import { ref, computed, watch, defineComponent } from 'vue'
+import { expectType } from './utils'
 
 const source = ref('foo')
 const source2 = computed(() => source.value)
index f7b074d640dee8ca171e22ddd60d64173f6c6a66..849abe6e68270b90d3a1d51af9714641081b2501 100644 (file)
@@ -182,14 +182,8 @@ importers:
 
   packages/dts-test:
     specifiers:
-      '@vue/reactivity': workspace:*
-      '@vue/runtime-core': workspace:*
-      '@vue/runtime-dom': workspace:*
       vue: workspace:*
     dependencies:
-      '@vue/reactivity': link:../reactivity
-      '@vue/runtime-core': link:../runtime-core
-      '@vue/runtime-dom': link:../runtime-dom
       vue: link:../vue
 
   packages/reactivity: