diff --git a/package.json b/package.json index 77bba08..8bab118 100644 --- a/package.json +++ b/package.json @@ -127,6 +127,7 @@ "svelte-check": "^3.0.0 || ^4.0.4", "svelte-jester": "^5.0.0", "typescript": "^5.5.3", + "typescript-svelte-plugin": "^0.3.46", "vite": "^4.0.0 || ^5.3.3", "vitest": "0.x.x || ^1.0.0 || ^2.0.2" } diff --git a/src/__tests__/render-runes.test-d.ts b/src/__tests__/render-runes.test-d.ts index 48d9d27..51b7cfa 100644 --- a/src/__tests__/render-runes.test-d.ts +++ b/src/__tests__/render-runes.test-d.ts @@ -29,7 +29,7 @@ describe('types', () => { test('render result has container and component', () => { const result = subject.render(Component, { name: 'Alice', count: 42 }) - expectTypeOf(result).toMatchTypeOf<{ + expectTypeOf(result).toExtend<{ container: HTMLElement component: { hello: string } debug: (el?: HTMLElement) => void @@ -55,7 +55,7 @@ describe('legacy component types', () => { count: 42, }) - expectTypeOf(component).toMatchTypeOf<{ hello: string }>() + expectTypeOf(component).toExtend<{ hello: string }>() // @ts-expect-error: Svelte 5 mount does not return `$set` component.$on('greeting', onGreeting) diff --git a/src/__tests__/render-utilities.test-d.ts b/src/__tests__/render-utilities.test-d.ts index b45614e..d1e3869 100644 --- a/src/__tests__/render-utilities.test-d.ts +++ b/src/__tests__/render-utilities.test-d.ts @@ -8,7 +8,7 @@ describe('render query and utility types', () => { test('render result has default queries', () => { const result = subject.render(Component, { name: 'Alice' }) - expectTypeOf(result.getByRole).parameters.toMatchTypeOf< + expectTypeOf(result.getByRole).parameters.toExtend< [role: subject.ByRoleMatcher, options?: subject.ByRoleOptions] >() }) @@ -27,25 +27,25 @@ describe('render query and utility types', () => { { queries: { getByVibes } } ) - expectTypeOf(result.getByVibes).parameters.toMatchTypeOf<[vibes: string]>() + expectTypeOf(result.getByVibes).parameters.toExtend<[vibes: string]>() }) test('act is an async function', () => { - expectTypeOf(subject.act).toMatchTypeOf<() => Promise>() + expectTypeOf(subject.act).toExtend<() => Promise>() }) test('act accepts a sync function', () => { - expectTypeOf(subject.act).toMatchTypeOf<(fn: () => void) => Promise>() + expectTypeOf(subject.act).toExtend<(fn: () => void) => Promise>() }) test('act accepts an async function', () => { - expectTypeOf(subject.act).toMatchTypeOf< + expectTypeOf(subject.act).toExtend< (fn: () => Promise) => Promise >() }) test('fireEvent is an async function', () => { - expectTypeOf(subject.fireEvent).toMatchTypeOf< + expectTypeOf(subject.fireEvent).toExtend< ( element: Element | Node | Document | Window, event: Event @@ -54,7 +54,7 @@ describe('render query and utility types', () => { }) test('fireEvent[eventName] is an async function', () => { - expectTypeOf(subject.fireEvent.click).toMatchTypeOf< + expectTypeOf(subject.fireEvent.click).toExtend< ( element: Element | Node | Document | Window, // eslint-disable-next-line @typescript-eslint/no-empty-object-type diff --git a/src/__tests__/render.test-d.ts b/src/__tests__/render.test-d.ts index 08cad70..bf0a611 100644 --- a/src/__tests__/render.test-d.ts +++ b/src/__tests__/render.test-d.ts @@ -37,7 +37,7 @@ describe('types', () => { test('render result has container and component', () => { const result = subject.render(Component, { name: 'Alice', count: 42 }) - expectTypeOf(result).toMatchTypeOf<{ + expectTypeOf(result).toExtend<{ container: HTMLElement component: { hello: string } debug: (el?: HTMLElement) => void diff --git a/tsconfig.json b/tsconfig.json index f79cace..0cc0fdf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,8 @@ "noEmit": true, "skipLibCheck": true, "strict": true, - "types": ["svelte", "vite/client", "vitest", "vitest/globals"] + "types": ["svelte", "vite/client", "vitest", "vitest/globals"], + "plugins": [{ "name": "typescript-svelte-plugin" }] }, "include": ["src"] }