Skip to content

Commit

Permalink
fix(astro): strongly type Astro.self (#7866)
Browse files Browse the repository at this point in the history
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
Co-authored-by: Princesseuh <princssdev@gmail.com>
  • Loading branch information
3 people authored Aug 14, 2023
1 parent afc45af commit d1f7143
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-queens-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Add second type argument to the AstroGlobal type to type Astro.self. This change will ultimately allow our editor tooling to provide props completions and intellisense for `<Astro.self />`
8 changes: 5 additions & 3 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ export interface CLIFlags {
*
* [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global)
*/
export interface AstroGlobal<Props extends Record<string, any> = Record<string, any>>
extends AstroGlobalPartial,
export interface AstroGlobal<
Props extends Record<string, any> = Record<string, any>,
Self = AstroComponentFactory
> extends AstroGlobalPartial,
AstroSharedContext<Props> {
/**
* A full URL object of the request URL.
Expand Down Expand Up @@ -217,7 +219,7 @@ export interface AstroGlobal<Props extends Record<string, any> = Record<string,
*
* [Astro reference](https://docs.astro.build/en/guides/api-reference/#astroself)
*/
self: AstroComponentFactory;
self: Self;
/** Utility functions for modifying an Astro component’s slotted children
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
Expand Down

0 comments on commit d1f7143

Please sign in to comment.