Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CallToAction incorrectly extends HTMLAttributes #396

Closed
dawaltconley opened this issue Mar 24, 2024 · 3 comments
Closed

CallToAction incorrectly extends HTMLAttributes #396

dawaltconley opened this issue Mar 24, 2024 · 3 comments
Assignees

Comments

@dawaltconley
Copy link
Contributor

dawaltconley commented Mar 24, 2024

HTMLAttributes takes a string as its generic, currently it's being passed an undefined type a.

export interface CallToAction extends HTMLAttributes<a> {
  // ...
}

However, Astro throws type errors if pass a type like this to a component with spread syntax, because of the slot property. So the correct typing would be:

export interface CallToAction extends Omit<HTMLAttributes<'a'>, 'slot'> {
  // ...
}
@prototypa
Copy link
Contributor

Hi @dawaltconley

Thank you for this. Let's work on it. If you have noticed more details like this related to typescript, please let us know.

@dawaltconley
Copy link
Contributor Author

Sure, I can collect in a fork. The main other thing I've noticed is typecasting Astro.props, I believe this doesn't enforce typings when passing props to astro components. I.e. in the Content widget:

import type { Content } from '~/types';
const {
   // ...props...
} = Astro.props as Content;

This should be changed to

import type { Content } from '~/types';
export type Props = Content // astro uses a type/interface of this name to type its props
const {
   // ...props...
} = Astro.props;

or just

import type { Content as Props } from '~/types';
const {
   // ...props...
} = Astro.props;

@prototypa
Copy link
Contributor

Hi @dawaltconley

With your PR and with some adjustments that I made based on the comment you put in the PR about missing types, AstroWind now passes the astro check validation

Thanks, I'm going to close the Issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants