Navigate button
-
Navigate Link
+
Navigate Link
Navigate Link
-
Navigate Link
+
Navigate
-
Navigate Link
Navigate Link
@@ -17,14 +16,19 @@
diff --git a/test/fixtures/simple/pages/admin/[id].vue b/test/fixtures/sample-project/src/pages/admin/[id].vue
similarity index 100%
rename from test/fixtures/simple/pages/admin/[id].vue
rename to test/fixtures/sample-project/src/pages/admin/[id].vue
diff --git a/test/fixtures/complex/src/pages/admin/[id]/action-[slug].vue b/test/fixtures/sample-project/src/pages/admin/[id]/action-[slug].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/admin/[id]/action-[slug].vue
rename to test/fixtures/sample-project/src/pages/admin/[id]/action-[slug].vue
diff --git a/test/fixtures/complex/src/pages/admin/[id]/index.vue b/test/fixtures/sample-project/src/pages/admin/[id]/index.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/admin/[id]/index.vue
rename to test/fixtures/sample-project/src/pages/admin/[id]/index.vue
diff --git a/test/fixtures/complex/src/pages/admin/[id]/profile.vue b/test/fixtures/sample-project/src/pages/admin/[id]/profile.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/admin/[id]/profile.vue
rename to test/fixtures/sample-project/src/pages/admin/[id]/profile.vue
diff --git a/test/fixtures/complex/src/pages/admin/[id]/settings.vue b/test/fixtures/sample-project/src/pages/admin/[id]/settings.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/admin/[id]/settings.vue
rename to test/fixtures/sample-project/src/pages/admin/[id]/settings.vue
diff --git a/test/fixtures/complex/src/pages/admin/panel/[[blou]].vue b/test/fixtures/sample-project/src/pages/admin/panel/[[blou]].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/admin/panel/[[blou]].vue
rename to test/fixtures/sample-project/src/pages/admin/panel/[[blou]].vue
diff --git a/test/fixtures/complex/src/pages/baguette.vue b/test/fixtures/sample-project/src/pages/baguette.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/baguette.vue
rename to test/fixtures/sample-project/src/pages/baguette.vue
diff --git a/test/fixtures/sample-project/src/pages/index.vue b/test/fixtures/sample-project/src/pages/index.vue
new file mode 100644
index 0000000..9ed4e76
--- /dev/null
+++ b/test/fixtures/sample-project/src/pages/index.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/test/fixtures/complex/src/pages/user/[foo]-[[bar]].vue b/test/fixtures/sample-project/src/pages/user/[foo]-[[bar]].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[foo]-[[bar]].vue
rename to test/fixtures/sample-project/src/pages/user/[foo]-[[bar]].vue
diff --git a/test/fixtures/complex/src/pages/user/[id].vue b/test/fixtures/sample-project/src/pages/user/[id].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[id].vue
rename to test/fixtures/sample-project/src/pages/user/[id].vue
diff --git a/test/fixtures/complex/src/pages/user/[id]/[slug].vue b/test/fixtures/sample-project/src/pages/user/[id]/[slug].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[id]/[slug].vue
rename to test/fixtures/sample-project/src/pages/user/[id]/[slug].vue
diff --git a/test/fixtures/complex/src/pages/user/[id]/[slug]/articles.vue b/test/fixtures/sample-project/src/pages/user/[id]/[slug]/articles.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[id]/[slug]/articles.vue
rename to test/fixtures/sample-project/src/pages/user/[id]/[slug]/articles.vue
diff --git a/test/fixtures/complex/src/pages/user/[id]/[slug]/index.vue b/test/fixtures/sample-project/src/pages/user/[id]/[slug]/index.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[id]/[slug]/index.vue
rename to test/fixtures/sample-project/src/pages/user/[id]/[slug]/index.vue
diff --git a/test/fixtures/complex/src/pages/user/[id]/index.vue b/test/fixtures/sample-project/src/pages/user/[id]/index.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[id]/index.vue
rename to test/fixtures/sample-project/src/pages/user/[id]/index.vue
diff --git a/test/fixtures/complex/src/pages/user/[id]/posts.vue b/test/fixtures/sample-project/src/pages/user/[id]/posts.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[id]/posts.vue
rename to test/fixtures/sample-project/src/pages/user/[id]/posts.vue
diff --git a/test/fixtures/complex/src/pages/user/[one]-foo-[two].vue b/test/fixtures/sample-project/src/pages/user/[one]-foo-[two].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/[one]-foo-[two].vue
rename to test/fixtures/sample-project/src/pages/user/[one]-foo-[two].vue
diff --git a/test/fixtures/complex/src/pages/user/catch/[...slug].vue b/test/fixtures/sample-project/src/pages/user/catch/[...slug].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/catch/[...slug].vue
rename to test/fixtures/sample-project/src/pages/user/catch/[...slug].vue
diff --git a/test/fixtures/complex/src/pages/user/index.vue b/test/fixtures/sample-project/src/pages/user/index.vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/index.vue
rename to test/fixtures/sample-project/src/pages/user/index.vue
diff --git a/test/fixtures/complex/src/pages/user/test-[[optional]].vue b/test/fixtures/sample-project/src/pages/user/test-[[optional]].vue
similarity index 100%
rename from test/fixtures/complex/src/pages/user/test-[[optional]].vue
rename to test/fixtures/sample-project/src/pages/user/test-[[optional]].vue
diff --git a/test/fixtures/sample-project/tests/README.md b/test/fixtures/sample-project/tests/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/complex/tests/misc/definePageMeta.spec-d.ts b/test/fixtures/sample-project/tests/[classic]/misc/definePageMeta.spec-d.ts
similarity index 98%
rename from test/fixtures/complex/tests/misc/definePageMeta.spec-d.ts
rename to test/fixtures/sample-project/tests/[classic]/misc/definePageMeta.spec-d.ts
index ae2cee4..4b0b400 100644
--- a/test/fixtures/complex/tests/misc/definePageMeta.spec-d.ts
+++ b/test/fixtures/sample-project/tests/[classic]/misc/definePageMeta.spec-d.ts
@@ -72,7 +72,7 @@ definePageMeta({
// ! ------ Should Error ❌
// @ts-expect-error
-assertType(definePageMeta({ redirect: '' }));
+assertType(definePageMeta({ redirect: '/foo' }));
// @ts-expect-error
assertType(definePageMeta({ redirect: '/admin ' }));
// @ts-expect-error
diff --git a/test/fixtures/complex/tests/router/NuxtLink.spec-d.ts b/test/fixtures/sample-project/tests/[classic]/router/NuxtLink.spec-d.ts
similarity index 100%
rename from test/fixtures/complex/tests/router/NuxtLink.spec-d.ts
rename to test/fixtures/sample-project/tests/[classic]/router/NuxtLink.spec-d.ts
diff --git a/test/fixtures/complex/tests/router/navigateTo.spec-d.ts b/test/fixtures/sample-project/tests/[classic]/router/navigateTo.spec-d.ts
similarity index 100%
rename from test/fixtures/complex/tests/router/navigateTo.spec-d.ts
rename to test/fixtures/sample-project/tests/[classic]/router/navigateTo.spec-d.ts
diff --git a/test/fixtures/complex/tests/router/useRouter.spec-d.ts b/test/fixtures/sample-project/tests/[classic]/router/useRouter.spec-d.ts
similarity index 97%
rename from test/fixtures/complex/tests/router/useRouter.spec-d.ts
rename to test/fixtures/sample-project/tests/[classic]/router/useRouter.spec-d.ts
index 3d4502b..94b0d9d 100644
--- a/test/fixtures/complex/tests/router/useRouter.spec-d.ts
+++ b/test/fixtures/sample-project/tests/[classic]/router/useRouter.spec-d.ts
@@ -1,6 +1,6 @@
import { assertType } from 'vitest';
-import type { TypedRouter, } from '@typed-router';
-import { useRouter } from '@typed-router';
+import type { TypedRouter } from '@typed-router';
+import { useRouter } from '@typed-router';
// @ts-expect-error Ensure global imports are disabled
declare const globalDecl: (typeof globalThis)['useRouter'];
@@ -8,6 +8,8 @@ declare const globalDecl: (typeof globalThis)['useRouter'];
// Given
const router = useRouter();
+router.push({ name: 'index' });
+
assertType
(router);
// - Usage of useRouter with useRouter
diff --git a/test/fixtures/complex/tests/routes/useRoute.spec-d.ts b/test/fixtures/sample-project/tests/[classic]/routes/useRoute.spec-d.ts
similarity index 100%
rename from test/fixtures/complex/tests/routes/useRoute.spec-d.ts
rename to test/fixtures/sample-project/tests/[classic]/routes/useRoute.spec-d.ts
diff --git a/test/fixtures/sample-project/tests/[classic]/test.vue b/test/fixtures/sample-project/tests/[classic]/test.vue
new file mode 100644
index 0000000..cb1064c
--- /dev/null
+++ b/test/fixtures/sample-project/tests/[classic]/test.vue
@@ -0,0 +1,29 @@
+
+
+ Navigate button
+ Navigate link
+ Foo
+
+ NavigateTo button
+
+
+
+
diff --git a/test/fixtures/complex/tests/router/$typedRouter.spec-d.ts b/test/fixtures/sample-project/tests/[withPlugin]/$typedRouter.spec-d.ts
similarity index 100%
rename from test/fixtures/complex/tests/router/$typedRouter.spec-d.ts
rename to test/fixtures/sample-project/tests/[withPlugin]/$typedRouter.spec-d.ts
diff --git a/test/fixtures/simple/tests/misc/definePageMeta.spec-d.ts b/test/fixtures/sample-project/tests/[withStrict]/misc/definePageMeta.spec-d.ts
similarity index 50%
rename from test/fixtures/simple/tests/misc/definePageMeta.spec-d.ts
rename to test/fixtures/sample-project/tests/[withStrict]/misc/definePageMeta.spec-d.ts
index ae2cee4..e58ef18 100644
--- a/test/fixtures/simple/tests/misc/definePageMeta.spec-d.ts
+++ b/test/fixtures/sample-project/tests/[withStrict]/misc/definePageMeta.spec-d.ts
@@ -1,4 +1,4 @@
-import { assertType, expectTypeOf } from 'vitest';
+import { assertType } from 'vitest';
import { definePageMeta } from '@typed-router';
// Given
@@ -48,12 +48,6 @@ definePageMeta({ redirect: { name: 'user-id-slug', params: { id: 1 } } });
// @ts-expect-error
definePageMeta({ redirect: { name: 'test-module' } });
-// * --- Path navigation
-// @ts-expect-error
-definePageMeta({ redirect: '/fooooooooooo' });
-// @ts-expect-error
-definePageMeta({ redirect: { path: '/foo' } });
-
// $ ----- Should be valid ✅
definePageMeta({ redirect: { name: 'index' } });
@@ -72,46 +66,4 @@ definePageMeta({
// ! ------ Should Error ❌
// @ts-expect-error
-assertType(definePageMeta({ redirect: '' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin ' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin/ /' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: `/ / // / / eefzr` }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/elzhlzehflzhef' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin/foo/bar' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin/foo/bar/baz' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: `/admin/${id}/action-bar/taz?query` }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin/panel/3O9393/bar' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin/foo/ profile/ezfje' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin/3U93U/settings/baz' }));
-// @ts-expect-error
-assertType(definePageMeta({ redirect: '/admin/panel/?fjzk' }));
-
-// $ ----- Should be valid ✅
-
-const id = '38789803';
-assertType(definePageMeta({ redirect: '/' }));
-assertType(definePageMeta({ redirect: '/baguette' }));
-assertType(definePageMeta({ redirect: '/admin/foo' }));
-assertType(definePageMeta({ redirect: '/admin/foo/' }));
-assertType(definePageMeta({ redirect: `/admin/${id}/action-bar#hash` }));
-assertType(definePageMeta({ redirect: `/admin/${id}/action-bar?query=bar` }));
-assertType(definePageMeta({ redirect: '/admin/foo/profile/' }));
-assertType(definePageMeta({ redirect: `/admin/${id}/settings` }));
-assertType(definePageMeta({ redirect: '/admin/panel/' }));
-assertType(definePageMeta({ redirect: '/admin/panel/938783/' }));
-assertType(definePageMeta({ redirect: '/user/38873-' }));
-assertType(definePageMeta({ redirect: '/user/38673/bar/#hash' }));
-assertType(definePageMeta({ redirect: '/user/ç9737/foo/articles?baz=foo' }));
-assertType(definePageMeta({ redirect: '/user/catch/1/2' }));
-assertType(definePageMeta({ redirect: '/user/test-' }));
-assertType(definePageMeta({ redirect: '/user' }));
+definePageMeta({ redirect: '/' });
diff --git a/test/fixtures/simple/tests/router/NuxtLink.spec-d.ts b/test/fixtures/sample-project/tests/[withStrict]/router/NuxtLink.spec-d.ts
similarity index 53%
rename from test/fixtures/simple/tests/router/NuxtLink.spec-d.ts
rename to test/fixtures/sample-project/tests/[withStrict]/router/NuxtLink.spec-d.ts
index 30d7c07..17967f9 100644
--- a/test/fixtures/simple/tests/router/NuxtLink.spec-d.ts
+++ b/test/fixtures/sample-project/tests/[withStrict]/router/NuxtLink.spec-d.ts
@@ -1,7 +1,7 @@
import { assertType, vi } from 'vitest';
-import type { TypedNuxtLink } from '../../.nuxt/typed-router/typed-router';
+import type { GlobalComponents } from 'vue';
-const NuxtLink: TypedNuxtLink = vi.fn() as any;
+const NuxtLink: GlobalComponents['NuxtLink'] = vi.fn() as any;
// ! ------ Should Error ❌
@@ -27,9 +27,9 @@ assertType(new NuxtLink({ to: { name: 'user-foo-bar', params: { bar: 1 } } }));
// * --- [...slug].vue
// @ts-expect-error
-assertType(new NuxtLink({ to: { name: 'user-catch-slug' } }));
+assertType(new NuxtLink({ to: { name: 'user-slug' } }));
// @ts-expect-error
-assertType(new NuxtLink({ to: { name: 'user-catch-slug', params: { slug: 1 } } }));
+assertType(new NuxtLink({ to: { name: 'user-slug', params: { slug: 1 } } }));
// * --- [one]-foo-[two].vue
// @ts-expect-error
@@ -47,6 +47,15 @@ assertType(new NuxtLink({ to: { name: 'user-id-slug', params: { id: 1 } } }));
// @ts-expect-error
assertType(new NuxtLink({ to: { name: 'test-module' } }));
+// --- Path navigation
+
+// ! ------ Should Error ❌
+
+// @ts-expect-error
+assertType(new NuxtLink({ to: '/' }));
+// @ts-expect-error
+assertType(new NuxtLink({ to: { path: '/' } }));
+
// $ ----- Should be valid ✅
assertType(new NuxtLink({ to: { name: 'index' } }));
@@ -66,58 +75,14 @@ assertType(
})
);
-// --- Path navigation
-
-// ! ------ Should Error ❌
-
-// @ts-expect-error
-assertType(new NuxtLink({ to: '' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin ' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin/ /' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: `/ / // / / eefzr` }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/elzhlzehflzhef' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin/foo/bar' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin/foo/bar/baz' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: `/admin/${id}/action-bar/taz?query` }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin/panel/3O9393/bar' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin/foo/ profile/ezfje' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin/3U93U/settings/baz' }));
-// @ts-expect-error
-assertType(new NuxtLink({ to: '/admin/panel/?fjzk' }));
-
-// $ ----- Should be valid ✅
-
-const id = '38789803';
-assertType(new NuxtLink({ to: '/' }));
-assertType(new NuxtLink({ to: '/baguette' }));
-assertType(new NuxtLink({ to: '/admin/foo' }));
-assertType(new NuxtLink({ to: '/admin/foo/' }));
-assertType(new NuxtLink({ to: `/admin/${id}/action-bar#hash` }));
-assertType(new NuxtLink({ to: `/admin/${id}/action-bar?query=bar` }));
-assertType(new NuxtLink({ to: '/admin/foo/profile/' }));
-assertType(new NuxtLink({ to: `/admin/${id}/settings` }));
-assertType(new NuxtLink({ to: '/admin/panel/' }));
-assertType(new NuxtLink({ to: '/admin/panel/938783/' }));
-assertType(new NuxtLink({ to: '/user/38873-' }));
-assertType(new NuxtLink({ to: '/user/38673/bar/#hash' }));
-assertType(new NuxtLink({ to: '/user/ç9737/foo/articles?baz=foo' }));
-assertType(new NuxtLink({ to: '/user/catch/1/2' }));
-assertType(new NuxtLink({ to: '/user/test-' }));
-assertType(new NuxtLink({ to: '/user' }));
+assertType(
+ new NuxtLink({
+ to: { name: 'test-module', params: { foo: 1 }, query: { foo: 'bar' } },
+ })
+);
// - With External prop
// $ ----- Should be valid ✅
-assertType(new NuxtLink({ to: '/admin/:id/', external: false }));
assertType(new NuxtLink({ to: 'http://google.com', external: true }));
diff --git a/test/fixtures/simple/tests/router/navigateTo.spec-d.ts b/test/fixtures/sample-project/tests/[withStrict]/router/navigateTo.spec-d.ts
similarity index 67%
rename from test/fixtures/simple/tests/router/navigateTo.spec-d.ts
rename to test/fixtures/sample-project/tests/[withStrict]/router/navigateTo.spec-d.ts
index 37aea62..5235ebe 100644
--- a/test/fixtures/simple/tests/router/navigateTo.spec-d.ts
+++ b/test/fixtures/sample-project/tests/[withStrict]/router/navigateTo.spec-d.ts
@@ -1,5 +1,6 @@
-import { assertType, test } from 'vitest';
+import { assertType } from 'vitest';
import type { LocationQuery } from 'vue-router';
+import test from 'node:test';
// ! ------ Should Error ❌
@@ -25,9 +26,9 @@ navigateTo({ name: 'user-foo-bar', params: { bar: 1 } });
// * --- [...slug].vue
// @ts-expect-error
-navigateTo({ name: 'user-catch-slug' });
+navigateTo({ name: 'user-slug' });
// @ts-expect-error
-navigateTo({ name: 'user-catch-slug', params: { slug: 1 } });
+navigateTo({ name: 'user-slug', params: { slug: 1 } });
// * --- [one]-foo-[two].vue
// @ts-expect-error
@@ -55,61 +56,14 @@ navigateTo({ name: 'user-catch-slug', params: { slug: ['foo'] } });
navigateTo({ name: 'user-catch-slug', params: { slug: [1, 2, 3] } });
navigateTo({ name: 'user-one-foo-two', params: { one: 1, two: '2' } });
navigateTo({ name: 'user-id-slug', params: { slug: '2' }, query: { foo: 'bar' } });
+navigateTo({ name: 'test-module', params: { foo: 1 }, query: { foo: 'bar' } });
// --- Path navigation
// ! ------ Should Error ❌
// @ts-expect-error
-assertType(navigateTo(''));
-// @ts-expect-error
-assertType(navigateTo('/admin '));
-// @ts-expect-error
-assertType(navigateTo('/admin/ /'));
-// @ts-expect-error
-assertType(navigateTo(`/ / // / / eefzr`));
-// @ts-expect-error
-assertType(navigateTo('/elzhlzehflzhef'));
-// @ts-expect-error
-assertType(navigateTo('/admin/foo/bar'));
-// @ts-expect-error
-assertType(navigateTo('/admin/foo/bar/baz'));
-// @ts-expect-error
-assertType(navigateTo(`/admin/${id}/action-bar/taz?query`));
-// @ts-expect-error
-assertType(navigateTo('/admin/panel/3O9393/bar'));
-// @ts-expect-error
-assertType(navigateTo('/admin/foo/ profile/ezfje'));
-// @ts-expect-error
-assertType(navigateTo('/admin/3U93U/settings/baz'));
-// @ts-expect-error
-assertType(navigateTo('/admin/panel/?fjzk'));
-// @ts-expect-error
-assertType(navigateTo('/admin/panel/938783/ '));
-// @ts-expect-error
-assertType(navigateTo('/user/3887/foo/bar/'));
-// @ts-expect-error
-assertType(navigateTo('/admin/:id//'));
-
-// $ ----- Should be valid ✅
-
-const id = '38789803';
assertType(navigateTo('/'));
-assertType(navigateTo('/baguette'));
-assertType(navigateTo('/admin/foo'));
-assertType(navigateTo('/admin/foo/'));
-assertType(navigateTo(`/admin/${id}/action-bar#hash`));
-assertType(navigateTo(`/admin/${id}/action-bar?query=bar`));
-assertType(navigateTo('/admin/foo/profile/'));
-assertType(navigateTo(`/admin/${id}/settings`));
-assertType(navigateTo('/admin/panel/'));
-assertType(navigateTo('/admin/panel/938783/'));
-assertType(navigateTo('/user/38873-'));
-assertType(navigateTo('/user/38673/bar/#hash'));
-assertType(navigateTo('/user/ç9737/foo/articles?baz=foo'));
-assertType(navigateTo('/user/catch/1/2'));
-assertType(navigateTo('/user/test-'));
-assertType(navigateTo('/user'));
// - Resolved routes
@@ -214,20 +168,19 @@ test('', async () => {
}
});
-// - With paths
-
-// * --- [foo]-[[bar]].vue
+// * --- Routes added by modules
test('', async () => {
- const resolvedNavigateToRoute = await navigateTo('/admin/3883/action-376773');
+ const resolvedNavigateToRoute = await navigateTo({
+ name: 'test-module',
+ params: {
+ foo: 1,
+ },
+ });
if (resolvedNavigateToRoute && !(resolvedNavigateToRoute instanceof Error)) {
- assertType<'admin-id-action-slug'>(resolvedNavigateToRoute.name);
+ assertType<'test-module'>(resolvedNavigateToRoute.name);
assertType<{
- id: string;
- slug: string;
+ foo: string;
}>(resolvedNavigateToRoute.params);
-
- // @ts-expect-error
- assertType<'admin-id'>(resolvedNavigateToRoute.name);
}
});
diff --git a/test/fixtures/sample-project/tests/[withStrict]/router/useRouter.spec-d.ts b/test/fixtures/sample-project/tests/[withStrict]/router/useRouter.spec-d.ts
new file mode 100644
index 0000000..50d96d6
--- /dev/null
+++ b/test/fixtures/sample-project/tests/[withStrict]/router/useRouter.spec-d.ts
@@ -0,0 +1,89 @@
+import { assertType } from 'vitest';
+import type { TypedRouter } from '@typed-router';
+import { useRouter } from '@typed-router';
+
+// @ts-expect-error Ensure global imports are disabled
+declare const globalDecl: (typeof globalThis)['useRouter'];
+
+// Given
+const router = useRouter();
+
+assertType(router);
+
+// - Usage of useRouter with useRouter
+
+// ! ------ Should Error ❌
+
+// * index.vue
+// @ts-expect-error
+router.push({ name: 'index', params: { id: 1 } });
+// @ts-expect-error
+router.push({ name: 'index', params: { id: 1 } });
+// @ts-expect-error
+router.push({ name: 'blabla-baguette' });
+
+// * --- [id].vue
+// @ts-expect-error
+router.push({ name: 'user-id' });
+// @ts-expect-error
+router.push({ name: 'user-id', params: { foo: 'bar' } });
+
+// * --- [foo]-[[bar]].vue
+// @ts-expect-error
+router.push({ name: 'user-foo-bar' });
+// @ts-expect-error
+router.push({ name: 'user-foo-bar', params: { bar: 1 } });
+
+// * --- [...slug].vue
+// @ts-expect-error
+router.push({ name: 'user-slug' });
+// @ts-expect-error
+router.push({ name: 'user-slug', params: { slug: 1 } });
+
+// * --- [one]-foo-[two].vue
+// @ts-expect-error
+router.push({ name: 'user-one-foo-two' });
+// @ts-expect-error
+router.push({ name: 'user-one-foo-two', params: { one: 1 } });
+
+// * --- [id]/[slug].vue
+// @ts-expect-error
+router.push({ name: 'user-id-slug' });
+// @ts-expect-error
+router.push({ name: 'user-id-slug', params: { id: 1 } });
+
+// * --- Routes added by modules
+// @ts-expect-error
+router.push({ name: 'test-module' });
+
+// $ ----- Should be valid ✅
+
+router.push({ name: 'index' });
+router.push({ name: 'user-id', params: { id: 1 }, hash: 'baz' });
+router.push({ name: 'user-foo-bar', params: { foo: 'bar' }, force: true });
+router.push({ name: 'user-foo-bar', params: { foo: 'bar', bar: 'baz' } });
+router.push({ name: 'user-catch-slug', params: { slug: ['foo'] } });
+router.push({ name: 'user-catch-slug', params: { slug: [1, 2, 3] } });
+router.push({ name: 'user-one-foo-two', params: { one: 1, two: '2' } });
+router.push({ name: 'user-id-slug', params: { slug: '2' }, query: { foo: 'bar' } });
+router.push({ name: 'test-module', params: { foo: 1 }, query: { foo: 'bar' } });
+
+router.replace({ name: 'index' });
+router.replace({ name: 'user-id', params: { id: 1 }, hash: 'baz' });
+
+// --- Path navigation
+
+// ! ------ Should Error ❌
+// @ts-expect-error
+assertType(router.push('/'));
+
+// * Resolved routes
+
+const resolved1 = router.resolve({ name: 'index' });
+assertType<'index'>(resolved1.name);
+// @ts-expect-error
+assertType<'index'>(resolved1.params);
+
+const resolved2 = router.resolve({ name: 'user-id', params: { id: 1 }, hash: 'baz' });
+assertType<'user-id'>(resolved2.name);
+assertType<{ id: string }>(resolved2.params);
diff --git a/test/fixtures/simple/tests/routes/useRoute.spec-d.ts b/test/fixtures/sample-project/tests/[withStrict]/routes/useRoute.spec-d.ts
similarity index 89%
rename from test/fixtures/simple/tests/routes/useRoute.spec-d.ts
rename to test/fixtures/sample-project/tests/[withStrict]/routes/useRoute.spec-d.ts
index 5993a5f..2287c8e 100644
--- a/test/fixtures/simple/tests/routes/useRoute.spec-d.ts
+++ b/test/fixtures/sample-project/tests/[withStrict]/routes/useRoute.spec-d.ts
@@ -72,3 +72,12 @@ if (route.name === 'user-id-slug') {
slug: string;
}>(route.params);
}
+
+// * --- Routes added by modules
+if (route.name === 'test-module') {
+ assertType>(route);
+ assertType<'test-module'>(route.name);
+ assertType<{
+ foo: string;
+ }>(route.params);
+}
diff --git a/test/fixtures/complex/tests/i18n/NuxtLinkLocale.spec-d.ts b/test/fixtures/sample-project/tests/i18n/NuxtLinkLocale.spec-d.ts
similarity index 100%
rename from test/fixtures/complex/tests/i18n/NuxtLinkLocale.spec-d.ts
rename to test/fixtures/sample-project/tests/i18n/NuxtLinkLocale.spec-d.ts
diff --git a/test/fixtures/complex/tests/i18n/useLocalePath.spec-d.ts b/test/fixtures/sample-project/tests/i18n/useLocalePath.spec-d.ts
similarity index 100%
rename from test/fixtures/complex/tests/i18n/useLocalePath.spec-d.ts
rename to test/fixtures/sample-project/tests/i18n/useLocalePath.spec-d.ts
diff --git a/test/fixtures/complex/tests/i18n/useLocaleRoute.spec-d.ts b/test/fixtures/sample-project/tests/i18n/useLocaleRoute.spec-d.ts
similarity index 100%
rename from test/fixtures/complex/tests/i18n/useLocaleRoute.spec-d.ts
rename to test/fixtures/sample-project/tests/i18n/useLocaleRoute.spec-d.ts
diff --git a/test/fixtures/complex/tsconfig.json b/test/fixtures/sample-project/tsconfig.json
similarity index 100%
rename from test/fixtures/complex/tsconfig.json
rename to test/fixtures/sample-project/tsconfig.json
diff --git a/test/fixtures/simple/.gitignore b/test/fixtures/simple/.gitignore
deleted file mode 100644
index 438cb08..0000000
--- a/test/fixtures/simple/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-node_modules
-*.log*
-.nuxt
-.nitro
-.cache
-.output
-.env
-dist
diff --git a/test/fixtures/simple/README.md b/test/fixtures/simple/README.md
deleted file mode 100644
index c699c96..0000000
--- a/test/fixtures/simple/README.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Nuxt 3 Minimal Starter
-
-Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
-
-## Setup
-
-Make sure to install the dependencies:
-
-```bash
-# yarn
-yarn install
-
-# npm
-npm install
-
-# pnpm
-pnpm install
-```
-
-## Development Server
-
-Start the development server on http://localhost:3000
-
-```bash
-npm run dev
-```
-
-## Production
-
-Build the application for production:
-
-```bash
-npm run build
-```
-
-Locally preview production build:
-
-```bash
-npm run preview
-```
-
-Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
diff --git a/test/fixtures/simple/app.vue b/test/fixtures/simple/app.vue
deleted file mode 100644
index 01b7bef..0000000
--- a/test/fixtures/simple/app.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/test/fixtures/simple/nuxt.config.ts b/test/fixtures/simple/nuxt.config.ts
deleted file mode 100644
index a278ee6..0000000
--- a/test/fixtures/simple/nuxt.config.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export default defineNuxtConfig({
- modules: ['nuxt-typed-router'],
- vite: {
- resolve: {
- dedupe: ['vue-router'],
- },
- },
-});
diff --git a/test/fixtures/simple/package.json b/test/fixtures/simple/package.json
deleted file mode 100644
index ca2431f..0000000
--- a/test/fixtures/simple/package.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "private": true,
- "name": "simple",
- "version": "1.0.0",
- "scripts": {
- "build": "nuxt build",
- "dev": "nuxt dev",
- "generate": "nuxt generate",
- "preview": "nuxt preview"
- },
- "devDependencies": {
- "nuxt": "^3.8.2",
- "vue": "3.3.10",
- "nuxt-typed-router": "workspace:*"
- }
-}
diff --git a/test/fixtures/simple/pages/admin.vue b/test/fixtures/simple/pages/admin.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/admin.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/admin/[id]/action-[slug].vue b/test/fixtures/simple/pages/admin/[id]/action-[slug].vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/admin/[id]/action-[slug].vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/admin/[id]/index.vue b/test/fixtures/simple/pages/admin/[id]/index.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/admin/[id]/index.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/admin/[id]/profile.vue b/test/fixtures/simple/pages/admin/[id]/profile.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/admin/[id]/profile.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/admin/[id]/settings.vue b/test/fixtures/simple/pages/admin/[id]/settings.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/admin/[id]/settings.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/admin/panel/[[blou]].vue b/test/fixtures/simple/pages/admin/panel/[[blou]].vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/admin/panel/[[blou]].vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/baguette.vue b/test/fixtures/simple/pages/baguette.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/baguette.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/user/[foo]-[[bar]].vue b/test/fixtures/simple/pages/user/[foo]-[[bar]].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/simple/pages/user/[foo]-[[bar]].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/simple/pages/user/[id].vue b/test/fixtures/simple/pages/user/[id].vue
deleted file mode 100644
index 094637f..0000000
--- a/test/fixtures/simple/pages/user/[id].vue
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/test/fixtures/simple/pages/user/[id]/[slug].vue b/test/fixtures/simple/pages/user/[id]/[slug].vue
deleted file mode 100644
index 094637f..0000000
--- a/test/fixtures/simple/pages/user/[id]/[slug].vue
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/test/fixtures/simple/pages/user/[id]/[slug]/articles.vue b/test/fixtures/simple/pages/user/[id]/[slug]/articles.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/user/[id]/[slug]/articles.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/user/[id]/[slug]/index.vue b/test/fixtures/simple/pages/user/[id]/[slug]/index.vue
deleted file mode 100644
index 9070ec8..0000000
--- a/test/fixtures/simple/pages/user/[id]/[slug]/index.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Navigate back
-
diff --git a/test/fixtures/simple/pages/user/[id]/index.vue b/test/fixtures/simple/pages/user/[id]/index.vue
deleted file mode 100644
index 2504a8a..0000000
--- a/test/fixtures/simple/pages/user/[id]/index.vue
+++ /dev/null
@@ -1 +0,0 @@
-Youhou
diff --git a/test/fixtures/simple/pages/user/[id]/posts.vue b/test/fixtures/simple/pages/user/[id]/posts.vue
deleted file mode 100644
index 094637f..0000000
--- a/test/fixtures/simple/pages/user/[id]/posts.vue
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/test/fixtures/simple/pages/user/[one]-foo-[two].vue b/test/fixtures/simple/pages/user/[one]-foo-[two].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/simple/pages/user/[one]-foo-[two].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/simple/pages/user/catch/[...slug].vue b/test/fixtures/simple/pages/user/catch/[...slug].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/simple/pages/user/catch/[...slug].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/simple/pages/user/index.vue b/test/fixtures/simple/pages/user/index.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/simple/pages/user/index.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/simple/pages/user/test-[[optional]].vue b/test/fixtures/simple/pages/user/test-[[optional]].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/simple/pages/user/test-[[optional]].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/simple/tests/router/useRouter.spec-d.ts b/test/fixtures/simple/tests/router/useRouter.spec-d.ts
deleted file mode 100644
index 09aa5a6..0000000
--- a/test/fixtures/simple/tests/router/useRouter.spec-d.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-import { assertType } from 'vitest';
-import test from 'node:test';
-import type { TypedRouter } from '@typed-router';
-
-// Given
-const router = useRouter();
-
-assertType(router);
-
-// - Usage of useRouter with useRouter
-
-// ! ------ Should Error ❌
-
-// * index.vue
-// @ts-expect-error
-router.push({ name: 'index', params: { id: 1 } });
-// @ts-expect-error
-router.push({ name: 'index', params: { id: 1 } });
-// @ts-expect-error
-router.push({ name: 'blabla-baguette' });
-
-// * --- [id].vue
-// @ts-expect-error
-router.push({ name: 'user-id' });
-// @ts-expect-error
-router.push({ name: 'user-id', params: { foo: 'bar' } });
-
-// * --- [foo]-[[bar]].vue
-// @ts-expect-error
-router.push({ name: 'user-foo-bar' });
-// @ts-expect-error
-router.push({ name: 'user-foo-bar', params: { bar: 1 } });
-
-// * --- [...slug].vue
-// @ts-expect-error
-router.push({ name: 'user-slug' });
-// @ts-expect-error
-router.push({ name: 'user-slug', params: { slug: 1 } });
-
-// * --- [one]-foo-[two].vue
-// @ts-expect-error
-router.push({ name: 'user-one-foo-two' });
-// @ts-expect-error
-router.push({ name: 'user-one-foo-two', params: { one: 1 } });
-
-// * --- [id]/[slug].vue
-// @ts-expect-error
-router.push({ name: 'user-id-slug' });
-// @ts-expect-error
-router.push({ name: 'user-id-slug', params: { id: 1 } });
-
-// * --- Routes added by modules
-// @ts-expect-error
-router.push({ name: 'test-module' });
-
-// * --- Path navigation
-// @ts-expect-error
-router.push('/fooooooooooo');
-// @ts-expect-error
-router.push({ path: '/foo' });
-
-// $ ----- Should be valid ✅
-
-router.push({ name: 'index' });
-router.push({ name: 'user-id', params: { id: 1 }, hash: 'baz' });
-router.push({ name: 'user-foo-bar', params: { foo: 'bar' }, force: true });
-router.push({ name: 'user-foo-bar', params: { foo: 'bar', bar: 'baz' } });
-router.push({ name: 'user-catch-slug', params: { slug: ['foo'] } });
-router.push({ name: 'user-catch-slug', params: { slug: [1, 2, 3] } });
-router.push({ name: 'user-one-foo-two', params: { one: 1, two: '2' } });
-router.push({ name: 'user-id-slug', params: { slug: '2' }, query: { foo: 'bar' } });
-
-router.replace({ name: 'index' });
-router.replace({ name: 'user-id', params: { id: 1 }, hash: 'baz' });
-router.replace('/admin');
-
-// --- Path navigation
-
-// ! ------ Should Error ❌
-
-// @ts-expect-error
-assertType(router.push(''));
-// @ts-expect-error
-assertType(router.push('/admin '));
-// @ts-expect-error
-assertType(router.push('/admin/ /'));
-// @ts-expect-error
-assertType(router.push(`/ / // / / eefzr`));
-// @ts-expect-error
-assertType(router.push('/elzhlzehflzhef'));
-// @ts-expect-error
-assertType(router.push('/admin/foo/bar'));
-// @ts-expect-error
-assertType(router.push('/admin/foo/bar/baz'));
-// @ts-expect-error
-assertType(router.push(`/admin/${id}/action-bar/taz?query`));
-// @ts-expect-error
-assertType(router.push('/admin/panel/3O9393/bar'));
-// @ts-expect-error
-assertType(router.push('/admin/foo/ profile/ezfje'));
-// @ts-expect-error
-assertType(router.push('/admin/3U93U/settings/baz'));
-// @ts-expect-error
-assertType(router.push('/admin/panel/?fjzk'));
-
-// $ ----- Should be valid ✅
-
-const id = '38789803';
-assertType(router.push('/'));
-assertType(router.push('/baguette'));
-assertType(router.push('/admin/foo'));
-assertType(router.push('/admin/foo/'));
-assertType(router.push(`/admin/${id}/action-bar#hash`));
-assertType(router.push(`/admin/${id}/action-bar?query=bar`));
-assertType(router.push('/admin/foo/profile/'));
-assertType(router.push(`/admin/${id}/settings`));
-assertType(router.push('/admin/panel/'));
-assertType(router.push('/admin/panel/938783/'));
-assertType(router.push('/user/38873-'));
-assertType(router.push('/user/38673/bar/#hash'));
-assertType(router.push('/user/ç9737/foo/articles?baz=foo'));
-assertType(router.push('/user/catch/1/2'));
-assertType(router.push('/user/test-'));
-assertType(router.push('/user'));
-
-// * Resolved routes
-
-test('', () => {
- const resolved = router.resolve({ name: 'index' });
- assertType<'index'>(resolved.name);
- // @ts-expect-error
- assertType<'index'>(resolved.params);
-});
-
-test('', () => {
- const resolved = router.resolve({ name: 'user-id', params: { id: 1 }, hash: 'baz' });
- assertType<'user-id'>(resolved.name);
- assertType<{ id: string }>(resolved.params);
-
- // @ts-expect-error
- assertType<'user-eojzpejfze'>(resolved.name);
-});
-
-test('', () => {
- const resolved = router.resolve('/admin/foo/');
- assertType<'admin-id'>(resolved.name);
- assertType<{ id: string }>(resolved.params);
-
- // @ts-expect-error
- assertType<'jzeifjlfej'>(resolved.name);
- // @ts-expect-error
- assertType<{ foo: string }>(resolved.params);
-});
diff --git a/test/fixtures/simple/tests/routes/useLink.spec-d.ts b/test/fixtures/simple/tests/routes/useLink.spec-d.ts
deleted file mode 100644
index 04eb3c4..0000000
--- a/test/fixtures/simple/tests/routes/useLink.spec-d.ts
+++ /dev/null
@@ -1,245 +0,0 @@
-import { assertType, test } from 'vitest';
-import type { LocationQuery } from 'vue-router';
-
-// ! ------ Should Error ❌
-
-// * index.vue
-// @ts-expect-error
-useLink({ to: { name: 'index', params: { id: 1 } } });
-// @ts-expect-error
-useLink({ to: { name: 'index', params: { id: 1 } } });
-// @ts-expect-error
-useLink({ to: { name: 'blabla-baguette' } });
-
-// * --- [id].vue
-// @ts-expect-error
-useLink({ to: { name: 'user-id' } });
-// @ts-expect-error
-useLink({ to: { name: 'user-id', params: { foo: 'bar' } } });
-
-// * --- [foo]-[[bar]].vue
-// @ts-expect-error
-useLink({ to: { name: 'user-foo-bar' } });
-// @ts-expect-error
-useLink({ to: { name: 'user-foo-bar', params: { bar: 1 } } });
-
-// * --- [...slug].vue
-// @ts-expect-error
-useLink({ to: { name: 'user-catch-slug' } });
-// @ts-expect-error
-useLink({ to: { name: 'user-catch-slug', params: { slug: 1 } } });
-
-// * --- [one]-foo-[two].vue
-// @ts-expect-error
-useLink({ to: { name: 'user-one-foo-two' } });
-// @ts-expect-error
-useLink({ to: { name: 'user-one-foo-two', params: { one: 1 } } });
-
-// * --- [id]/[slug].vue
-// @ts-expect-error
-useLink({ to: { name: 'user-id-slug' } });
-// @ts-expect-error
-useLink({ to: { name: 'user-id-slug', params: { id: 1 } } });
-
-// * --- Routes added by modules
-// @ts-expect-error
-useLink({ to: { name: 'test-module' } });
-
-// $ ----- Should be valid ✅
-
-useLink({ to: { name: 'index' } });
-useLink({ to: { name: 'user-id', params: { id: 1 }, hash: 'baz' } });
-useLink({ to: { name: 'user-foo-bar', params: { foo: 'bar' }, force: true } });
-useLink({ to: { name: 'user-foo-bar', params: { foo: 'bar', bar: 'baz' } } });
-useLink({ to: { name: 'user-catch-slug', params: { slug: ['foo'] } } });
-useLink({ to: { name: 'user-catch-slug', params: { slug: [1, 2, 3] } } });
-useLink({ to: { name: 'user-one-foo-two', params: { one: 1, two: '2' } } });
-useLink({ to: { name: 'user-id-slug', params: { slug: '2' }, query: { foo: 'bar' } } });
-
-// --- Path navigation
-
-// ! ------ Should Error ❌
-
-// @ts-expect-error
-assertType(useLink({ to: '' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin ' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/ /' }));
-// @ts-expect-error
-assertType(useLink({ to: `/ / // / / eefzr` }));
-// @ts-expect-error
-assertType(useLink({ to: '/elzhlzehflzhef' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/foo/bar' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/foo/bar/baz' }));
-// @ts-expect-error
-assertType(useLink({ to: `/admin/${id}/action-bar/taz?query` }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/panel/3O9393/bar' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/foo/ profile/ezfje' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/3U93U/settings/baz' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/panel/?fjzk' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/panel/938783/ ' }));
-// @ts-expect-error
-assertType(useLink({ to: '/user/3887/foo/bar/' }));
-// @ts-expect-error
-assertType(useLink({ to: '/admin/:id//' }));
-
-// $ ----- Should be valid ✅
-
-const id = '38789803';
-assertType(useLink({ to: '/' }));
-assertType(useLink({ to: '/baguette' }));
-assertType(useLink({ to: '/admin/foo' }));
-assertType(useLink({ to: '/admin/foo/' }));
-assertType(useLink({ to: `/admin/${id}/action-bar#hash` }));
-assertType(useLink({ to: `/admin/${id}/action-bar?query=bar` }));
-assertType(useLink({ to: '/admin/foo/profile/' }));
-assertType(useLink({ to: `/admin/${id}/settings` }));
-assertType(useLink({ to: '/admin/panel/' }));
-assertType(useLink({ to: '/admin/panel/938783/' }));
-assertType(useLink({ to: '/user/38873-' }));
-assertType(useLink({ to: '/user/38673/bar/#hash' }));
-assertType(useLink({ to: '/user/ç9737/foo/articles?baz=foo' }));
-assertType(useLink({ to: '/user/catch/1/2' }));
-assertType(useLink({ to: '/user/test-' }));
-assertType(useLink({ to: '/user' }));
-
-// - Resolved routes
-
-// * index.vue
-test('', async () => {
- const resolvedNavigateToRoute = useLink({
- to: {
- name: 'index',
- },
- });
-
- if (resolvedNavigateToRoute) {
- assertType<'index'>(resolvedNavigateToRoute.route.value.name);
- // @ts-expect-error
- assertType(resolvedNavigateToRoute.params);
- }
-});
-
-// * --- [id].vue
-test('', async () => {
- const resolvedNavigateToRoute = await useLink({
- to: {
- name: 'user-id',
- params: {
- id: 1,
- },
- },
- });
-
- if (resolvedNavigateToRoute) {
- assertType<'user-id'>(resolvedNavigateToRoute.route.value.name);
- assertType<{
- id: string;
- }>(resolvedNavigateToRoute.route.value.params);
- }
-});
-
-// * --- [foo]-[[bar]].vue
-test('', async () => {
- const resolvedNavigateToRoute = await useLink({
- to: {
- name: 'user-foo-bar',
- params: {
- foo: 1,
- bar: 1,
- },
- },
- });
-
- if (resolvedNavigateToRoute) {
- assertType<'user-foo-bar'>(resolvedNavigateToRoute.route.value.name);
- assertType<{
- foo: string;
- bar?: string | undefined;
- }>(resolvedNavigateToRoute.route.value.params);
- }
-});
-
-// * --- [...slug].vue
-test('', async () => {
- const resolvedNavigateToRoute = await useLink({
- to: {
- name: 'user-catch-slug',
- params: {
- slug: [1, 2, 3],
- },
- },
- });
-
- if (resolvedNavigateToRoute) {
- assertType<'user-catch-slug'>(resolvedNavigateToRoute.route.value.name);
- assertType<{
- slug: string[];
- }>(resolvedNavigateToRoute.route.value.params);
- }
-});
-
-// * --- [one]-foo-[two].vue
-
-const resolvedNavigateToRoute = await useLink({
- to: {
- name: 'user-one-foo-two',
- params: { one: 1, two: 2 },
- },
-});
-
-if (resolvedNavigateToRoute) {
- assertType<'user-one-foo-two'>(resolvedNavigateToRoute.route.value.name);
- assertType<{
- one: string | number;
- two: string | number;
- }>(resolvedNavigateToRoute.route.value.params);
- assertType(resolvedNavigateToRoute.route.value.query);
-}
-
-// * --- [id]/[slug].vue
-test('', async () => {
- const resolvedNavigateToRoute = await useLink({
- to: {
- name: 'user-id-slug',
- params: {
- slug: 1,
- id: 1,
- },
- },
- });
-
- if (resolvedNavigateToRoute) {
- assertType<'user-id-slug'>(resolvedNavigateToRoute.route.value.name);
- assertType<{
- id: string;
- slug: string;
- }>(resolvedNavigateToRoute.route.value.params);
- }
-});
-
-// - With paths
-
-// * --- [foo]-[[bar]].vue
-test('', async () => {
- const resolvedNavigateToRoute = await useLink({ to: '/admin/3883/action-376773' });
-
- if (resolvedNavigateToRoute) {
- assertType<'admin-id-action-slug'>(resolvedNavigateToRoute.route.value.name);
- assertType<{
- id: string;
- slug: string;
- }>(resolvedNavigateToRoute.route.value.params);
-
- // @ts-expect-error
- assertType<'admin-id'>(resolvedNavigateToRoute.route.value.name);
- }
-});
diff --git a/test/fixtures/simple/tsconfig.json b/test/fixtures/simple/tsconfig.json
deleted file mode 100644
index 3c61969..0000000
--- a/test/fixtures/simple/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- // https://nuxt.com/docs/guide/concepts/typescript
- "extends": "./.nuxt/tsconfig.json",
- "compilerOptions": {
- "verbatimModuleSyntax": false
- }
-}
diff --git a/test/fixtures/withOptions/.gitignore b/test/fixtures/withOptions/.gitignore
deleted file mode 100644
index 438cb08..0000000
--- a/test/fixtures/withOptions/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-node_modules
-*.log*
-.nuxt
-.nitro
-.cache
-.output
-.env
-dist
diff --git a/test/fixtures/withOptions/README.md b/test/fixtures/withOptions/README.md
deleted file mode 100644
index c699c96..0000000
--- a/test/fixtures/withOptions/README.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Nuxt 3 Minimal Starter
-
-Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
-
-## Setup
-
-Make sure to install the dependencies:
-
-```bash
-# yarn
-yarn install
-
-# npm
-npm install
-
-# pnpm
-pnpm install
-```
-
-## Development Server
-
-Start the development server on http://localhost:3000
-
-```bash
-npm run dev
-```
-
-## Production
-
-Build the application for production:
-
-```bash
-npm run build
-```
-
-Locally preview production build:
-
-```bash
-npm run preview
-```
-
-Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
diff --git a/test/fixtures/withOptions/app.vue b/test/fixtures/withOptions/app.vue
deleted file mode 100644
index 01b7bef..0000000
--- a/test/fixtures/withOptions/app.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/test/fixtures/withOptions/nuxt.config.ts b/test/fixtures/withOptions/nuxt.config.ts
deleted file mode 100644
index 658a9f2..0000000
--- a/test/fixtures/withOptions/nuxt.config.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import NuxtTypedRouter from '../../..';
-
-export default defineNuxtConfig({
- modules: [NuxtTypedRouter],
- vite: {
- resolve: {
- dedupe: ['vue-router'],
- },
- },
-});
diff --git a/test/fixtures/withOptions/package.json b/test/fixtures/withOptions/package.json
deleted file mode 100644
index b856c02..0000000
--- a/test/fixtures/withOptions/package.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "private": true,
- "name": "with-options",
- "version": "1.0.0",
- "scripts": {
- "build": "nuxt build",
- "dev": "nuxt dev",
- "generate": "nuxt generate",
- "preview": "nuxt preview"
- },
- "devDependencies": {
- "nuxt": "3.8.2",
- "nuxt-typed-router": "workspace:*"
- }
-}
diff --git a/test/fixtures/withOptions/pages/index.vue b/test/fixtures/withOptions/pages/index.vue
deleted file mode 100644
index e3a145e..0000000
--- a/test/fixtures/withOptions/pages/index.vue
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
diff --git a/test/fixtures/withOptions/pages/user/[...slug].vue b/test/fixtures/withOptions/pages/user/[...slug].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/withOptions/pages/user/[...slug].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/withOptions/pages/user/[foo]-[[bar]].vue b/test/fixtures/withOptions/pages/user/[foo]-[[bar]].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/withOptions/pages/user/[foo]-[[bar]].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/withOptions/pages/user/[id].vue b/test/fixtures/withOptions/pages/user/[id].vue
deleted file mode 100644
index 094637f..0000000
--- a/test/fixtures/withOptions/pages/user/[id].vue
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/test/fixtures/withOptions/pages/user/[id]/[slug].vue b/test/fixtures/withOptions/pages/user/[id]/[slug].vue
deleted file mode 100644
index 094637f..0000000
--- a/test/fixtures/withOptions/pages/user/[id]/[slug].vue
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/test/fixtures/withOptions/pages/user/[id]/[slug]/articles.vue b/test/fixtures/withOptions/pages/user/[id]/[slug]/articles.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/withOptions/pages/user/[id]/[slug]/articles.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/withOptions/pages/user/[id]/[slug]/index.vue b/test/fixtures/withOptions/pages/user/[id]/[slug]/index.vue
deleted file mode 100644
index 9070ec8..0000000
--- a/test/fixtures/withOptions/pages/user/[id]/[slug]/index.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Navigate back
-
diff --git a/test/fixtures/withOptions/pages/user/[id]/index.vue b/test/fixtures/withOptions/pages/user/[id]/index.vue
deleted file mode 100644
index 2504a8a..0000000
--- a/test/fixtures/withOptions/pages/user/[id]/index.vue
+++ /dev/null
@@ -1 +0,0 @@
-Youhou
diff --git a/test/fixtures/withOptions/pages/user/[id]/posts.vue b/test/fixtures/withOptions/pages/user/[id]/posts.vue
deleted file mode 100644
index 094637f..0000000
--- a/test/fixtures/withOptions/pages/user/[id]/posts.vue
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/test/fixtures/withOptions/pages/user/[one]-foo-[two].vue b/test/fixtures/withOptions/pages/user/[one]-foo-[two].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/withOptions/pages/user/[one]-foo-[two].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/withOptions/pages/user/index.vue b/test/fixtures/withOptions/pages/user/index.vue
deleted file mode 100644
index 7dcf98f..0000000
--- a/test/fixtures/withOptions/pages/user/index.vue
+++ /dev/null
@@ -1 +0,0 @@
-H1
diff --git a/test/fixtures/withOptions/pages/user/test-[[optional]].vue b/test/fixtures/withOptions/pages/user/test-[[optional]].vue
deleted file mode 100644
index 87ac15c..0000000
--- a/test/fixtures/withOptions/pages/user/test-[[optional]].vue
+++ /dev/null
@@ -1 +0,0 @@
-test
diff --git a/test/fixtures/withOptions/tests/e2e/withPartialStrict.spec.ts b/test/fixtures/withOptions/tests/e2e/withPartialStrict.spec.ts
deleted file mode 100644
index b3dda7e..0000000
--- a/test/fixtures/withOptions/tests/e2e/withPartialStrict.spec.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-test('empty')
-
-// import { fileURLToPath } from 'node:url';
-// import { setup } from '@nuxt/test-utils';
-// import { assertType } from 'vitest';
-// import { useRouter } from '../../.nuxt/typed-router';
-// import type { TypedNuxtLink } from '../../.nuxt/typed-router/typed-router';
-
-// test.skip('The strict option should behave correctly with partial strict options', async () => {
-// await setup({
-// rootDir: fileURLToPath(new URL('../../fixtures/withOptions', import.meta.url)),
-// setupTimeout: 120000,
-// nuxtConfig: {
-// nuxtTypedRouter: {
-// strict: {
-// NuxtLink: {
-// strictRouteLocation: true,
-// },
-// router: {
-// strictToArgument: true,
-// },
-// },
-// },
-// },
-// } as any);
-
-// // const diagnostic = await runTypesDiagnostics(__dirname, __filename);
-
-// // expect(diagnostic.length).toBe(0);
-
-// const NuxtLink: TypedNuxtLink = vi.fn() as any;
-
-// const router = { push: vi.fn() } as unknown as ReturnType;
-
-// assertType(router.push('/user'));
-// // @ts-expect-error
-// assertType(router.push({ path: '/login' }));
-
-// // @ts-expect-error
-// assertType(new NuxtLink('/user'));
-// assertType(new NuxtLink({ to: { path: '/user' } }));
-// });
diff --git a/test/fixtures/withOptions/tests/e2e/withStrict.spec.ts b/test/fixtures/withOptions/tests/e2e/withStrict.spec.ts
deleted file mode 100644
index 2c105e8..0000000
--- a/test/fixtures/withOptions/tests/e2e/withStrict.spec.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-test('empty')
-// import { setup } from '@nuxt/test-utils';
-// import { fileURLToPath } from 'node:url';
-// import { assertType } from 'vitest';
-// import { useRouter } from '../../.nuxt/typed-router';
-// import type { TypedNuxtLink } from '../../.nuxt/typed-router/typed-router';
-
-// test.skip('The strict option should behave correctly with strict: true', async () => {
-// await setup({
-// rootDir: fileURLToPath(new URL('../../fixtures/withOptions', import.meta.url)),
-// setupTimeout: 120000,
-// nuxtConfig: {
-// nuxtTypedRouter: {
-// strict: true,
-// },
-// },
-// } as any);
-
-// // const diagnostic = await runTypesDiagnostics(__dirname, __filename);
-
-// // expect(diagnostic.length).toBe(0);
-
-// const NuxtLink: TypedNuxtLink = vi.fn() as any;
-
-// const router = { push: vi.fn() } as unknown as ReturnType;
-
-// // @ts-expect-error
-// assertType(router.push('/foo'));
-// // @ts-expect-error
-// assertType(router.push({ path: '/login' }));
-
-// // @ts-expect-error
-// assertType(new NuxtLink('/login'));
-// // @ts-expect-error
-// assertType(new NuxtLink({ path: '/goooo' }));
-// });
-
diff --git a/test/fixtures/withOptions/tsconfig.json b/test/fixtures/withOptions/tsconfig.json
deleted file mode 100644
index 2c90bb7..0000000
--- a/test/fixtures/withOptions/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "extends": "./.nuxt/tsconfig.json",
- "compilerOptions": {
- "types": ["vitest/globals"]
- }
-}
diff --git a/test/samples-config/classic.ts b/test/samples-config/classic.ts
new file mode 100644
index 0000000..ccac3ac
--- /dev/null
+++ b/test/samples-config/classic.ts
@@ -0,0 +1,5 @@
+import { NuxtConfig } from '@nuxt/schema';
+
+const config: NuxtConfig = {};
+
+export default config;
diff --git a/test/samples-config/withPlugin.ts b/test/samples-config/withPlugin.ts
new file mode 100644
index 0000000..51bada2
--- /dev/null
+++ b/test/samples-config/withPlugin.ts
@@ -0,0 +1,8 @@
+import { NuxtConfig } from '@nuxt/schema';
+
+const config: NuxtConfig = {
+ nuxtTypedRouter: {
+ plugin: true,
+ },
+};
+export default config;
diff --git a/test/samples-config/withStrict.ts b/test/samples-config/withStrict.ts
new file mode 100644
index 0000000..330156b
--- /dev/null
+++ b/test/samples-config/withStrict.ts
@@ -0,0 +1,8 @@
+import { NuxtConfig } from '@nuxt/schema';
+
+const config: NuxtConfig = {
+ nuxtTypedRouter: {
+ strict: true,
+ },
+};
+export default config;
diff --git a/test/unit/setupTypeTest.ts b/test/unit/setupTypeTest.ts
new file mode 100644
index 0000000..5196dd3
--- /dev/null
+++ b/test/unit/setupTypeTest.ts
@@ -0,0 +1,11 @@
+import { timeout } from '$$/utils';
+import { $ } from 'zx';
+
+export async function setupNuxtTestWithConfig(configName: string) {
+ try {
+ await $`NUXT_ROUTER_CONFIG_NAME=${configName} pnpm run test:types-fixtures`;
+ await timeout(100);
+ } catch (e) {
+ return Promise.reject(`Typecheck failed for config: [${configName}]: ${e}`);
+ }
+}
diff --git a/test/unit/unitTestAllConfigs.spec.ts b/test/unit/unitTestAllConfigs.spec.ts
new file mode 100644
index 0000000..11a5292
--- /dev/null
+++ b/test/unit/unitTestAllConfigs.spec.ts
@@ -0,0 +1,15 @@
+import path from 'path';
+import { setupNuxtTestWithConfig } from './setupTypeTest';
+import { globby } from 'globby';
+
+describe.sequential('Testing types with different configs', async () => {
+ try {
+ const allConfigs = await globby('test/samples-config', { absolute: false });
+ for (let config of allConfigs) {
+ const configFileName = path.parse(config).name;
+ await setupNuxtTestWithConfig(configFileName);
+ }
+ } catch (e: any) {
+ throw new Error(e);
+ }
+});
diff --git a/test/utils/index.ts b/test/utils/index.ts
index 7da0ba4..ee894da 100644
--- a/test/utils/index.ts
+++ b/test/utils/index.ts
@@ -1,6 +1,26 @@
-export * from './tsd.utils';
-export * from './typecheck';
+import type { NuxtConfig } from '@nuxt/schema';
+import { globbySync } from 'globby';
export function timeout(count: number) {
return new Promise((resolve) => setTimeout(resolve, count));
}
+
+export function getConfigFromName(configName: string, config: NuxtConfig): NuxtConfig {
+ const files = globbySync(`test/fixtures/sample-project/tests/[${configName}]`);
+ return {
+ ...config,
+ nuxtTypedRouter: {
+ ...config.nuxtTypedRouter,
+ ignoreRoutes: ['[...404].vue', '[tests]/**/*.vue'],
+ },
+ typescript: {
+ tsConfig: {
+ files: [
+ ...files.map((m) => m.replace('test/fixtures/sample-project', '..')),
+ `../src/pages/[tests]/[${configName}].vue`,
+ ],
+ exclude: ['../tests/**/*', '../src/pages/[tests]/**/*.vue'],
+ },
+ },
+ };
+}
diff --git a/test/utils/tsd.utils.ts b/test/utils/tsd.utils.ts
deleted file mode 100644
index c9fdc10..0000000
--- a/test/utils/tsd.utils.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import path from 'path';
-import tsd from 'tsd';
-
-export async function runTypesDiagnostics(dirName: string, fileName: string) {
- const diagnostic = await tsd({
- cwd: dirName,
- testFiles: [path.basename(fileName)],
- typingsFile: `./${path.basename(fileName)}`,
- });
-
- if (diagnostic.length) {
- console.error(
- diagnostic.map(
- (m) => `Error in file ${m.fileName}:${m.line}:${m.column}:
- ${m.message}`
- )
- );
- }
-
- return diagnostic;
-}
diff --git a/test/utils/typecheck.ts b/test/utils/typecheck.ts
deleted file mode 100644
index e13fb6a..0000000
--- a/test/utils/typecheck.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-// Check required param
-export function required(arg: string) {}
-
-// Check optional param
-export function optional(arg: undefined extends T ? T : never) {}
-
-// Check array params
-export function array(arg: string[]) {}
diff --git a/vercel.json b/vercel.json
new file mode 100644
index 0000000..7ae9a3d
--- /dev/null
+++ b/vercel.json
@@ -0,0 +1,5 @@
+{
+ "github": {
+ "silent": true
+ }
+}
diff --git a/vite.config.ts b/vite.config.ts
index 71af7e8..dfc7885 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -4,8 +4,18 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
- testTimeout: 10000,
- threads: false,
+ passWithNoTests: true,
+ pool: 'forks',
+ poolOptions: {
+ forks: {
+ singleFork: true,
+ },
+ },
+ sequence: {
+ concurrent: false,
+ hooks: 'list',
+ setupFiles: 'list',
+ },
},
resolve: {
alias: {