From 7fae52c0a267d8968adaca142de6ba09b8c560ba Mon Sep 17 00:00:00 2001 From: Bruno Lemos Date: Mon, 22 Oct 2018 15:51:32 -0300 Subject: [PATCH] Use TypeScript parser to read tsconfig.json (#5532) --- scripts/utils/verifyTypeScriptSetup.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/utils/verifyTypeScriptSetup.js b/scripts/utils/verifyTypeScriptSetup.js index b2f37244919..2205d56634e 100644 --- a/scripts/utils/verifyTypeScriptSetup.js +++ b/scripts/utils/verifyTypeScriptSetup.js @@ -52,10 +52,11 @@ function verifyTypeScriptSetup() { const isYarn = fs.existsSync(paths.yarnLockFile); // Ensure typescript is installed + let ts; try { - resolve.sync('typescript', { + ts = require(resolve.sync('typescript', { basedir: paths.appNodeModules, - }); + })); } catch (_) { console.error( chalk.red( @@ -88,7 +89,16 @@ function verifyTypeScriptSetup() { const messages = []; let tsconfig; try { - tsconfig = require(paths.appTsConfig); + const { config, error } = ts.readConfigFile( + paths.appTsConfig, + ts.sys.readFile + ); + + if (error) { + throw error; + } + + tsconfig = config; } catch (_) { console.error( chalk.red.bold(