@@ -621,7 +621,7 @@ export async function main(argv, options) {
621
621
stats . parseTime += stats . end ( begin ) ;
622
622
}
623
623
}
624
- const numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
624
+ const numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
625
625
if ( numErrors ) {
626
626
const err = Error ( `${ numErrors } parse error(s)` ) ;
627
627
err . stack = err . message ; // omit stack
@@ -730,7 +730,7 @@ export async function main(argv, options) {
730
730
? assemblyscript . getBinaryenModuleRef ( module )
731
731
: module . ref
732
732
) ;
733
- var numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
733
+ var numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
734
734
if ( numErrors ) {
735
735
const err = Error ( `${ numErrors } compile error(s)` ) ;
736
736
err . stack = err . message ; // omit stack
@@ -743,7 +743,7 @@ export async function main(argv, options) {
743
743
if ( error ) return prepareResult ( error ) ;
744
744
}
745
745
746
- numErrors = checkDiagnostics ( program , stderr , options . reportDiagnostic , stderrColors . enabled ) ;
746
+ numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
747
747
if ( numErrors ) {
748
748
const err = Error ( `${ numErrors } afterCompile error(s)` ) ;
749
749
err . stack = err . message ; // omit stack
@@ -1123,17 +1123,22 @@ async function getConfig(file, baseDir, readFile) {
1123
1123
}
1124
1124
1125
1125
/** Checks diagnostics emitted so far for errors. */
1126
- export function checkDiagnostics ( program , stderr , reportDiagnostic , useColors ) {
1126
+ export function checkDiagnostics ( program , stderr , disableWarning , reportDiagnostic , useColors ) {
1127
1127
if ( typeof useColors === "undefined" && stderr ) useColors = stderr . isTTY ;
1128
1128
var numErrors = 0 ;
1129
1129
do {
1130
1130
let diagnostic = assemblyscript . nextDiagnostic ( program ) ;
1131
1131
if ( ! diagnostic ) break ;
1132
1132
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
+ }
1137
1142
}
1138
1143
if ( reportDiagnostic ) {
1139
1144
function wrapRange ( range ) {
0 commit comments