mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix(ext/console): log class for class constructor (#17615)
Co-authored-by: tannal <tannal.cn@gmail.com>
This commit is contained in:
parent
1e75e5ecc7
commit
0eb5be9a12
8 changed files with 21 additions and 14 deletions
|
@ -375,7 +375,7 @@ fn typescript_decorators() {
|
|||
Some(vec![("NO_COLOR".to_owned(), "1".to_owned())]),
|
||||
false,
|
||||
);
|
||||
assert_ends_with!(out, "undefined\n[Function: Test]\n2\n");
|
||||
assert_ends_with!(out, "undefined\n[Class: Test]\n2\n");
|
||||
assert!(err.is_empty());
|
||||
}
|
||||
|
||||
|
@ -943,7 +943,7 @@ fn npm_packages() {
|
|||
);
|
||||
|
||||
assert_contains!(out, "Module {");
|
||||
assert_contains!(out, "Chalk: [Function: Chalk],");
|
||||
assert_contains!(out, "Chalk: [Class: Chalk],");
|
||||
assert!(err.is_empty());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
Node esm importing node cjs
|
||||
===========================
|
||||
{ default: [Function], named: [Function], MyClass: [Function: MyClass] }
|
||||
{ default: [Function], named: [Function], MyClass: [Class: MyClass] }
|
||||
{ default: [Function], named: [Function] }
|
||||
Module {
|
||||
MyClass: [Function: MyClass],
|
||||
MyClass: [Class: MyClass],
|
||||
__esModule: true,
|
||||
default: { default: [Function], named: [Function], MyClass: [Function: MyClass] },
|
||||
default: { default: [Function], named: [Function], MyClass: [Class: MyClass] },
|
||||
named: [Function]
|
||||
}
|
||||
Module {
|
||||
|
@ -17,11 +17,11 @@ Module {
|
|||
static method
|
||||
Deno esm importing node cjs
|
||||
===========================
|
||||
{ default: [Function], named: [Function], MyClass: [Function: MyClass] }
|
||||
{ default: [Function], named: [Function], MyClass: [Class: MyClass] }
|
||||
Module {
|
||||
MyClass: [Function: MyClass],
|
||||
MyClass: [Class: MyClass],
|
||||
__esModule: true,
|
||||
default: { default: [Function], named: [Function], MyClass: [Function: MyClass] },
|
||||
default: { default: [Function], named: [Function], MyClass: [Class: MyClass] },
|
||||
named: [Function]
|
||||
}
|
||||
===========================
|
||||
|
|
|
@ -1 +1 @@
|
|||
[Function: Client]
|
||||
[Class: Client]
|
||||
|
|
2
cli/tests/testdata/run/070_location.ts.out
vendored
2
cli/tests/testdata/run/070_location.ts.out
vendored
|
@ -1,4 +1,4 @@
|
|||
[WILDCARD][Function: Location]
|
||||
[WILDCARD][Class: Location]
|
||||
Location {}
|
||||
Location {
|
||||
hash: "#bat",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[WILDCARD][Function: Location]
|
||||
[WILDCARD][Class: Location]
|
||||
Location {}
|
||||
undefined
|
||||
/bar
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
loading [WILDCARD]a.js
|
||||
loaded Module { default: [Function: Foo] }
|
||||
loaded Module { default: [Class: Foo] }
|
||||
loading [WILDCARD]b.js
|
||||
loaded Module { default: [Function: Bar] }
|
||||
loaded Module { default: [Class: Bar] }
|
||||
all loaded
|
||||
|
|
|
@ -237,7 +237,7 @@ Deno.test(function consoleTestStringifyCircular() {
|
|||
arrowFunc: [Function: arrowFunc],
|
||||
extendedClass: Extended { a: 1, b: 2 },
|
||||
nFunc: [Function],
|
||||
extendedCstr: [Function: Extended],
|
||||
extendedCstr: [Class: Extended],
|
||||
o: {
|
||||
num: 2,
|
||||
bool: false,
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
StringPrototypeToString,
|
||||
StringPrototypeTrim,
|
||||
StringPrototypeIncludes,
|
||||
StringPrototypeStartsWith,
|
||||
TypeError,
|
||||
NumberParseInt,
|
||||
RegExp,
|
||||
|
@ -82,6 +83,7 @@
|
|||
ArrayPrototypeFilter,
|
||||
ArrayPrototypeFind,
|
||||
FunctionPrototypeBind,
|
||||
FunctionPrototypeToString,
|
||||
Map,
|
||||
MapPrototype,
|
||||
MapPrototypeHas,
|
||||
|
@ -347,6 +349,11 @@
|
|||
// use generic 'Function' instead.
|
||||
cstrName = "Function";
|
||||
}
|
||||
const stringValue = FunctionPrototypeToString(value);
|
||||
// Might be Class
|
||||
if (StringPrototypeStartsWith(stringValue, "class")) {
|
||||
cstrName = "Class";
|
||||
}
|
||||
|
||||
// Our function may have properties, so we want to format those
|
||||
// as if our function was an object
|
||||
|
|
Loading…
Add table
Reference in a new issue