Skip to content

Commit 533fa36

Browse files
committed
refactor: Vue SFC type resolution during module build
Addresses an issue where the Vue SFC transformer couldn't resolve imported types from 'nuxt-users/utils' during the module build process. This commit defines Props interfaces inline within the Vue components to ensure compatibility and proper type resolution during the module build.
1 parent 0a3d443 commit 533fa36

File tree

6 files changed

+43
-11
lines changed

6 files changed

+43
-11
lines changed

src/runtime/components/NUsersList.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { ref, onMounted } from 'vue'
33
import { useRuntimeConfig } from '#imports'
4-
import { defaultDisplayFields, defaultFieldLabels, type DisplayFieldsProps, type User } from 'nuxt-users/utils'
4+
import { defaultDisplayFields, defaultFieldLabels, type User } from 'nuxt-users/utils'
55
66
interface Pagination {
77
page: number
@@ -17,7 +17,14 @@ interface UsersResponse {
1717
pagination: Pagination
1818
}
1919
20-
withDefaults(defineProps<DisplayFieldsProps>(), {
20+
// Note: We define Props interface inline instead of importing DisplayFieldsProps from 'nuxt-users/utils'
21+
// because the Vue SFC transformer cannot resolve these imported types during the module build process
22+
interface Props {
23+
displayFields?: string[]
24+
fieldLabels?: Record<string, string>
25+
}
26+
27+
withDefaults(defineProps<Props>(), {
2128
displayFields: () => defaultDisplayFields,
2229
fieldLabels: () => defaultFieldLabels
2330
})

src/runtime/components/NUsersLoginForm.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
<script setup lang="ts">
22
import { ref, computed } from 'vue'
33
import { navigateTo } from '#app'
4-
import type { LoginFormData, LoginFormProps, UserWithoutPassword, ModuleOptions } from 'nuxt-users/utils'
4+
import type { LoginFormData, UserWithoutPassword, ModuleOptions } from 'nuxt-users/utils'
55
import { useRuntimeConfig } from '#imports'
66
77
const { public: { nuxtUsers } } = useRuntimeConfig()
88
const { passwordValidation } = nuxtUsers as ModuleOptions
99
10+
// Note: We define Props interface inline instead of importing LoginFormProps from 'nuxt-users/utils'
11+
// because the Vue SFC transformer cannot resolve these imported types during the module build process
12+
interface Props {
13+
apiEndpoint?: string
14+
forgotPasswordEndpoint?: string
15+
redirectTo?: string
16+
}
17+
1018
interface Emits {
1119
(e: 'success', user: UserWithoutPassword): void
1220
(e: 'error' | 'forgot-password-error', error: string): void
1321
(e: 'submit', data: LoginFormData): void
1422
(e: 'forgot-password-success'): void
1523
}
1624
17-
const props = defineProps<LoginFormProps>()
25+
const props = defineProps<Props>()
1826
1927
const emit = defineEmits<Emits>()
2028

src/runtime/components/NUsersPasswordStrengthIndicator.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script setup lang="ts">
22
import { computed } from 'vue'
3-
import type { PasswordValidationResult } from '../../utils'
3+
import type { PasswordValidationResult } from 'nuxt-users/utils'
44
import { useRuntimeConfig } from '#imports'
55
import type { ModuleOptions } from 'nuxt-users/utils'
66
7+
// Note: We define Props interface inline to ensure compatibility during the module build process
78
interface Props {
89
password: string
910
validationResult: PasswordValidationResult | null

src/runtime/components/NUsersResetPasswordForm.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@
1111
* For password change: requires user to be logged in and provide current password
1212
*/
1313
import { ref, watch, computed } from 'vue'
14-
import type { UserWithoutPassword, ModuleOptions, ResetPasswordFormProps } from 'nuxt-users/utils'
14+
import type { UserWithoutPassword, ModuleOptions } from 'nuxt-users/utils'
1515
import { usePasswordValidation } from '../composables/usePasswordValidation'
1616
import { useRuntimeConfig, useRoute, useRouter } from '#imports'
1717
import NUsersPasswordStrengthIndicator from './NUsersPasswordStrengthIndicator.vue'
1818
19+
// Note: We define Props interface inline instead of importing ResetPasswordFormProps from 'nuxt-users/utils'
20+
// because the Vue SFC transformer cannot resolve these imported types during the module build process
21+
interface Props {
22+
updatePasswordEndpoint?: string
23+
resetPasswordEndpoint?: string
24+
redirectTo?: string
25+
}
26+
1927
interface Emits {
2028
(e: 'success', user: UserWithoutPassword): void
2129
(e: 'error' | 'password-error', error: string): void
@@ -25,7 +33,7 @@ interface Emits {
2533
const { public: { nuxtUsers } } = useRuntimeConfig()
2634
const moduleOptions = nuxtUsers as ModuleOptions
2735
28-
const props = defineProps<ResetPasswordFormProps>()
36+
const props = defineProps<Props>()
2937
const emit = defineEmits<Emits>()
3038
3139
const route = useRoute()

src/runtime/components/NUsersUserCard.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
import { computed } from 'vue'
33
import { useAuthentication } from '../composables/useAuthentication'
44
import { useRuntimeConfig } from '#imports'
5-
import { defaultDisplayFields, defaultFieldLabels, type DisplayFieldsProps, type User } from 'nuxt-users/utils'
5+
import { defaultDisplayFields, defaultFieldLabels, type User } from 'nuxt-users/utils'
66
7-
interface Props extends DisplayFieldsProps {
7+
// Note: We define Props interface inline instead of importing DisplayFieldsProps from 'nuxt-users/utils'
8+
// because the Vue SFC transformer cannot resolve these imported types during the module build process
9+
interface Props {
810
user: User
911
index: number
12+
displayFields?: string[]
13+
fieldLabels?: Record<string, string>
1014
}
1115
1216
const props = withDefaults(defineProps<Props>(), {

src/runtime/components/NUsersUserForm.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import type { RuntimeModuleOptions, User } from 'nuxt-users/utils'
44
import { usePasswordValidation } from '../composables/usePasswordValidation'
55
import { useRuntimeConfig } from '#imports'
66
7-
const props = defineProps<{
7+
// Note: We define Props interface inline instead of importing types from 'nuxt-users/utils'
8+
// because the Vue SFC transformer cannot resolve these imported types during the module build process
9+
interface Props {
810
user?: User | null
9-
}>()
11+
}
12+
13+
const props = defineProps<Props>()
1014
1115
const emit = defineEmits<{
1216
(e: 'submit', userData: Partial<User>): void

0 commit comments

Comments
 (0)