Failed to resolve import

[plugin:vite:import-analysis] Failed to resolve import "../../../../src/admin/dashboards/analytics/AnalyticsDashboardPage" from "src/router.tsx". Does the file exist? /home/rootall/apps/minisaas-boilerplate/app/.wasp/out/web-app/src/router.tsx:9:35 5 | import { LoginPage } from "../../../../src/auth/LoginPage"; 6 | import { TooGradedPage } from "../../../../src/toograded/TooGradedPage"; 7 | import AnalyticsDashboardPage from "../../../../src/admin/dashboards/analytics/AnalyticsDashboardPage"; | ^ 8 | import { SGPACalculatorPage } from "../../../../src/sgpa-calculator/SGPACalculatorPage"; 9 | import { CGPACalculatorPage } from "../../../../src/cgpa-calculator/CGPACalculatorPage"; what's wrong???
20 Replies
kapa.ai
kapa.ai2w ago
Hi @NEROX. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- This error is related to a common issue in Wasp projects where the import paths in the generated router.tsx file don't match the actual file structure of your project. Based on the information provided in the knowledge sources, here's what might be wrong: 1. File path mismatch: The error suggests that the file AnalyticsDashboardPage cannot be found at the specified path. This could be because the file doesn't exist or the path is incorrect. Github Issue #1664 (https://github.com/wasp-lang/wasp/issues/1664) 2. Incorrect import in Wasp file: The error might be caused by an incorrect import statement in your main .wasp file. The path to the component in your Wasp file might be missing the pages/ part of the path. Github Issue #1527 (https://github.com/wasp-lang/wasp/issues/1527) To resolve this issue, you can try the following: 1. Check if the file AnalyticsDashboardPage exists in the specified directory structure: src/admin/dashboards/analytics/. 2. If the file exists, make sure the import statement in your .wasp file is correct. Look for a declaration like page AnalyticsDashboardPage in your .wasp file and ensure the component: part includes the correct path, including any necessary pages/ part. 3. If the file doesn't exist, you need to create it at the correct location or update the import path in your .wasp file to match the actual location of the file. 4. After making these changes, try running wasp start again to see if the error is resolved. If you continue to face issues, you might want to check the other import statements as well, as they all seem to follow a similar pattern that might be incorrect. Remember, Wasp is still in development, and there are known issues with error reporting and import path handling. If you can't resolve the issue, you might want to seek help on the Wasp Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416) where the community can provide more specific assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
Solved, I forgot that I had commented those files, don't ask me why. @kapa.ai Fixed but now I have other errors: [ Wasp ] ext-src/admin/layout/Sidebar.tsx(106,17): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => boolean; className: (isActive: NavLinkRenderProps) => string; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(282,25): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => any; className: (isActive: NavLinkRenderProps) => string; onClick: (e: MouseEvent<...>) => void; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(420,25): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => any; className: (isActive: NavLinkRenderProps) => string; onClick: (e: MouseEvent<...>) => void; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] ext-src/messages/MessageButton.tsx(8,9): error TS2322: Type '"/admin/messages"' is not assignable to type '"/login" | "/" | "/admin" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'. [ Wasp ] ext-src/user/DropdownUser.tsx(4,31): error TS2307: Cannot find module './UserMenuItems' or its corresponding type declarations.
❌ --- [Error] Your wasp project failed to compile: ------------------------------- - SDK build failed with exit code: 2
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- These new errors are related to TypeScript type checking issues in your Wasp project. Let's break them down and suggest some solutions: 1. NavLink prop errors: The first three errors are about the isActive prop on NavLink components. It seems that the NavLink component from the version of react-router-dom you're using doesn't expect an isActive prop. This could be due to a version mismatch or changes in the API. To fix this: - Remove the isActive prop from your NavLink components in ext-src/admin/layout/Sidebar.tsx. - If you need custom active link logic, consider using the className prop with a function that receives { isActive } as an argument. 2. Route path error:
[ Wasp ] ext-src/messages/MessageButton.tsx(8,9): error TS2322: Type '"/admin/messages"' is not assignable to type '"/login" | "/" | "/admin" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'.
[ Wasp ] ext-src/messages/MessageButton.tsx(8,9): error TS2322: Type '"/admin/messages"' is not assignable to type '"/login" | "/" | "/admin" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'.
This error suggests that the route /admin/messages is not defined in your Wasp file. To fix this: - Add the /admin/messages route to your .wasp file if it's missing. - If the route is already defined, make sure it's spelled correctly in both the .wasp file and the MessageButton.tsx file. 3. Module import error:
[ Wasp ] ext-src/user/DropdownUser.tsx(4,31): error TS2307: Cannot find module './UserMenuItems' or its corresponding type declarations.
[ Wasp ] ext-src/user/DropdownUser.tsx(4,31): error TS2307: Cannot find module './UserMenuItems' or its corresponding type declarations.
This error indicates that the file UserMenuItems is missing or not in the expected location. To fix this: - Check if the file UserMenuItems.tsx (or .js) exists in the same directory as DropdownUser.tsx. - If it doesn't exist, create it or update the import statement to point to the correct file. These errors are typical TypeScript issues that can occur when working with Wasp projects. They're not directly related to Wasp itself but rather to the TypeScript configuration and the React components you're using. To resolve these issues: 1. Update your NavLink usage in Sidebar.tsx to match the expected props. 2. Check your route definitions in the .wasp file and ensure they match your component usage. 3. Verify the existence and correct import path of the UserMenuItems file. After making these changes, run wasp start again to see if the errors are resolved. If you continue to face issues, you might want to check your TypeScript and react-router-dom versions to ensure compatibility. For more detailed assistance, you can refer to the Wasp documentation (https://wasp-lang.dev/docs) or ask for help in the Wasp Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
@kapa.ai And to solve these?: [ Wasp ] ext-src/admin/layout/Sidebar.tsx(106,17): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => boolean; className: (isActive: NavLinkRenderProps) => string; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(282,25): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => any; className: (isActive: NavLinkRenderProps) => string; onClick: (e: MouseEvent<...>) => void; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(420,25): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => any; className: (isActive: NavLinkRenderProps) => string; onClick: (e: MouseEvent<...>) => void; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] ext-src/messages/MessageButton.tsx(8,9): error TS2322: Type '"/admin/messages"' is not assignable to type '"/login" | "/" | "/admin" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'. [ Wasp ] ext-src/user/UserMenuItems.tsx(26,13): error TS2322: Type '"/account"' is not assignable to type '"/admin" | "/login" | "/" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'.
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- These errors are TypeScript type checking issues related to your Wasp project. Let's address them one by one: 1. NavLink prop errors (first three errors): These errors suggest that the NavLink component from react-router-dom doesn't expect an isActive prop. This could be due to a version mismatch between your TypeScript types and the actual react-router-dom version. To fix this: - Remove the isActive prop from your NavLink components in ext-src/admin/layout/Sidebar.tsx. - Instead, use the className prop with a function that receives { isActive } as an argument. For example:
<NavLink
to="/some-path"
className={({ isActive }) => isActive ? 'active-class' : 'inactive-class'}
>
{/* children */}
</NavLink>
<NavLink
to="/some-path"
className={({ isActive }) => isActive ? 'active-class' : 'inactive-class'}
>
{/* children */}
</NavLink>
2. Route path errors:
[ Wasp ] ext-src/messages/MessageButton.tsx(8,9): error TS2322: Type '"/admin/messages"' is not assignable to type '"/login" | "/" | "/admin" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'.
[ Wasp ] ext-src/user/UserMenuItems.tsx(26,13): error TS2322: Type '"/account"' is not assignable to type '"/admin" | "/login" | "/" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'.
[ Wasp ] ext-src/messages/MessageButton.tsx(8,9): error TS2322: Type '"/admin/messages"' is not assignable to type '"/login" | "/" | "/admin" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'.
[ Wasp ] ext-src/user/UserMenuItems.tsx(26,13): error TS2322: Type '"/account"' is not assignable to type '"/admin" | "/login" | "/" | "/sgpa-calculator" | "/cgpa-calculator" | "/sgpa-to-percentage-calculator" | "/cgpa-to-percentage-calculator" | "/sgpa-to-cgpa-calculator" | ... 21 more ... | "/dua-to-pass-driving-exam"'.
These errors indicate that the routes /admin/messages and /account are not defined in your Wasp file. To fix this: 1. Open your main .wasp file. 2. Add these routes to your route declarations. For example:
route AdminMessagesRoute { path: "/admin/messages", to: AdminMessagesPage }
route AccountRoute { path: "/account", to: AccountPage }
page AdminMessagesPage {
component: import { AdminMessagesPage } from "@client/pages/AdminMessagesPage"
}

