Prerequisites
Reproduction url
https://github.com/JoshuaKGoldberg/repros/tree/astro-knip-ignoreExportsUsedInFile
Reproduction access
Description of the issue
ignoreExportsUsedInFile should make it so that all interfaces & props that are exported from a file, but also used in that file, are allowed. This works well for UI/site frameworks that allow explicitly defining components with their prop types. For example, in React, export function MyComponent({...}: MyComponentProps { / export const MyComponent: React.FC<MyComponentProps> = ... are fine.
In Astro components, however, the usage of props is implicit. Defining a shape like interface Props { ... } in a .astro file is how to indicate that file's Astro.props is that shape. But because the name Props isn't explicitly typed out in the file, Knip sees it as unused even if ignoreExportsUsedInFile is enabled.
---
export interface Props {
happy?: boolean;
}
// Astro.props is now type Props
---
<main>
<h1>
{Astro.props.happy ? "Hooray!" : "Good."}
</h1>
</main>
Proposal: can this be treated as a bug to be fixed?
Originally seen in: https://github.com/flint-fyi/flint/pull/2439/changes#r2937717265
Prerequisites
Reproduction url
https://github.com/JoshuaKGoldberg/repros/tree/astro-knip-ignoreExportsUsedInFile
Reproduction access
Description of the issue
ignoreExportsUsedInFileshould make it so that all interfaces & props that are exported from a file, but also used in that file, are allowed. This works well for UI/site frameworks that allow explicitly defining components with their prop types. For example, in React,export function MyComponent({...}: MyComponentProps {/export const MyComponent: React.FC<MyComponentProps> = ...are fine.In Astro components, however, the usage of props is implicit. Defining a shape like
interface Props { ... }in a.astrofile is how to indicate that file'sAstro.propsis that shape. But because the namePropsisn't explicitly typed out in the file, Knip sees it as unused even ifignoreExportsUsedInFileis enabled.Proposal: can this be treated as a bug to be fixed?
Originally seen in: https://github.com/flint-fyi/flint/pull/2439/changes#r2937717265