]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: defineOptions dts tests (#10849)
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Fri, 3 May 2024 20:27:23 +0000 (22:27 +0200)
committerGitHub <noreply@github.com>
Fri, 3 May 2024 20:27:23 +0000 (04:27 +0800)
packages/dts-test/README.md
packages/dts-test/setupHelpers.test-d.ts

index 6f1b1da1d0e50d9a297ca32fc997e393a37035c4..f75cc8b8d5ad1814ab61d4533ab63b94235edb6a 100644 (file)
@@ -4,4 +4,4 @@ Tests TypeScript types to ensure the types remain as expected.
 
 - This directory is included in the root `tsconfig.json`, where package imports are aliased to `src` directories, so in IDEs and the `pnpm check` script the types are validated against source code.
 
-- When running `tsc` with `packages/dts-test/tsconfig.test.json`, packages are resolved using normal `node` resolution, so the types are validated against actual **built** types. This requires the types to be built first via `pnpm build-types`.
+- When running `tsc` with `packages/dts-test/tsconfig.test.json`, packages are resolved using normal `node` resolution, so the types are validated against actual **built** types. This requires the types to be built first via `pnpm build-dts`.
index 883ebe6b254ff86a4176b5ce3cc093b829aa6f66..2cfc04bad1dedbde4806ed88ab433213df16c8ca 100644 (file)
@@ -5,6 +5,7 @@ import {
   defineComponent,
   defineEmits,
   defineModel,
+  defineOptions,
   defineProps,
   defineSlots,
   toRefs,
@@ -501,3 +502,21 @@ describe('toRefs w/ type declaration', () => {
   }>()
   expectType<Ref<File | File[] | undefined>>(toRefs(props).file)
 })
+
+describe('defineOptions', () => {
+  defineOptions({
+    name: 'MyComponent',
+    inheritAttrs: true,
+  })
+
+  defineOptions({
+    // @ts-expect-error props should be defined via defineProps()
+    props: ['props'],
+    // @ts-expect-error emits should be defined via defineEmits()
+    emits: ['emits'],
+    // @ts-expect-error slots should be defined via defineSlots()
+    slots: { default: 'default' },
+    // @ts-expect-error expose should be defined via defineExpose()
+    expose: ['expose'],
+  })
+})