page AccountPage {
component: import { AccountPage } from "@client/pages/AccountPage"
}
route AdminMessagesRoute { path: "/admin/messages", to: AdminMessagesPage }
route AccountRoute { path: "/account", to: AccountPage }
page AdminMessagesPage {
component: import { AdminMessagesPage } from "@client/pages/AdminMessagesPage"
}

page AccountPage {
component: import { AccountPage } from "@client/pages/AccountPage"
}
3. Make sure you have created the corresponding React components for these pages. After making these changes, run wasp start again to rebuild your project. This should resolve the TypeScript errors you're encountering. If you continue to face issues, you might want to check your TypeScript and react-router-dom versions to ensure compatibility. You can also refer to the Wasp documentation (https://wasp-lang.dev/docs) for more information on routing and TypeScript support in Wasp projects. Remember, Wasp is still in development, and there might be some inconsistencies between TypeScript types and the actual implementation. If these issues persist, you might want to reach out to the Wasp community on their Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416) for more specific assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
@kapa.ai done but: [ Wasp ] ext-src/admin/layout/Sidebar.tsx(289,25): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => any; className: (isActive: NavLinkRenderProps) => string; onClick: (e: MouseEvent<...>) => void; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(427,25): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => any; className: (isActive: NavLinkRenderProps) => string; onClick: (e: MouseEvent<...>) => void; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. ❌ --- [Error] Your wasp project failed to compile: -------------------------------
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- These errors are still related to the isActive prop on the NavLink component that we discussed earlier. It seems that you might have missed updating a couple of instances in your Sidebar.tsx file. Let's address these remaining issues: The error messages indicate that the NavLink component doesn't expect an isActive prop. This is likely due to changes in the React Router API in recent versions. To fix this, you need to remove the isActive prop and update how you handle active link styling. Here's how you can modify the NavLink components in ext-src/admin/layout/Sidebar.tsx: 1. Remove the isActive prop. 2. Update the className prop to use a function that receives { isActive } as an argument. For example, change this:
<NavLink
to="/some-path"
isActive={(_match, location) => /* some condition */}
className={(isActive: NavLinkRenderProps) => /* some class */}
onClick={(e: MouseEvent<HTMLElement>) => /* some action */}
>
{/* children */}
</NavLink>
<NavLink
to="/some-path"
isActive={(_match, location) => /* some condition */}
className={(isActive: NavLinkRenderProps) => /* some class */}
onClick={(e: MouseEvent<HTMLElement>) => /* some action */}
>
{/* children */}
</NavLink>
To this:
<NavLink
to="/some-path"
className={({ isActive }) =>
isActive ? 'your-active-class' : 'your-inactive-class'
}
onClick={(e: React.MouseEvent<HTMLElement>) => /* some action */}
>
{/* children */}
</NavLink>
<NavLink
to="/some-path"
className={({ isActive }) =>
isActive ? 'your-active-class' : 'your-inactive-class'
}
onClick={(e: React.MouseEvent<HTMLElement>) => /* some action */}
>
{/* children */}
</NavLink>
Make sure to apply this change to both instances mentioned in the error messages (lines 289 and 427 in Sidebar.tsx). If you need custom logic for determining whether a link is active, you can use the end prop on NavLink or create a custom wrapper component that uses the useMatch hook from react-router-dom to determine if a link should be considered active. After making these changes, run wasp start again to rebuild your project. This should resolve the remaining TypeScript errors related to the NavLink components. If you continue to face issues or need more specific help, you might want to share the relevant parts of your Sidebar.tsx file or ask for assistance in the Wasp Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416), where the community can provide more tailored support. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
@kapa.ai thanks and [ Wasp ] ext-src/admin/layout/Sidebar.tsx(288,29): error TS2304: Cannot find name 'path'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(293,102): error TS2304: Cannot find name 'path'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(297,34): error TS2552: Cannot find name 'onClick'. Did you mean 'onclick'? [ Wasp ] ext-src/admin/layout/Sidebar.tsx(299,26): error TS2304: Cannot find name 'children'. [ Wasp ] ext-src/admin/layout/Sidebar.tsx(377,25): error TS2322: Type '{ children: (string | Element)[]; to: string; isActive: (_match: any, location: any) => any; className: (isActive: NavLinkRenderProps) => string; onClick: (e: MouseEvent<...>) => void; }' is not assignable to type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'. [ Wasp ] Property 'isActive' does not exist on type 'IntrinsicAttributes & NavLinkProps & RefAttributes<HTMLAnchorElement>'.
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Thank you for providing the updated error messages. Let's address these new TypeScript errors in your ext-src/admin/layout/Sidebar.tsx file: 1. Cannot find name 'path' errors: These errors suggest that you're using a variable named path that hasn't been defined. Make sure you've imported or defined path correctly. If it's supposed to be a prop, make sure it's included in your component's props type definition. 2. Cannot find name 'onClick' error: This error indicates that onClick is not recognized. It should be onClick (with a capital C) if you're using it as a prop or event handler. Make sure you're using the correct casing. 3. Cannot find name 'children' error: The children prop should be available by default in React components. Make sure you're using it correctly within the component's props type definition. 4. Type error with NavLink: This error is similar to what we discussed earlier. You need to remove the isActive prop from the NavLink component. To fix these issues, try the following: 1. If path is a prop, make sure it's defined in your component's props interface:
interface SidebarProps {
path: string;
// other props...
}

