But What will I do if I've to import from another file that is in the same folder but that folder is nested?
E.g. src/service/backend/post/ is a folder. Inside that I have 2 modules but 1 imports another. So do I've to write it like import {aFunction} from "service/backend/post/module-2" ?
You can still use relative imports. This compiler option only adds to your abilities to do imports, it doesn't take away. you can still use import {aFunction} from "../module-2" and since it's relative, this will still work. The baseUrl option only applies to imports that are not relative, so relative imports still references from the current file
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
But What will I do if I've to import from another file that is in the same folder but that folder is nested?
E.g.
src/service/backend/post/
is a folder. Inside that I have 2 modules but 1 imports another. So do I've to write it likeimport {aFunction} from "service/backend/post/module-2"
?Can I use relative import in that case?
You can still use relative imports. This compiler option only adds to your abilities to do imports, it doesn't take away. you can still use
import {aFunction} from "../module-2"
and since it's relative, this will still work. The baseUrl option only applies to imports that are not relative, so relative imports still references from the current file