I need some help configuring aliases order in the generated .nuxt/tsconfig.json
file. Firstly, I think the documentation needs to really emphasize the importance of the fileURLToPath("<path-from-src-dir>", import.meta.url)
function; it’s import location is not even shown and if you don’t use it, either your IDE will yell at you or your project pages will throw errors! Granted, that’s figured out now.
Second thing is my user defined aliases in the nuxt.config.ts
file should be generated above the default aliases! Because of aliases like “~” referencing the src directory, my IDE will suggest imports from there instead of a more specific location I’ve aliased. I can ofcourse manually import but that’s hurting the DX pretty bad. I’ve resorted to accepting the IDE import from “~” and manually editing it to reference my specific alias.
This is what my alias looks like:
alias: {
'@schemas': fileURLToPath(new URL('./lib/schemas', import.meta.url)),
},
And this is the abbreviated generated tsconfig “paths” array:
"paths": {
...,
"~": [
".."
],
"~/*": [
"../*"
],
"@": [
".."
],
"@/*": [
"../*"
],
"~~": [
".."
],
"~~/*": [
"../*"
],
"@@": [
".."
],
"@@/*": [
"../*"
],
...,
"@schemas": [
"../lib/schemas"
],
"@schemas/*": [
"../lib/schemas/*"
],
...,
},
When I manually move my alias to the top of the file the IDE works as expected, but of course when this file is regenerated, it puts my alias as the bottom again.