const Sidebar: React.FC<SidebarProps> = ({ path, ...otherProps }) => {
// component logic
}
interface SidebarProps {
path: string;
// other props...
}

const Sidebar: React.FC<SidebarProps> = ({ path, ...otherProps }) => {
// component logic
}
2. Correct the onClick casing:
onClick={(e: React.MouseEvent<HTMLElement>) => /* your logic */}
onClick={(e: React.MouseEvent<HTMLElement>) => /* your logic */}
3. For the children error, make sure you're using it correctly within your component:
const Sidebar: React.FC<SidebarProps> = ({ children, ...otherProps }) => {
// component logic
return (
// ...
{children}
// ...
)
}
const Sidebar: React.FC<SidebarProps> = ({ children, ...otherProps }) => {
// component logic
return (
// ...
{children}
// ...
)
}
4. Remove the isActive prop from NavLink and use the className prop with a function:
<NavLink
to={path}
className={({ isActive }) =>
isActive ? 'your-active-class' : 'your-inactive-class'
}
onClick={(e: React.MouseEvent<HTMLElement>) => /* your logic */}
>
{children}
</NavLink>
<NavLink
to={path}
className={({ isActive }) =>
isActive ? 'your-active-class' : 'your-inactive-class'
}
onClick={(e: React.MouseEvent<HTMLElement>) => /* your logic */}
>
{children}
</NavLink>
After making these changes, run wasp start again to rebuild your project. This should resolve the TypeScript errors in your Sidebar.tsx file. If you continue to face issues, you might want to share the relevant parts of your Sidebar.tsx file or ask for more specific assistance in the Wasp Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
@kapa.ai I have new project: [ Wasp ] ext-src/WingBackAi/WingBackAiPage.tsx(6,61): error TS2558: Expected 2 type arguments, but got 1. [ Wasp ] ext-src/WingBackAi/WingBackAiPage.tsx(30,56): error TS2339: Property 'data' does not exist on type 'unknown'.
❌ --- [Error] Your wasp project failed to compile: ------------------------------- - SDK build failed with exit code: 2 ❌ --- [Error] Compilation of wasp project failed: -------------------------------- My operations: import type { GetWingBackData } from 'wasp/server/operations' export type WingBackDataPayload = { status: string data: { message: string } } // The query function needs both args and context types export const getWingBackData: GetWingBackData<void, WingBackDataPayload> = async (_args, context) => { try { return { status: 'success', data: { message: 'Welcome to WingBack AI!' } } } catch (error: any) { throw new Error(error.message) } } My page: import { useQuery } from 'wasp/client/operations' import { getWingBackData } from './operations' import type { WingBackDataPayload } from './operations' export function WingBackAiPage() { const { data: wingBackData, isLoading, error } = useQuery<void, WingBackDataPayload>(getWingBackData) if (isLoading) { return ( <div className="flex justify-center items-center min-h-screen"> <div className="animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-gray-900"></div> </div> ) } if (error) { return ( <div className="min-h-screen flex items-center justify-center"> <div className="text-red-500">Error: {error.message}</div> </div> ) } return ( <div className="min-h-screen bg-gray-100"> <main className="container mx-auto px-4 py-8"> <h1 className="text-4xl font-bold text-gray-900 mb-8">WingBack AI</h1> {wingBackData && ( <div className="bg-white rounded-lg shadow p-6"> <p className="text-gray-700">{wingBackData.data.message}</p> </div> )} </main> </div> ) } My main wasp: route WingBackAiRoute { path: "/wingback", to: WingBackAiPage } page WingBackAiPage { component: import { WingBackAiPage } from "@src/WingBackAi/WingBackAiPage" } query getWingBackData { fn: import { getWingBackData } from "@src/WingBackAi/operations", entities: [] }
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the information you've provided, it seems you're encountering TypeScript errors in your Wasp project. Let's address these issues one by one: 1. Error in WingBackAiPage.tsx(6,61):
error TS2558: Expected 2 type arguments, but got 1.
error TS2558: Expected 2 type arguments, but got 1.
This error is occurring because the useQuery hook expects two type arguments, but you're only providing one. To fix this, update your useQuery call as follows:
const { data: wingBackData, isLoading, error } = useQuery<void, WingBackDataPayload>(getWingBackData)
const { data: wingBackData, isLoading, error } = useQuery<void, WingBackDataPayload>(getWingBackData)
2. Error in WingBackAiPage.tsx(30,56):
error TS2339: Property 'data' does not exist on type 'unknown'.
error TS2339: Property 'data' does not exist on type 'unknown'.
This error is likely because TypeScript doesn't recognize the type of wingBackData. To fix this, you can add a type assertion:
{wingBackData && (
<div className="bg-white rounded-lg shadow p-6">
<p className="text-gray-700">{(wingBackData as WingBackDataPayload).data.message}</p>
</div>
)}
{wingBackData && (
<div className="bg-white rounded-lg shadow p-6">
<p className="text-gray-700">{(wingBackData as WingBackDataPayload).data.message}</p>
</div>
)}
However, a better approach would be to use optional chaining and nullish coalescing:
<p className="text-gray-700">{wingBackData?.data?.message ?? 'No message available'}</p>
<p className="text-gray-700">{wingBackData?.data?.message ?? 'No message available'}</p>
3. In your operations file, make sure you're importing the correct type from Wasp:
import type { GetWingBackData } from 'wasp/server/operations'
import type { GetWingBackData } from 'wasp/server/operations'
Ensure that GetWingBackData is the correct type exported by Wasp for your query. 4. In your main.wasp file, the query definition looks correct:
query getWingBackData {
fn: import { getWingBackData } from "@src/WingBackAi/operations",
entities: []
}
query getWingBackData {
fn: import { getWingBackData } from "@src/WingBackAi/operations",
entities: []
}
After making these changes, try running wasp start again. If you still encounter issues, you might want to check the following: 1. Ensure that your Wasp version is up to date. 2. Verify that all imports in your TypeScript files are correct. 3. Make sure that the WingBackDataPayload type is correctly defined and exported from your operations file. If the problems persist, you might want to seek further assistance on the Wasp Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416), where the community can provide more specific help based on your project setup. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
@kapa.ai now it gives me: [ Wasp ] ext-src/WingBackAi/WingBackAiPage.tsx(6,89): error TS2345: Argument of type 'GetWingBackData<void, WingBackDataResponse>' is not assignable to parameter of type 'Query<void, WingBackDataResponse>'. [ Wasp ] Type 'GetWingBackData<void, WingBackDataResponse>' is not assignable to type '() => Promise<WingBackDataResponse>'. [ Wasp ] Target signature provides too few arguments. Expected 2 or more, but got 0. After the changes
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- It seems that the error is related to a type mismatch between what useQuery expects and what getWingBackData is defined as. Let's address this issue: The error suggests that GetWingBackData is not directly compatible with the Query type that useQuery expects. This is likely because GetWingBackData is a server-side type, while useQuery expects a client-side query function. To resolve this, you need to import the client-side version of your query. In Wasp, client-side query functions are automatically generated and can be imported from wasp/client/operations. Here's how you can fix this: 1. Update your imports in WingBackAiPage.tsx:
import { useQuery } from 'wasp/client/operations'
import getWingBackData from 'wasp/client/operations/getWingBackData'
import type { WingBackDataPayload } from './operations'
import { useQuery } from 'wasp/client/operations'
import getWingBackData from 'wasp/client/operations/getWingBackData'
import type { WingBackDataPayload } from './operations'
2. Then, use getWingBackData directly in your useQuery call:
const { data: wingBackData, isLoading, error } = useQuery(getWingBackData)
const { data: wingBackData, isLoading, error } = useQuery(getWingBackData)
You don't need to specify the generic types for useQuery in this case, as they will be inferred from the getWingBackData function. 3. If you still need to specify the types explicitly, you can do so like this:
const { data: wingBackData, isLoading, error } = useQuery<void, WingBackDataPayload>(getWingBackData)
const { data: wingBackData, isLoading, error } = useQuery<void, WingBackDataPayload>(getWingBackData)
These changes should resolve the type mismatch error you're encountering. Remember, in Wasp, there's a distinction between server-side query implementations (which you define in your operations.ts file) and client-side query functions (which Wasp generates for you). When using useQuery in your React components, you should always use the client-side version of the query. If you continue to face issues after making these changes, you might want to double-check your main.wasp file to ensure the query is correctly defined there, and that all your file paths are correct. If problems persist, consider reaching out to the Wasp Discord community (https://discord.com/channels/686873244791210014/1219134547711758416) for more specific assistance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
@kapa.ai New problem. Forget completely our conversation, we start again: [ Server!] [!] RollupError: src/auth/providers/config/email.ts (14:9): "getEmailUserFields" is not exported by "../../../src/auth/userSignupFields.ts", imported by "src/auth/providers/config/email.ts". [ Server!] https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module [ Server!] src/auth/providers/config/email.ts (14:9) [ Server!] 12: import { handleRejection } from "wasp/server/utils"; [ Server!] 13: [ Server!] 14: import { getEmailUserFields } from '../../../../../../../src/auth/userSignupFields' [ Server!] ^ [ Server!] 15: const _waspUserSignupFields = getEmailUserFields
Rollup
The JavaScript module bundler
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I understand you're facing a new issue with your Wasp project. Let's analyze the error message and provide a solution: The error you're seeing is a RollupError, which is related to module bundling. Specifically, it's saying that "getEmailUserFields" is not exported from the file "../../../src/auth/userSignupFields.ts". This typically happens when there's a mismatch between what's being imported and what's actually exported from a file. Here's how we can address this issue: 1. First, check your "src/auth/userSignupFields.ts" file. Make sure you're exporting the getEmailUserFields function. It should look something like this:
export function getEmailUserFields() {
// Function implementation
}
export function getEmailUserFields() {
// Function implementation
}
Or if it's a named export:
export const getEmailUserFields = () => {
// Function implementation
}
export const getEmailUserFields = () => {
// Function implementation
}
2. If the function is there and properly exported, the issue might be with the import path. The error message shows a very long relative path:
import { getEmailUserFields } from '../../../../../../../src/auth/userSignupFields'
import { getEmailUserFields } from '../../../../../../../src/auth/userSignupFields'
This path seems unusually long and might be incorrect. In Wasp projects, you typically import from "@src" instead of using relative paths. Try changing the import to:
import { getEmailUserFields } from '@src/auth/userSignupFields'
import { getEmailUserFields } from '@src/auth/userSignupFields'
3. If you've made these changes and the error persists, double-check that the file name and location are correct. It should be at "src/auth/userSignupFields.ts" relative to your project root. 4. Also, ensure that the function name is exactly getEmailUserFields in both the export and import statements. TypeScript is case-sensitive, so even a small difference in casing could cause this error. 5. If you're still having issues, you might want to check your tsconfig.json file to ensure that the paths are correctly set up, especially if you're using path aliases. After making these changes, try running wasp start again to see if the error is resolved. If you continue to face issues, it might be helpful to share the contents of your "src/auth/userSignupFields.ts" file and the relevant parts of your "src/auth/providers/config/email.ts" file. This would allow for a more detailed diagnosis of the problem. Remember, if you need further assistance, the Wasp Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416) is a great place to get help from the community and the Wasp team directly. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP2w ago
@kapa.ai My file is this: import { defineUserSignupFields } from 'wasp/server/auth' export const getGoogleUserFields = defineUserSignupFields({ username: (data: any) => data.profile.email, email: (data: any) => data.profile.email }) export const getGoogleAuthConfig = () => ({ scopes: ['profile', 'email'] }) What's wrong
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the file content you've provided and the previous error message, it seems that the issue is related to a mismatch between what's being exported from your file and what's being imported elsewhere in your Wasp project. Let's analyze the problem: 1. Your file is exporting getGoogleUserFields and getGoogleAuthConfig, but the error message mentions getEmailUserFields. 2. The error suggests that the system is looking for getEmailUserFields, but this function is not defined or exported in the file you've shown. To resolve this issue, you have a few options: 1. If you intended to use getGoogleUserFields for email authentication: Rename getGoogleUserFields to getEmailUserFields:
export const getEmailUserFields = defineUserSignupFields({
username: (data: any) => data.profile.email,
email: (data: any) => data.profile.email
})

export const getEmailUserFields = defineUserSignupFields({
username: (data: any) => data.profile.email,
email: (data: any) => data.profile.email
})

2. If you're using Google authentication and the import in another file is incorrect: Find the file that's trying to import getEmailUserFields (likely "src/auth/providers/config/email.ts" based on the error message) and update the import to:
import { getGoogleUserFields as getEmailUserFields } from '@src/auth/userSignupFields'

import { getGoogleUserFields as getEmailUserFields } from '@src/auth/userSignupFields'

3. If you need separate functions for Google and Email authentication: Add a new export for email authentication:
export const getEmailUserFields = defineUserSignupFields({
username: (data: any) => data.email,
email: (data: any) => data.email
})

export const getEmailUserFields = defineUserSignupFields({
username: (data: any) => data.email,
email: (data: any) => data.email
})

After making one of these changes, make sure to update any other files that might be importing these functions to use the correct names. Also, ensure that the file name and location are correct. The error message suggests it should be at "src/auth/userSignupFields.ts" relative to your project root. If you continue to face issues after making these changes, you might want to check your main.wasp file to ensure that the auth configuration is correctly set up for the authentication methods you're using (Google, Email, or both). For more specific assistance, you could share the relevant parts of your main.wasp file and the file where you're trying to import getEmailUserFields. This would allow for a more precise diagnosis of the problem. Remember, if you need further help, the Wasp Discord channel (https://discord.com/channels/686873244791210014/1219134547711758416) is a great place to get assistance from the Wasp community and developers. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Filip
Filip7d ago
Hey @NEROX, did you resolve the issue? If not, could you give a human readable summary of the problem to spare me from reading the bot conversation? Thanks!
NEROX
NEROXOP7d ago
yeah! When I put the ✅ Solved tag it means all its ok ;)
Filip
Filip7d ago
Perfect, thanks!
Want results from more Discord servers?
Add your server