From f487929a9ec661329b787847f2301998a65d2206 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Thu, 7 Sep 2023 15:28:09 +0300 Subject: [PATCH] fix(vite): check for undefined and create types array (#19045) --- packages/vite/src/generators/configuration/configuration.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/vite/src/generators/configuration/configuration.ts b/packages/vite/src/generators/configuration/configuration.ts index cd48539d420e6..bafa4642cae37 100644 --- a/packages/vite/src/generators/configuration/configuration.ts +++ b/packages/vite/src/generators/configuration/configuration.ts @@ -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,