summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/diagnostics.rs16
-rw-r--r--cli/fmt_errors.rs6
-rw-r--r--cli/lib.rs7
-rw-r--r--cli/tests/038_checkjs.js.out5
-rw-r--r--cli/tests/config.ts.out2
-rw-r--r--cli/tests/error_003_typescript.ts.out3
-rw-r--r--cli/tests/error_013_missing_script.out2
-rw-r--r--cli/tests/error_017_hide_long_source_ts.ts.out3
-rw-r--r--cli/tests/error_local_static_import_from_remote.js.out2
-rw-r--r--cli/tests/unstable_disabled.out2
10 files changed, 25 insertions, 23 deletions
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs
index a21ba654f..0c81ce79e 100644
--- a/cli/diagnostics.rs
+++ b/cli/diagnostics.rs
@@ -89,18 +89,16 @@ fn format_category_and_code(
code: i64,
) -> String {
let category = match category {
- DiagnosticCategory::Error => {
- format!("{}", colors::red_bold("error".to_string()))
- }
- DiagnosticCategory::Warning => "warn".to_string(),
- DiagnosticCategory::Debug => "debug".to_string(),
- DiagnosticCategory::Info => "info".to_string(),
+ DiagnosticCategory::Error => "ERROR".to_string(),
+ DiagnosticCategory::Warning => "WARN".to_string(),
+ DiagnosticCategory::Debug => "DEBUG".to_string(),
+ DiagnosticCategory::Info => "INFO".to_string(),
_ => "".to_string(),
};
let code = colors::bold(format!("TS{}", code.to_string())).to_string();
- format!("{} {}", category, code)
+ format!("{} [{}]", code, category)
}
fn format_message(
@@ -433,14 +431,14 @@ mod tests {
#[test]
fn diagnostic_to_string1() {
let d = diagnostic1();
- let expected = "error TS2322: Type \'(o: T) => { v: any; f: (x: B) => string; }[]\' is not assignable to type \'(r: B) => Value<B>[]\'.\n Types of parameters \'o\' and \'r\' are incompatible.\n Type \'B\' is not assignable to type \'T\'.\n values: o => [\n ~~~~~~\n at deno/tests/complex_diagnostics.ts:19:3\n\n The expected type comes from property \'values\' which is declared here on type \'SettingsInterface<B>\'\n values?: (r: T) => Array<Value<T>>;\n ~~~~~~\n at deno/tests/complex_diagnostics.ts:7:3";
+ let expected = "TS2322 [ERROR]: Type \'(o: T) => { v: any; f: (x: B) => string; }[]\' is not assignable to type \'(r: B) => Value<B>[]\'.\n Types of parameters \'o\' and \'r\' are incompatible.\n Type \'B\' is not assignable to type \'T\'.\n values: o => [\n ~~~~~~\n at deno/tests/complex_diagnostics.ts:19:3\n\n The expected type comes from property \'values\' which is declared here on type \'SettingsInterface<B>\'\n values?: (r: T) => Array<Value<T>>;\n ~~~~~~\n at deno/tests/complex_diagnostics.ts:7:3";
assert_eq!(expected, strip_ansi_codes(&d.to_string()));
}
#[test]
fn diagnostic_to_string2() {
let d = diagnostic2();
- let expected = "error TS2322: Example 1\n values: o => [\n ~~~~~~\n at deno/tests/complex_diagnostics.ts:19:3\n\nerror TS2000: Example 2\n values: undefined,\n ~~~~~~\n at /foo/bar.ts:129:3\n\nFound 2 errors.";
+ let expected = "TS2322 [ERROR]: Example 1\n values: o => [\n ~~~~~~\n at deno/tests/complex_diagnostics.ts:19:3\n\nTS2000 [ERROR]: Example 2\n values: undefined,\n ~~~~~~\n at /foo/bar.ts:129:3\n\nFound 2 errors.";
assert_eq!(expected, strip_ansi_codes(&d.to_string()));
}
diff --git a/cli/fmt_errors.rs b/cli/fmt_errors.rs
index 7317d7fc0..c8dfc625a 100644
--- a/cli/fmt_errors.rs
+++ b/cli/fmt_errors.rs
@@ -150,11 +150,7 @@ impl fmt::Display for JSError {
"{}",
&format_stack(
true,
- format!(
- "{}: {}",
- colors::red_bold("error".to_string()),
- self.0.message.clone()
- ),
+ self.0.message.clone(),
self.0.source_line.clone(),
self.0.start_column,
self.0.end_column,
diff --git a/cli/lib.rs b/cli/lib.rs
index 957637719..97b497e95 100644
--- a/cli/lib.rs
+++ b/cli/lib.rs
@@ -626,7 +626,12 @@ pub fn main() {
let result = tokio_util::run_basic(fut);
if let Err(err) = result {
- eprintln!("{}", err.to_string());
+ let msg = format!(
+ "{}: {}",
+ colors::red_bold("error".to_string()),
+ err.to_string(),
+ );
+ eprintln!("{}", msg);
std::process::exit(1);
}
}
diff --git a/cli/tests/038_checkjs.js.out b/cli/tests/038_checkjs.js.out
index 92b8e2fd0..452290272 100644
--- a/cli/tests/038_checkjs.js.out
+++ b/cli/tests/038_checkjs.js.out
@@ -1,4 +1,5 @@
-[WILDCARD]error TS2552: Cannot find name 'consol'. Did you mean 'console'?
+[WILDCARD]
+error: TS2552 [ERROR]: Cannot find name 'consol'. Did you mean 'console'?
consol.log("hello world!");
~~~~~~
at [WILDCARD]tests/038_checkjs.js:2:1
@@ -8,7 +9,7 @@ consol.log("hello world!");
~~~~~~~
at [WILDCARD]
-error TS2552: Cannot find name 'Foo'. Did you mean 'foo'?
+TS2552 [ERROR]: Cannot find name 'Foo'. Did you mean 'foo'?
const foo = new Foo();
~~~
at [WILDCARD]tests/038_checkjs.js:6:17
diff --git a/cli/tests/config.ts.out b/cli/tests/config.ts.out
index b08761ac1..8f5cf7e39 100644
--- a/cli/tests/config.ts.out
+++ b/cli/tests/config.ts.out
@@ -1,7 +1,7 @@
[WILDCARD]Unsupported compiler options in "[WILDCARD]config.tsconfig.json"
The following options were ignored:
module, target
-error TS2532: Object is possibly 'undefined'.
+error: TS2532 [ERROR]: Object is possibly 'undefined'.
if (map.get("bar").foo) {
~~~~~~~~~~~~~~
at [WILDCARD]tests/config.ts:3:5
diff --git a/cli/tests/error_003_typescript.ts.out b/cli/tests/error_003_typescript.ts.out
index ba113d12c..49cd274f4 100644
--- a/cli/tests/error_003_typescript.ts.out
+++ b/cli/tests/error_003_typescript.ts.out
@@ -1,4 +1,5 @@
-[WILDCARD]error TS2322: Type '{ a: { b: { c(): { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c(): { d: string; }; }; }; }'.
+[WILDCARD]
+error: TS2322 [ERROR]: Type '{ a: { b: { c(): { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c(): { d: string; }; }; }; }'.
The types of 'a.b.c().d' are incompatible between these types.
Type 'number' is not assignable to type 'string'.
x = y;
diff --git a/cli/tests/error_013_missing_script.out b/cli/tests/error_013_missing_script.out
index 9836c361f..35aaec9be 100644
--- a/cli/tests/error_013_missing_script.out
+++ b/cli/tests/error_013_missing_script.out
@@ -1 +1 @@
-Cannot resolve module "[WILDCARD]missing_file_name"
+error: Cannot resolve module "[WILDCARD]missing_file_name"
diff --git a/cli/tests/error_017_hide_long_source_ts.ts.out b/cli/tests/error_017_hide_long_source_ts.ts.out
index 6606c8523..6799a94cc 100644
--- a/cli/tests/error_017_hide_long_source_ts.ts.out
+++ b/cli/tests/error_017_hide_long_source_ts.ts.out
@@ -1,2 +1,3 @@
-[WILDCARD]error TS2532: Object is possibly 'undefined'.
+[WILDCARD]
+error: TS2532 [ERROR]: Object is possibly 'undefined'.
at [WILDCARD]tests/error_017_hide_long_source_ts.ts:2:1
diff --git a/cli/tests/error_local_static_import_from_remote.js.out b/cli/tests/error_local_static_import_from_remote.js.out
index 99e4b94c7..4e6a9d4e7 100644
--- a/cli/tests/error_local_static_import_from_remote.js.out
+++ b/cli/tests/error_local_static_import_from_remote.js.out
@@ -1,2 +1,2 @@
[WILDCARD]
-Remote module are not allowed to statically import local modules. Use dynamic import instead.
+error: Remote module are not allowed to statically import local modules. Use dynamic import instead.
diff --git a/cli/tests/unstable_disabled.out b/cli/tests/unstable_disabled.out
index ca88df9c8..695ca122c 100644
--- a/cli/tests/unstable_disabled.out
+++ b/cli/tests/unstable_disabled.out
@@ -1,5 +1,5 @@
[WILDCARD]
-error TS2339: Property 'loadavg' does not exist on type 'typeof Deno'.
+error: TS2339 [ERROR]: Property 'loadavg' does not exist on type 'typeof Deno'.
console.log(Deno.loadavg);
~~~~~~~
at [WILDCARD]/cli/tests/unstable.ts:1:18