How to import a specific file under "shared".
cakoose opened this issue · comments
Hi! I'm trying to set up a project and this example has been useful. However, I ran into an issue.
In your example, "backend/src/index.ts" does:
import { createUser, showUser, User } from 'shared';
This seems to work because "shared/src/index.ts" re-exports everything from "shared/src/user.ts". But what if I have tons of files under "shared" and want to import them selectively, e.g.
import { createUser, showUser, User } from 'shared/user'; # ERROR: Cannot find module 'shared/user'
Is there a way to make that work?
If so, you should need to import from the correct path like this:
import { createUser, showUser, User } from 'shared/dist/user';
For me, the import statement is not reading by human but machine, so I prefer let editor handle everything about import.
VSCode auto import is powerful, just let VSCode organize import statement.