Sara
Sara4d ago

I like to use a better file organisation

I like to use a better file organisation in my /convex directory for tables that require more than one file (mainly to organize file that can extend to 1000+ lines), when I'm inside a file in say /convex/chat/support.ts I don't get convex's functions in /_generated directory suggested to me, anyway I can fix that within my editor or tsconfig?
13 Replies
erquhart
erquhart4d ago
Should work just the same if you’re importing eg., api from the generated api file - what are you seeing?
Sara
SaraOP4d ago
if it works the same I wouldn't be asking the question 😛 haha for instance when I try importing query: (I tried updating the paths in my tsconfig earlier, this is why I have a bunch of options)
No description
Sara
SaraOP4d ago
and when I try importing api:
No description
v
v4d ago
Weird bug I use that structure just fine, default tsconfig, editor etc
erquhart
erquhart4d ago
Sorry, what I meant with "should work the same" is "no you don't have to do anything to make it work" Can you share your convex/tsconfig?
v
v4d ago
Are the functions in the generated files ?
Sara
SaraOP4d ago
It's the basic tsconfig that's generarated by convex
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"isolatedModules": true,
"noEmit": true
},
"include": ["./**/*"],
"exclude": ["./_generated"]
}
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"isolatedModules": true,
"noEmit": true
},
"include": ["./**/*"],
"exclude": ["./_generated"]
}
v
v4d ago
Did you happen to restart the ts server
Sara
SaraOP4d ago
yes
v
v4d ago
I wonder if webstorm would show the same results
erquhart
erquhart4d ago
Dang that's really strange. I would try importing api and console logging a function reference, then running tsc from the console to see if it's just your editor or not
Sara
SaraOP4d ago
To make it clear, I'm asking about the IntelliSense 😅 everything else works perfectly
erquhart
erquhart4d ago
Yeah I know, I'm just trying to help troubleshoot as I haven't seen anyone encounter this before. I understand things work, but wanted to specifically confirm that this is actually limited to intellisense, which requires running code that intellisense thinks is incorrect. Hmm wait so you're saying if you manually add import { api } from ./_generated/api, everything works in the editor, types click through, etc? Like literally just intellisense? If so I think that really goes squarely on the editor and plugins. Which is super unhelpful, I know. Just not sure there's anything Convex specific happening if that's the case.

Did you find this page helpful?