vue-tsc
vue-tsc copied to clipboard
Use ‘vue-tsc --noEmit’ in ‘lint-staged’ to verify the reference of the alias path @/ prompt an error
Use ‘vue-tsc --noEmit’ in ‘lint-staged’ to verify the reference of the alias path ‘@/’ prompt an error。在package.json中的设置:
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"src/**/*.{ts,vue}": [
"vue-tsc --noEmit",
"git add"
]
}
git commit error message :
× vue-tsc --noEmit:
src/pages/selectCommunity/selectCommunity.vue(41,44): error TS2307: Cannot find module '@/api/community-api' or its corresponding type declarations.
pre-commit hook failed (add --no-verify to bypass)
But,Run vue-tsc --noEmit alone without error, alias ‘@/’ path can pass the validation.
tsconfig.json alias path configuration:
"baseUrl": ".",
"paths": {
"@/components/*": ["./src/components/*"],
"@/utils/*": ["./src/utils/*"],
"@/assets/*": ["./src/assets/*"],
"@/api/*": ["./src/api/*"],
"@/router/*": ["./src/router/*"],
"@/pages/*": ["./src/pages/*"],
}
I guess lint-staged pick a different tsconfig / jsconfig but I can't confirm, please provide a repro case.