Skip to content

Commit

Permalink
test: defineOptions dts tests (#10849)
Browse files Browse the repository at this point in the history
  • Loading branch information
cexbrayat committed May 3, 2024
1 parent c146186 commit 9b82005
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/dts-test/README.md
Expand Up @@ -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`.
19 changes: 19 additions & 0 deletions packages/dts-test/setupHelpers.test-d.ts
Expand Up @@ -5,6 +5,7 @@ import {
defineComponent,
defineEmits,
defineModel,
defineOptions,
defineProps,
defineSlots,
toRefs,
Expand Down Expand Up @@ -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'],
})
})

0 comments on commit 9b82005

Please sign in to comment.