Skip to content

Commit

Permalink
Export AstroConfigType properly as type and not as a Zod schema value (
Browse files Browse the repository at this point in the history
  • Loading branch information
shishkin committed Aug 15, 2023
1 parent 1e99021 commit c19987d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-islands-repeat.md
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix AstroConfigSchema type export
5 changes: 2 additions & 3 deletions packages/astro/src/@types/astro.ts
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 @@ -1354,7 +1353,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
@@ -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
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

0 comments on commit c19987d

Please sign in to comment.