From 4b775a8d499afd83a4a75d59993666a0c1d85237 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 18 Apr 2024 11:02:50 -0400 Subject: [PATCH] fix: error for more unterminated nodes (#628) --- src/swc.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/swc.rs b/src/swc.rs index 3f4d9781..81449eb8 100644 --- a/src/swc.rs +++ b/src/swc.rs @@ -124,6 +124,12 @@ pub fn ensure_no_specific_syntax_errors(parsed_source: &ParsedSource) -> Result< SyntaxError::ExpectedDigit { .. } | SyntaxError::ExpectedSemiForExprStmt { .. } | SyntaxError::ExpectedUnicodeEscape | + // various unterminated + SyntaxError::UnterminatedStrLit | + SyntaxError::UnterminatedBlockComment | + SyntaxError::UnterminatedJSXContents | + SyntaxError::UnterminatedRegExp | + SyntaxError::UnterminatedTpl | // unexpected token SyntaxError::Unexpected { .. } | // Merge conflict marker @@ -293,6 +299,19 @@ mod tests { ); } + #[test] + fn it_should_error_for_exected_string_literal() { + run_non_fatal_diagnostic_test( + "./test.ts", + "var foo = 'test", + concat!( + "Unterminated string constant at file:///test.ts:1:11\n\n", + " var foo = 'test\n", + " ~~~~~" + ), + ); + } + #[test] fn it_should_error_for_merge_conflict_marker() { run_non_fatal_diagnostic_test(