File tree 1 file changed +12
-3
lines changed
packages/react-scripts/scripts/utils
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,12 @@ function verifyTypeScriptSetup() {
103
103
} ,
104
104
} ;
105
105
106
+ const formatDiagnosticHost = {
107
+ getCanonicalFileName : fileName => fileName ,
108
+ getCurrentDirectory : ts . sys . getCurrentDirectory ,
109
+ getNewLine : ( ) => os . EOL ,
110
+ } ;
111
+
106
112
const messages = [ ] ;
107
113
let appTsConfig ;
108
114
let parsedTsConfig ;
@@ -114,7 +120,7 @@ function verifyTypeScriptSetup() {
114
120
) ;
115
121
116
122
if ( error ) {
117
- throw error ;
123
+ throw new Error ( ts . formatDiagnostic ( error , formatDiagnosticHost ) ) ;
118
124
}
119
125
120
126
appTsConfig = readTsConfig ;
@@ -132,18 +138,21 @@ function verifyTypeScriptSetup() {
132
138
} ) ;
133
139
134
140
if ( result . errors && result . errors . length ) {
135
- throw result . errors [ 0 ] ;
141
+ throw new Error (
142
+ ts . formatDiagnostic ( result . errors [ 0 ] , formatDiagnosticHost )
143
+ ) ;
136
144
}
137
145
138
146
parsedCompilerOptions = result . options ;
139
- } catch ( _ ) {
147
+ } catch ( e ) {
140
148
console . error (
141
149
chalk . red . bold (
142
150
'Could not parse' ,
143
151
chalk . cyan ( 'tsconfig.json' ) + '.' ,
144
152
'Please make sure it contains syntactically correct JSON.'
145
153
)
146
154
) ;
155
+ console . error ( e && e . message ? `Details: ${ e . message } ` : '' ) ;
147
156
process . exit ( 1 ) ;
148
157
}
149
158
You can’t perform that action at this time.
0 commit comments