0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

feat: errors

This commit is contained in:
Florian Lefebvre 2024-08-20 15:34:51 +02:00
parent 89aba33116
commit 0377fb9b4c
2 changed files with 39 additions and 9 deletions

View file

@ -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);
}
}

View file

@ -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