compiler icon indicating copy to clipboard operation
compiler copied to clipboard

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

Open patrick91 opened this issue 1 year ago • 2 comments

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

patrick91 avatar Dec 26 '23 06:12 patrick91

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

Princesseuh avatar Dec 26 '23 14:12 Princesseuh

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

MoustaphaDev avatar Dec 26 '23 16:12 MoustaphaDev