@@ -316,15 +257,13 @@ impl fmt::Display for DiagnosticItem {
fnfmt(&self,f:&mutfmt::Formatter)->fmt::Result{
write!(
f,
"{}{}{}{}{}",
self.format_source_name(0),
"{}{}\n\n► {}{}{}",
self.format_category_and_code(),
self.format_message(0),
self.format_source_name(),
self.format_source_line(0),
self.format_related_info(),
)?;
Ok(())
)
}
}
...
...
@@ -655,14 +594,14 @@ mod tests {
#[test]
fndiagnostic_to_string1(){
letd=diagnostic1();
letexpected="deno/tests/complex_diagnostics.ts:19:3 - 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\n19 values: o => [\n ~~~~~~\n\n deno/tests/complex_diagnostics.ts:7:3 \n\n 7 values?: (r: T) => Array<Value<T>>;\n ~~~~~~\n The expected type comes from property \'values\' which is declared here on type \'SettingsInterface<B>\'\n";
letexpected="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\n► deno/tests/complex_diagnostics.ts:19:3\n\n19 values: o => [\n ~~~~~~\n\n The expected type comes from property \'values\' which is declared here on type \'SettingsInterface<B>\'\n\n ► deno/tests/complex_diagnostics.ts:7:3\n\n 7 values?: (r: T) => Array<Value<T>>;\n ~~~~~~\n\n";
write!(f," at {} ({})",function_name,script_line_column)
}elseifframe.is_eval{
write!(f," at eval ({})",script_line_column)
}else{
write!(f," at {}",script_line_column)
}
}
}
#[cfg(test)]
modtests{
usesuper::*;
usecrate::ansi::strip_ansi_codes;
fnerror1()->JSError{
JSError{
message:"Error: foo bar".to_string(),
source_line:None,
script_resource_name:None,
line_number:None,
start_position:None,
end_position:None,
error_level:None,
start_column:None,
end_column:None,
frames:vec![
StackFrame{
line:4,
column:16,
script_name:"foo_bar.ts".to_string(),
function_name:"foo".to_string(),
is_eval:false,
is_constructor:false,
is_wasm:false,
},
StackFrame{
line:5,
column:20,
script_name:"bar_baz.ts".to_string(),
function_name:"qat".to_string(),
is_eval:false,
is_constructor:false,
is_wasm:false,
},
StackFrame{
line:1,
column:1,
script_name:"deno_main.js".to_string(),
function_name:"".to_string(),
is_eval:false,
is_constructor:false,
is_wasm:false,
},
],
}
}
#[test]
fnjs_error_to_string(){
lete=error1();
assert_eq!("error: Error: foo bar\n at foo (foo_bar.ts:5:17)\n at qat (bar_baz.ts:6:21)\n at deno_main.js:2:2",strip_ansi_codes(&JSErrorColor(&e).to_string()));
[WILDCARD]/tests/error_003_typescript.ts:20:3 - error TS2322: Type '(o: T) => { v: any; f: (x: B) => string; }[]' is not assignable to type '(r: B) => Value<B>[]'.
[WILDCARD]error TS2322: Type '(o: T) => { v: any; f: (x: B) => string; }[]' is not assignable to type '(r: B) => Value<B>[]'.
Types of parameters 'o' and 'r' are incompatible.
Type 'B' is not assignable to type 'T'.
'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
[WILDCARD]tests/error_003_typescript.ts:20:3
20 values: o => [
~~~~~~
[WILDCARD]/tests/error_003_typescript.ts:8:3
The expected type comes from property 'values' which is declared here on type 'C<B>'
[WILDCARD]tests/error_003_typescript.ts:8:3
8 values?: (r: T) => Array<Value<T>>;
~~~~~~
The expected type comes from property 'values' which is declared here on type 'C<B>'
[WILDCARD]/tests/error_003_typescript.ts:22:12 - error TS2339: Property 't' does not exist on type 'T'.
error TS2339: Property 't' does not exist on type 'T'.