withastro / compiler

The Astro compiler. Written in Go. Distributed as WASM.
Other
503 stars 59 forks source link

🐛 BUG: using `as` a prop name cause Props to not be recognized in TSX #927

Open patrick91 opened 11 months ago

patrick91 commented 11 months ago

Describe the Bug

Having as as Prop gives this error: 'Props' is declared but never used`

here's a small reproduction

---
interface Props {
  as?: string;
  href?: string;
}

const { as: Component, href } = Astro.props;

const level = Component.replace("h", "");

const className = `typography-heading-${level}`;
---

<Component id={href.replace("#", "")}>
  <a href={href}>
    <slot />
  </a>
</Component>

Steps to Reproduce

using typescript and the strictest settings and then running build or astro check

Princesseuh commented 11 months ago

Compiler playground, having as as a prop breaks the Props recognition, could be related to https://github.com/withastro/compiler/issues/878 maybe?

MoustaphaDev commented 11 months ago

This likely regressed in https://github.com/withastro/compiler/pull/817