fix(vite): check for undefined and create types array (#19045)

This commit is contained in:
Katerina Skroumpelou 2023-09-07 15:28:09 +03:00 committed by GitHub
parent aa223621f7
commit f487929a9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -179,6 +179,12 @@ export async function viteConfigurationGenerator(
if (projectType === 'library') {
// update tsconfig.lib.json to include vite/client
updateJson(tree, joinPathFragments(root, 'tsconfig.lib.json'), (json) => {
if (!json.compilerOptions) {
json.compilerOptions = {};
}
if (!json.compilerOptions.types) {
json.compilerOptions.types = [];
}
if (!json.compilerOptions.types.includes('vite/client')) {
return {
...json,