astro/packages/astro/env.d.ts
Aleksander Heintz fcc36ac908
Make astro package play nice with node16 module resolution (#4182)
* Make astro package play nice with node16 module resolution

Projects using node16 module resolution in typescript uses the new
exports and imports configuration from typescript to find definition
files. This mirrors how nodejs resolves the files. If a package contains
an exports map in the package.json, typescript will ignore the "types"
field (not sure how it plays with typesVersions). This moves the typings
hirearchy of definition files into the same hierarchy that astro
produces output files in, so that typescript can discover them.

Fixes: #4172

* Add changeset

* Reorder export keys

* Update paths inside .d.ts files

Co-authored-by: Princesseuh <princssdev@gmail.com>
2022-08-25 14:57:11 -04:00

50 lines
1.6 KiB
TypeScript

/// <reference path="./client.d.ts" />
type Astro = import('./dist/@types/astro').AstroGlobal;
// We duplicate the description here because editors won't show the JSDoc comment from the imported type (but will for its properties, ex: Astro.request will show the AstroGlobal.request description)
/**
* Astro global available in all contexts in .astro files
*
* [Astro documentation](https://docs.astro.build/reference/api-reference/#astro-global)
*/
declare const Astro: Readonly<Astro>;
declare const Fragment: any;
declare module '*.md' {
type MD = import('./dist/@types/astro').MarkdownInstance<Record<string, any>>;
export const frontmatter: MD['frontmatter'];
export const file: MD['file'];
export const url: MD['url'];
export const getHeadings: MD['getHeadings'];
/** @deprecated Renamed to `getHeadings()` */
export const getHeaders: () => void;
export const Content: MD['Content'];
export const rawContent: MD['rawContent'];
export const compiledContent: MD['compiledContent'];
const load: MD['default'];
export default load;
}
declare module '*.mdx' {
type MDX = import('./dist/@types/astro').MDXInstance<Record<string, any>>;
export const frontmatter: MDX['frontmatter'];
export const file: MDX['file'];
export const url: MDX['url'];
export const getHeadings: MDX['getHeadings'];
export const Content: MDX['Content'];
export const rawContent: MDX['rawContent'];
export const compiledContent: MDX['compiledContent'];
const load: MDX['default'];
export default load;
}
declare module '*.html' {
const Component: { render(opts: { slots: Record<string, string> }): string };
export default Component;
}