@@ -621,7 +621,7 @@ export async function main(argv, options) {
621621 stats . parseTime += stats . end ( begin ) ;
622622 }
623623 }
624- const numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
624+ const numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
625625 if ( numErrors ) {
626626 const err = Error ( `${ numErrors } parse error(s)` ) ;
627627 err . stack = err . message ; // omit stack
@@ -730,7 +730,7 @@ export async function main(argv, options) {
730730 ? assemblyscript . getBinaryenModuleRef ( module )
731731 : module . ref
732732 ) ;
733- var numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
733+ var numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
734734 if ( numErrors ) {
735735 const err = Error ( `${ numErrors } compile error(s)` ) ;
736736 err . stack = err . message ; // omit stack
@@ -743,7 +743,7 @@ export async function main(argv, options) {
743743 if ( error ) return prepareResult ( error ) ;
744744 }
745745
746- numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
746+ numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
747747 if ( numErrors ) {
748748 const err = Error ( `${ numErrors } afterCompile error(s)` ) ;
749749 err . stack = err . message ; // omit stack
@@ -1123,17 +1123,22 @@ async function getConfig(file, baseDir, readFile) {
11231123}
11241124
11251125/** Checks diagnostics emitted so far for errors. */
1126- export function checkDiagnostics ( program , stderr , reportDiagnostic , useColors ) {
1126+ export function checkDiagnostics ( program , stderr , disableWarning , reportDiagnostic , useColors ) {
11271127 if ( typeof useColors === "undefined" && stderr ) useColors = stderr . isTTY ;
11281128 var numErrors = 0 ;
11291129 do {
11301130 let diagnostic = assemblyscript . nextDiagnostic ( program ) ;
11311131 if ( ! diagnostic ) break ;
11321132 if ( stderr ) {
1133- stderr . write (
1134- assemblyscript . formatDiagnostic ( diagnostic , useColors , true ) +
1135- EOL + EOL
1136- ) ;
1133+ const isDisabledWarning = ( diagnostic ) => {
1134+ if ( disableWarning == null ) return false ;
1135+ if ( ! disableWarning . length ) return true ;
1136+ const code = assemblyscript . getDiagnosticCode ( diagnostic ) ;
1137+ return disableWarning . includes ( code ) ;
1138+ } ;
1139+ if ( assemblyscript . isError ( diagnostic ) || ! isDisabledWarning ( diagnostic ) ) {
1140+ stderr . write ( assemblyscript . formatDiagnostic ( diagnostic , useColors , true ) + EOL + EOL ) ;
1141+ }
11371142 }
11381143 if ( reportDiagnostic ) {
11391144 function wrapRange ( range ) {
0 commit comments