From b1d548024f4e0ccf24332e04b2ee39689764dbb6 Mon Sep 17 00:00:00 2001 From: york yao Date: Sat, 3 Nov 2018 17:55:19 +0800 Subject: [PATCH] feat: when tsconfig.json file not exist, use empty config --- spec/result.txt | 4 ++-- src/tsconfig.ts | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/spec/result.txt b/spec/result.txt index 93abdb3..b615d2a 100644 --- a/spec/result.txt +++ b/spec/result.txt @@ -1,4 +1,4 @@ -src/tsconfig.ts:35:31: config +src/tsconfig.ts:32:57: config src/core.ts:30:45: intrinsicName src/core.ts:39:159: intrinsicName src/index.ts:15:37: v @@ -11,5 +11,5 @@ src/index.ts:23:106: debug src/index.ts:44:4: error src/index.ts:45:7: error src/index.ts:48:17: error -3180 / 3193 99.59% +3178 / 3191 99.59% type-coverage success. diff --git a/src/tsconfig.ts b/src/tsconfig.ts index 686b457..77f394a 100644 --- a/src/tsconfig.ts +++ b/src/tsconfig.ts @@ -29,10 +29,7 @@ type JsonConfig = { export function getTsConfig(configFilePath: string, dirname: string): JsonConfig { const configResult = ts.readConfigFile(configFilePath, p => fs.readFileSync(p).toString()) - if (configResult.error) { - throw configResult.error - } - const config = configResult.config as JsonConfig + const config = configResult.error ? {} : configResult.config as JsonConfig if (config.extends) { const project = path.resolve(dirname, config.extends) const { configFilePath, dirname: extendsBasename } = getTsConfigFilePath(project)