diff --git a/packages/astro/src/core/config/settings.ts b/packages/astro/src/core/config/settings.ts index 26c439958c..807e1d0cb6 100644 --- a/packages/astro/src/core/config/settings.ts +++ b/packages/astro/src/core/config/settings.ts @@ -144,25 +144,22 @@ function validateTsconfig(settings: AstroSettings, rawConfig: TSConfig) { return; } + // TODO: show diff each time before error (depends on https://github.com/withastro/astro/pull/11772) if (!rawConfig.extends) { - // TODO: must have extends - // must have this content at least (gen path) - throw new Error("Must have extends") + throw new AstroError(AstroErrorData.TSConfigInvalidExtends); } else if ( typeof rawConfig.extends === 'string' && rawConfig.extends !== GENERATED_TSCONFIG_PATH ) { - // TODO: must must have this content at least (gen path, array) - throw new Error('Must extend generated'); + throw new AstroError(AstroErrorData.TSConfigInvalidExtends); } else if (!rawConfig.extends.includes(GENERATED_TSCONFIG_PATH)) { - // TODO: must extends gen path - throw new Error('Must extend generated in array'); + throw new AstroError(AstroErrorData.TSConfigInvalidExtends); } if (rawConfig.include) { - throw new Error("include must be in experimental.typescript.include") + throw new AstroError(AstroErrorData.TSConfigInvalidInclude); } if (rawConfig.exclude) { - throw new Error("exclude must be in experimental.typescript.exclude") + throw new AstroError(AstroErrorData.TSConfigInvalidExclude); } } diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 475acdbbf7..433bd25ba1 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -1302,6 +1302,39 @@ export const UnknownFilesystemError = { hint: 'It can be caused by many things, eg. missing permissions or a file not existing we attempt to read. Check the error cause for more details.', } satisfies ErrorData; +/** + * @docs + * @description + * Your `tsconfig.json` `extends` property is invalid + */ +export const TSConfigInvalidExtends = { + name: 'TSConfigInvalidExtends', + title: 'Your `tsconfig.json` `extends` property is invalid', + hint: 'Check out what change you need to make in the terminal above.', +} satisfies ErrorData; + +/** + * @docs + * @description + * Your `tsconfig.json` `include` property is invalid + */ +export const TSConfigInvalidInclude = { + name: 'TSConfigInvalidInclude', + title: 'Your `tsconfig.json` `include` property is invalid', + hint: 'Check out what change you need to make in the terminal above.', +} satisfies ErrorData; + +/** + * @docs + * @description + * Your `tsconfig.json` `exclude` property is invalid + */ +export const TSConfigInvalidExclude = { + name: 'TSConfigInvalidExclude', + title: 'Your `tsconfig.json` `exclude` property is invalid', + hint: 'Check out what change you need to make in the terminal above.', +} satisfies ErrorData; + /** * @docs * @kind heading