Skip to content

Commit 7fae52c

Browse files
brunolemosTimer
authored andcommitted
Use TypeScript parser to read tsconfig.json (facebook#5532)
1 parent eccf30c commit 7fae52c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

scripts/utils/verifyTypeScriptSetup.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ function verifyTypeScriptSetup() {
5252
const isYarn = fs.existsSync(paths.yarnLockFile);
5353

5454
// Ensure typescript is installed
55+
let ts;
5556
try {
56-
resolve.sync('typescript', {
57+
ts = require(resolve.sync('typescript', {
5758
basedir: paths.appNodeModules,
58-
});
59+
}));
5960
} catch (_) {
6061
console.error(
6162
chalk.red(
@@ -88,7 +89,16 @@ function verifyTypeScriptSetup() {
8889
const messages = [];
8990
let tsconfig;
9091
try {
91-
tsconfig = require(paths.appTsConfig);
92+
const { config, error } = ts.readConfigFile(
93+
paths.appTsConfig,
94+
ts.sys.readFile
95+
);
96+
97+
if (error) {
98+
throw error;
99+
}
100+
101+
tsconfig = config;
92102
} catch (_) {
93103
console.error(
94104
chalk.red.bold(

0 commit comments

Comments
 (0)