I have this settings in my tsconfig:
"paths": {
"@util": ["util/index.js"]
}
But when I import { } from "@util";
It emits this code: import { } from "../util";
If I instead rename the file to something else, e.g. barrel, it emits this: import { } from "../util/barrel";
The problem is, node can resolve neither of these. And as I specify that @util should be rewritten to util/index.js I expect it to keep the index.js part, without this my import simply doesn't function.
I can't really tell if this is intended behavior or not, but I think emitting the full path (including index.js) should always be a safe option if it is specified as such in the paths option.
I know I could instead do "@util/*": ["util/*"]
And then import { } from "@util/index.js";
But it'd be even better if I can have it emit the index.js for me as well.
I have this settings in my tsconfig:
But when I
import { } from "@util";It emits this code:
import { } from "../util";If I instead rename the file to something else, e.g.
barrel, it emits this:import { } from "../util/barrel";The problem is, node can resolve neither of these. And as I specify that
@utilshould be rewritten toutil/index.jsI expect it to keep theindex.jspart, without this my import simply doesn't function.I can't really tell if this is intended behavior or not, but I think emitting the full path (including
index.js) should always be a safe option if it is specified as such in thepathsoption.I know I could instead do
"@util/*": ["util/*"]And then
import { } from "@util/index.js";But it'd be even better if I can have it emit the
index.jsfor me as well.