Skip to content

Commit

Permalink
Use TypeScript parser to read tsconfig.json (facebook#5532)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolemos authored and Timer committed Oct 22, 2018
1 parent eccf30c commit 7fae52c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scripts/utils/verifyTypeScriptSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7fae52c

Please sign in to comment.