diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 52df773374..1dbe0bafd9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2238,6 +2238,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, symbol.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 diff --git a/tests/cases/fourslash/scriptLexicalStructureItems2.ts b/tests/cases/fourslash/scriptLexicalStructureItems2.ts new file mode 100644 index 0000000000..092527ec93 --- /dev/null +++ b/tests/cases/fourslash/scriptLexicalStructureItems2.ts @@ -0,0 +1,12 @@ +/// + + +/////**/ + +goTo.marker(); +edit.insertLine("module A"); +edit.insert("export class "); + +// should not crash +verify.getScriptLexicalStructureListCount(1); +