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 nate770 committed Oct 30, 2018
1 parent 876a738 commit 2eb0f82
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/react-scripts/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 2eb0f82

Please sign in to comment.