diff options
author | 2023-08-14 15:04:45 +0100 | |
---|---|---|
committer | 2023-08-14 16:04:45 +0200 | |
commit | d1f7143f9caf2ffa0e87cc55c0e05339d3501db3 (patch) | |
tree | ec1ed543d16288fa9f4cd262c2507b88a7a3a408 | |
parent | afc45af2022f7c43fbb6c5c04983695f3819e47e (diff) | |
download | astro-d1f7143f9caf2ffa0e87cc55c0e05339d3501db3.tar.gz astro-d1f7143f9caf2ffa0e87cc55c0e05339d3501db3.tar.zst astro-d1f7143f9caf2ffa0e87cc55c0e05339d3501db3.zip |
fix(astro): strongly type Astro.self (#7866)
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
Co-authored-by: Princesseuh <princssdev@gmail.com>
-rw-r--r-- | .changeset/olive-queens-drum.md | 5 | ||||
-rw-r--r-- | packages/astro/src/@types/astro.ts | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/.changeset/olive-queens-drum.md b/.changeset/olive-queens-drum.md new file mode 100644 index 000000000..258d9c726 --- /dev/null +++ b/.changeset/olive-queens-drum.md @@ -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 />` diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index c2a7c3823..fd809e846 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -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. @@ -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) |