withastro / language-tools

Language tools for Astro
MIT License
242 stars 46 forks source link

🐛 BUG: @astrojs/check not working with typescript import aliases #809

Closed rafaelgimeno closed 3 months ago

rafaelgimeno commented 4 months ago

Describe the Bug

I'm using Astro version v4.4.0 & the last version of @astrojs/check v0.5.5. Also I have configured a list of aliases paths in tsconfig.json file.

When I run the task "npm run astro check", I get a lot of errors of this type: "Cannot find module '@layouts/Layout.astro' or its corresponding type declarations." (one by every component or layout imported).

It only happens with astro check, in dev mode everything works ok.

Steps to Reproduce

  1. Have an aliased folders in tsconfig.json:

    "paths": {
    "@components/*": ["src/components/*"],
    "@layouts/*": ["src/layouts/*"]
    },
  2. Use one of these aliases in an Astro file: import Layout from "@layouts/Layout.astro";

  3. Run the task astro check: npm run astro check

Princesseuh commented 4 months ago

Can you post your full config? Many people are successfully using aliases and astro check, including myself.

Princesseuh commented 3 months ago

Closing due to inactivity. Many people use astro check and import aliases together with no issues, so this is likely a configuration issue.