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

Export AstroConfigType properly as type and not as a Zod schema value #7702

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/green-islands-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix AstroConfigSchema type export
5 changes: 2 additions & 3 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import type { AddressInfo } from 'node:net';
import type * as rollup from 'rollup';
import type { TsConfigJson } from 'tsconfig-resolver';
import type * as vite from 'vite';
import type { z } from 'zod';
import type { SerializedSSRManifest } from '../core/app/types';
import type { PageBuildData } from '../core/build/types';
import type { AstroConfigSchema } from '../core/config';
import type { AstroConfigType } from '../core/config';
import type { AstroTimer } from '../core/config/timer';
import type { AstroCookies } from '../core/cookies';
import type { LogOptions, LoggerLevel } from '../core/logger/core';
Expand Down Expand Up @@ -1352,7 +1351,7 @@ export interface ResolvedInjectedRoute extends InjectedRoute {
* Resolved Astro Config
* Config with user settings along with all defaults filled in.
*/
export interface AstroConfig extends z.output<typeof AstroConfigSchema> {
export interface AstroConfig extends AstroConfigType {
// Public:
// This is a more detailed type than zod validation gives us.
// TypeScript still confirms zod validation matches this type.
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { resolveConfig, resolveConfigPath, resolveFlags, resolveRoot } from './config.js';
export { createNodeLogging } from './logging.js';
export { mergeConfig } from './merge.js';
export type { AstroConfigSchema } from './schema';
export type { AstroConfigType } from './schema';
export { createSettings } from './settings.js';
export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js';
2 changes: 2 additions & 0 deletions packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ export const AstroConfigSchema = z.object({
legacy: z.object({}).optional().default({}),
});

export type AstroConfigType = z.infer<typeof AstroConfigSchema>;

export function createRelativeSchema(cmd: string, fileProtocolRoot: string) {
// We need to extend the global schema to add transforms that are relative to root.
// This is type checked against the global schema to make sure we still match.
Expand Down