From aca2489992a5206ae5c2c7a57a5a0585f2953610 Mon Sep 17 00:00:00 2001 From: Alexey Solovyov Date: Mon, 4 Mar 2024 01:25:23 +0300 Subject: [PATCH] feat: support extends when parsing tsconfig.json file (#1) --- src/plugin.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index 4d66074..e63b3c5 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -68,14 +68,17 @@ function prepareCompilerOptions(cache: Map, file: strin ?? ts.findConfigFile(file, ts.sys.fileExists); if (location) { - const parsed = ts.readConfigFile(location, ts.sys.readFile); + const { config, error } = ts.readConfigFile(location, ts.sys.readFile); - if (parsed.error) { - throw parsed.error; + if (error) { + throw error; } + const configLocation = dirname(location) + const { options: tsconfigOptions } = ts.parseJsonConfigFileContent(config, ts.sys, configLocation) + const compilerOptions = { - ...parsed.config.compilerOptions, + ...tsconfigOptions, ...options?.tsconfig?.override, } satisfies CompilerOptions;