@@ -122,14 +122,30 @@ export function run(filePaths, options) {
122122 }
123123
124124 const program = TypeProcessor . createProgram ( [ ...filePaths , ...globalFiles ] , configParseResult . options ) ;
125- const diagnostics = program . getSemanticDiagnostics ( ) ;
126- if ( diagnostics . length > 0 ) {
125+
126+ const formatDiagnostics = ( diagnostics , kind ) => {
127+ if ( diagnostics . length === 0 ) return null ;
127128 const message = ts . formatDiagnosticsWithColorAndContext ( diagnostics , {
128129 getCanonicalFileName : ( fileName ) => fileName ,
129130 getNewLine : ( ) => ts . sys . newLine ,
130131 getCurrentDirectory : ( ) => ts . sys . getCurrentDirectory ( ) ,
131132 } ) ;
132- throw new Error ( `TypeScript semantic errors:\n${ message } ` ) ;
133+ return `${ kind } errors:\n${ message } ` ;
134+ } ;
135+
136+ const syntaxErrors = formatDiagnostics ( program . getSyntacticDiagnostics ( ) , "TypeScript syntax" ) ;
137+ if ( syntaxErrors ) {
138+ throw new Error ( syntaxErrors ) ;
139+ }
140+
141+ const optionErrors = formatDiagnostics ( program . getOptionsDiagnostics ( ) , "TypeScript option" ) ;
142+ if ( optionErrors ) {
143+ throw new Error ( optionErrors ) ;
144+ }
145+
146+ const semanticErrors = formatDiagnostics ( program . getSemanticDiagnostics ( ) , "TypeScript semantic" ) ;
147+ if ( semanticErrors ) {
148+ throw new Error ( semanticErrors ) ;
133149 }
134150
135151 const prelude = [
@@ -244,6 +260,13 @@ export function main(args) {
244260 cleanup ( ) ;
245261 }
246262 }
263+
264+ if ( swiftOutput . length === 0 ) {
265+ diagnosticEngine . print (
266+ "warning" ,
267+ "No Swift declarations were generated. This usually means the .d.ts contained constructs that BridgeJS cannot import."
268+ ) ;
269+ }
247270 // Write to file or stdout
248271 if ( options . values . output && options . values . output !== "-" ) {
249272 if ( swiftOutput . length > 0 ) {
0 commit comments