mario.p
mario.p
WWasp
Created by mario.p on 2/17/2025 in #🙋questions
"Property 'value' does not exist on type XYZ"- but it exists. What am I doing wrong?
Hi everyone! In advance I would say that I am new to this technology and I am stuck with something that looks like a bug in WASP but I am not sure. The error I receive when the build fails: Property 'user' does not exist on type '{ id: number; userId: string; } The code: File mypage.tsx
import { type CourseChapter, type Course, UserInstructor, User } from 'wasp/entities';

// ... other code

function CourseForm({ courseId }: { courseId: string }) {

const { data: instructors } = useQuery(getUserInstructors)

// other code...
<select>
{instructors?.map((instructor: UserInstructor) => (
<option key={instructor.id} value={String(instructor.id)}>
{instructor.user.username}
</option>
))}
</select>
// ...
import { type CourseChapter, type Course, UserInstructor, User } from 'wasp/entities';

// ... other code

function CourseForm({ courseId }: { courseId: string }) {

const { data: instructors } = useQuery(getUserInstructors)

// other code...
<select>
{instructors?.map((instructor: UserInstructor) => (
<option key={instructor.id} value={String(instructor.id)}>
{instructor.user.username}
</option>
))}
</select>
// ...
This is my operations file File operations.ts
import { Course, CourseCategory, CourseChapter, UserInstructor } from 'wasp/entities'
import { type GetCourseCategories, type GetUserInstructors, type GetCourses, type GetCourseChapters } from 'wasp/server/operations'

// ... other code

export const getUserInstructors: GetUserInstructors<void, UserInstructor[]> = async (args, context) => {
return context.entities.UserInstructor.findMany({
orderBy: { id: 'asc' },
include: {
user: {
select: {
id: true,
username: true
}
}
},
})
}
import { Course, CourseCategory, CourseChapter, UserInstructor } from 'wasp/entities'
import { type GetCourseCategories, type GetUserInstructors, type GetCourses, type GetCourseChapters } from 'wasp/server/operations'

// ... other code

export const getUserInstructors: GetUserInstructors<void, UserInstructor[]> = async (args, context) => {
return context.entities.UserInstructor.findMany({
orderBy: { id: 'asc' },
include: {
user: {
select: {
id: true,
username: true
}
}
},
})
}
File Schema.prisma
// ...
model UserInstructor {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId String @unique
courses Course[]
}
// ...
model UserInstructor {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId String @unique
courses Course[]
}
What I have already tried that didn't work: - wasp clean - Adding new fields to the UserInstructor model and running wasp db dev-migrate I am working on Ubuntu 22 with Wasp 0.16.2 I hope someone can help me 🙂 Thanks!
10 replies