language-tools: šŸ› BUG: astro check reports incorrect errors on HTMLAttributes

Describe the Bug

While this worked as expected in Astro 4.0.4, astro check now reports entirely valid JSX attributes as invalid HTMLAttributes. I’ve created a tiny reproduction here: https://stackblitz.com/edit/github-ckecs3?file=package.json. Running npm run check will show that both onClick and className are invalid, even though both are in fact valid JSX props.

Steps to Reproduce

  1. Run npm create astro@latest -- --template framework-preact
  2. Add "check": "astro check:" to the scripts section
  3. Run npm run check
  4. The valid onClick attributes are considered errors. Now, changing one of the class attributes to className (which is valid) will also show that as an error.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 20
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Just released a hotfix (0.3.4) that disable checking JSX and TSX files in the meantime. Sorry again for the inconvenience, I’m still working on it and will hopefully find a solution 🫔

Unfortunately, downgrading to 0.3.2 didn’t fix it for me

You might need to override the language-server version manually, unfortunately. Hoping to have a fix out today, sorry for the delay.

I have the same problem with React component.

Okay, this is proving to be much harder than anticipated due to bugs in TypeScript itself. It’ll take more time to figure out, so in the meantime I’ll revert the astro check fix to what it did before (where it skipped over .js(x) files).

Sorry for the inconvenience, TypeScript really wasn’t made to have multiple JSX typings in the same project.

Unfortunately, downgrading to 0.3.2 didn’t fix it for me

I’ll take a look once I’m back to work next week (if someone doesn’t before me). Apologies for the inconvenience.

In the meantime, pinning @astrojs/check to 0.3.2 would at least make it not fail (but would go back to the behavior where it didn’t check certain files)

I’m seeing the same error with my solidjs components.

Hmm, seems like it’s not taking into account the tsconfig.json correctly, for some reason. To be clear, this also didn’t work in the past, it’s just that I recently fixed a bug where it ignored errors completely inside certain files.

Make sure to update to the latest version of @astrojs/check for a temporary workaround!

TypeScript really wasn’t made to have multiple JSX typings in the same project.

Indeed, though this worked for me in the past (prior to noticing this issue just the other day):

tsconfig.json:

{
  "extends": "astro/tsconfigs/strict",
  "compilerOptions": {
    "rootDirs": [
      "./src/components/preact",
      "./src/components/react",
      "./src/components/solid"
    ]
  }
}

src/components/preact/tsconfig.json:

{
  "compilerOptions": {
    "module": "NodeNext",
    "jsx": "react-jsx",
    "jsxImportSource": "preact"
  }
}

src/components/react/tsconfig.json:

{
  "compilerOptions": {
    "module": "NodeNext",
    "jsx": "react-jsx"
  }
}

src/components/solid/tsconfig.json:

{
  "compilerOptions": {
    "module": "NodeNext",
    "jsx": "preserve",
    "jsxImportSource": "solid-js"
  }
}

astro.config.mjs:

import { defineConfig } from "astro/config";
import preact from "@astrojs/preact";
import react from "@astrojs/react";
import solid from "@astrojs/solid-js";

// https://astro.build/config
export default defineConfig({
  integrations: [
    preact({ include: ["**/preact/**"] }),
    react({ include: ["**/react/**"] }),
    solid({ include: ["**/solid/**"] }),
  ],
});