diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index f69f713981..43e6017392 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -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()); } diff --git a/cli/tests/testdata/npm/esm_import_cjs_default/main.out b/cli/tests/testdata/npm/esm_import_cjs_default/main.out index 4b73328f33..2e90049d80 100644 --- a/cli/tests/testdata/npm/esm_import_cjs_default/main.out +++ b/cli/tests/testdata/npm/esm_import_cjs_default/main.out @@ -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] } =========================== diff --git a/cli/tests/testdata/npm/tarball_with_global_header/main.out b/cli/tests/testdata/npm/tarball_with_global_header/main.out index 2f309499ee..caf351e2e3 100644 --- a/cli/tests/testdata/npm/tarball_with_global_header/main.out +++ b/cli/tests/testdata/npm/tarball_with_global_header/main.out @@ -1 +1 @@ -[Function: Client] +[Class: Client] diff --git a/cli/tests/testdata/run/070_location.ts.out b/cli/tests/testdata/run/070_location.ts.out index 692d7c976c..8b2f9e49df 100644 --- a/cli/tests/testdata/run/070_location.ts.out +++ b/cli/tests/testdata/run/070_location.ts.out @@ -1,4 +1,4 @@ -[WILDCARD][Function: Location] +[WILDCARD][Class: Location] Location {} Location { hash: "#bat", diff --git a/cli/tests/testdata/run/071_location_unset.ts.out b/cli/tests/testdata/run/071_location_unset.ts.out index 99f87a7fce..dc67c55787 100644 --- a/cli/tests/testdata/run/071_location_unset.ts.out +++ b/cli/tests/testdata/run/071_location_unset.ts.out @@ -1,4 +1,4 @@ -[WILDCARD][Function: Location] +[WILDCARD][Class: Location] Location {} undefined /bar diff --git a/cli/tests/testdata/run/top_level_await/loop.out b/cli/tests/testdata/run/top_level_await/loop.out index 70e621e45b..7f72048c2d 100644 --- a/cli/tests/testdata/run/top_level_await/loop.out +++ b/cli/tests/testdata/run/top_level_await/loop.out @@ -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 diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 1abacc9ad2..ccc8638d25 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -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, diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 1720fe7e2e..a9ec524887 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -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