From 211008d01572f59ee233e7e00f5ab0f81461e24c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 26 Aug 2014 13:03:24 -0700 Subject: [PATCH] Fix undefined symbol name in error message --- src/compiler/checker.ts | 1 + tests/baselines/reference/noDefaultLib.errors.txt | 15 +++++++++++++++ tests/baselines/reference/noDefaultLib.js | 15 +++++++++++++++ tests/cases/compiler/noDefaultLib.ts | 10 ++++++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/baselines/reference/noDefaultLib.errors.txt create mode 100644 tests/baselines/reference/noDefaultLib.js create mode 100644 tests/cases/compiler/noDefaultLib.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f88df3aa8..6b722f8593 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2236,6 +2236,7 @@ module ts { return emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); + var name = symbol.name; if (!(type.flags & TypeFlags.ObjectType)) { error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, name); return emptyObjectType; diff --git a/tests/baselines/reference/noDefaultLib.errors.txt b/tests/baselines/reference/noDefaultLib.errors.txt new file mode 100644 index 0000000000..2f411affd5 --- /dev/null +++ b/tests/baselines/reference/noDefaultLib.errors.txt @@ -0,0 +1,15 @@ +!!! Cannot find global type 'Boolean'. +!!! Cannot find global type 'IArguments'. +==== tests/cases/compiler/noDefaultLib.ts (1 errors) ==== + /// + var x; + + interface Array {} + ~~~~~ +!!! Global type 'Array' must have 1 type parameter(s). + interface String {} + interface Number {} + interface Object {} + interface Date {} + interface Function {} + interface RegExp {} \ No newline at end of file diff --git a/tests/baselines/reference/noDefaultLib.js b/tests/baselines/reference/noDefaultLib.js new file mode 100644 index 0000000000..69e7f3d0cf --- /dev/null +++ b/tests/baselines/reference/noDefaultLib.js @@ -0,0 +1,15 @@ +//// [noDefaultLib.ts] +/// +var x; + +interface Array {} +interface String {} +interface Number {} +interface Object {} +interface Date {} +interface Function {} +interface RegExp {} + +//// [noDefaultLib.js] +/// +var x; diff --git a/tests/cases/compiler/noDefaultLib.ts b/tests/cases/compiler/noDefaultLib.ts new file mode 100644 index 0000000000..92c8a63fc6 --- /dev/null +++ b/tests/cases/compiler/noDefaultLib.ts @@ -0,0 +1,10 @@ +/// +var x; + +interface Array {} +interface String {} +interface Number {} +interface Object {} +interface Date {} +interface Function {} +interface RegExp {} \ No newline at end of file