From e9fd2bcf0f4404716daae6b11816b91de6253c63 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Fri, 14 Apr 2017 10:36:49 +0800 Subject: [PATCH] address code review feedback --- src/compiler/checker.ts | 11 +++++++++-- src/compiler/diagnosticMessages.json | 6 +++++- .../InvalidNonInstantiatedModule.errors.txt | 8 ++++---- .../aliasOnMergedModuleInterface.errors.txt | 4 ++-- .../reference/assignToModule.errors.txt | 4 ++-- .../assignmentToReferenceTypes.errors.txt | 4 ++-- .../reference/assignments.errors.txt | 4 ++-- ...efaultArgsInFunctionExpressions.errors.txt | 4 ++-- ...peReferenceWithoutTypeArgument2.errors.txt | 4 ++-- .../importDeclWithClassModifiers.errors.txt | 12 ++++++------ .../importDeclWithDeclareModifier.errors.txt | 4 ++-- .../importDeclWithExportModifier.errors.txt | 4 ++-- ...portModifierAndExportAssignment.errors.txt | 4 ++-- .../importStatementsInterfaces.errors.txt | 4 ++-- .../interfaceNameAsIdentifier.errors.txt | 4 ++-- .../reference/memberScope.errors.txt | 4 ++-- .../reference/moduleAsBaseType.errors.txt | 12 ++++++------ .../moduleWithNoValuesAsType.errors.txt | 12 ++++++------ .../reference/namespaceModule.errors.txt | 19 ------------------- tests/baselines/reference/namespaceModule.js | 15 --------------- .../typeUsedAsValueError2.errors.txt | 4 ++-- .../typeofInternalModules.errors.txt | 8 ++++---- tests/cases/compiler/namespaceModule.ts | 9 --------- 23 files changed, 66 insertions(+), 98 deletions(-) delete mode 100644 tests/baselines/reference/namespaceModule.errors.txt delete mode 100644 tests/baselines/reference/namespaceModule.js delete mode 100644 tests/cases/compiler/namespaceModule.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 920bbceb6cf..b8fc42eee08 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1202,10 +1202,17 @@ namespace ts { } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation: Node, name: string, meaning: SymbolFlags): boolean { - if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) { + if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Type)) { const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); if (symbol) { - error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_value_here_because_it_has_no_value_export, name); + error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_value, name); + return true; + } + } + else if (meaning & (SymbolFlags.Type & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Value)) { + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + if (symbol) { + error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_type, name); return true; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4e70cf65849..10dc25ef70e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2099,10 +2099,14 @@ "category": "Error", "code": 2707 }, - "Cannot use namespace '{0}' as a value here because it has no value export.": { + "Cannot use namespace '{0}' as a value.": { "category": "Error", "code": 2708 }, + "Cannot use namespace '{0}' as a type.": { + "category": "Error", + "code": 2709 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/InvalidNonInstantiatedModule.errors.txt b/tests/baselines/reference/InvalidNonInstantiatedModule.errors.txt index bcfb27652c9..bc8582debd9 100644 --- a/tests/baselines/reference/InvalidNonInstantiatedModule.errors.txt +++ b/tests/baselines/reference/InvalidNonInstantiatedModule.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts(5,9): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. -tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts(7,15): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts(5,9): error TS2708: Cannot use namespace 'M' as a value. +tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts(7,15): error TS2708: Cannot use namespace 'M' as a value. ==== tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts (2 errors) ==== @@ -9,9 +9,9 @@ tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiate var m = M; // Error, not instantiated can not be used as var ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'M' as a value. var x: typeof M; // Error only a namespace ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'M' as a value. \ No newline at end of file diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt b/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt index ae56be397fe..66d9eebb3dd 100644 --- a/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2708: Cannot use namespace 'foo' as a value here because it has no value export. +tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2708: Cannot use namespace 'foo' as a value. ==== tests/cases/compiler/aliasOnMergedModuleInterface_1.ts (1 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2708: Cann z.bar("hello"); // This should be ok var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be error ~~~ -!!! error TS2708: Cannot use namespace 'foo' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'foo' as a value. ==== tests/cases/compiler/aliasOnMergedModuleInterface_0.ts (0 errors) ==== declare module "foo" diff --git a/tests/baselines/reference/assignToModule.errors.txt b/tests/baselines/reference/assignToModule.errors.txt index f7abfa90bf7..0b8b6f27deb 100644 --- a/tests/baselines/reference/assignToModule.errors.txt +++ b/tests/baselines/reference/assignToModule.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/assignToModule.ts(2,1): error TS2708: Cannot use namespace 'A' as a value here because it has no value export. +tests/cases/compiler/assignToModule.ts(2,1): error TS2708: Cannot use namespace 'A' as a value. ==== tests/cases/compiler/assignToModule.ts (1 errors) ==== module A {} A = undefined; // invalid LHS ~ -!!! error TS2708: Cannot use namespace 'A' as a value here because it has no value export. \ No newline at end of file +!!! error TS2708: Cannot use namespace 'A' as a value. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentToReferenceTypes.errors.txt b/tests/baselines/reference/assignmentToReferenceTypes.errors.txt index 8c937e02766..5e42a2e79c6 100644 --- a/tests/baselines/reference/assignmentToReferenceTypes.errors.txt +++ b/tests/baselines/reference/assignmentToReferenceTypes.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/assignmentToReferenceTypes.ts(5,1): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +tests/cases/compiler/assignmentToReferenceTypes.ts(5,1): error TS2708: Cannot use namespace 'M' as a value. tests/cases/compiler/assignmentToReferenceTypes.ts(9,1): error TS2539: Cannot assign to 'C' because it is not a variable. tests/cases/compiler/assignmentToReferenceTypes.ts(13,1): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2539: Cannot assign to 'f' because it is not a variable. @@ -11,7 +11,7 @@ tests/cases/compiler/assignmentToReferenceTypes.ts(16,1): error TS2539: Cannot a } M = null; ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'M' as a value. class C { } diff --git a/tests/baselines/reference/assignments.errors.txt b/tests/baselines/reference/assignments.errors.txt index 2c3fff0be59..cb8b7a17bdf 100644 --- a/tests/baselines/reference/assignments.errors.txt +++ b/tests/baselines/reference/assignments.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(11,1): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(11,1): error TS2708: Cannot use namespace 'M' as a value. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): error TS2539: Cannot assign to 'C' because it is not a variable. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2539: Cannot assign to 'E' because it is not a variable. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,3): error TS2540: Cannot assign to 'A' because it is a constant or a read-only property. @@ -19,7 +19,7 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er module M { } M = null; // Error ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'M' as a value. class C { } C = null; // Error diff --git a/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt b/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt index 889a6c3ce79..d46963caeed 100644 --- a/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt +++ b/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(11,1): error TS2322: Ty tests/cases/compiler/defaultArgsInFunctionExpressions.ts(14,51): error TS2352: Type 'string' cannot be converted to type 'number'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(17,41): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(20,62): error TS2352: Type 'string' cannot be converted to type 'number'. -tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2708: Cannot use namespace 'T' as a value here because it has no value export. +tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2708: Cannot use namespace 'T' as a value. ==== tests/cases/compiler/defaultArgsInFunctionExpressions.ts (8 errors) ==== @@ -52,7 +52,7 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2708: C var f6 = (t = T) => { }; ~ -!!! error TS2708: Cannot use namespace 'T' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'T' as a value. var f7 = (t = U) => { return t; }; f7().x; \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt index 05d88ae9d39..276654562a1 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt @@ -15,7 +15,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,38): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(20,17): error TS2689: Cannot extend an interface 'I'. Did you mean 'implements'? tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(23,21): error TS2314: Generic type 'I' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,18): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,18): error TS2708: Cannot use namespace 'M' as a value. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(30,24): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(31,24): error TS2694: Namespace 'M' has no exported member 'C'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(33,22): error TS2314: Generic type 'I' requires 1 type argument(s). @@ -89,7 +89,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc class D2 extends M.C { } ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'M' as a value. interface D3 { } ~~~ !!! error TS2314: Generic type 'E' requires 1 type argument(s). diff --git a/tests/baselines/reference/importDeclWithClassModifiers.errors.txt b/tests/baselines/reference/importDeclWithClassModifiers.errors.txt index 8c82322d384..1f545bb01f2 100644 --- a/tests/baselines/reference/importDeclWithClassModifiers.errors.txt +++ b/tests/baselines/reference/importDeclWithClassModifiers.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/importDeclWithClassModifiers.ts(5,8): error TS1044: 'public' modifier cannot appear on a module or namespace element. -tests/cases/compiler/importDeclWithClassModifiers.ts(5,26): error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +tests/cases/compiler/importDeclWithClassModifiers.ts(5,26): error TS2708: Cannot use namespace 'x' as a value. tests/cases/compiler/importDeclWithClassModifiers.ts(5,28): error TS2694: Namespace 'x' has no exported member 'c'. tests/cases/compiler/importDeclWithClassModifiers.ts(6,8): error TS1044: 'private' modifier cannot appear on a module or namespace element. -tests/cases/compiler/importDeclWithClassModifiers.ts(6,27): error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +tests/cases/compiler/importDeclWithClassModifiers.ts(6,27): error TS2708: Cannot use namespace 'x' as a value. tests/cases/compiler/importDeclWithClassModifiers.ts(6,29): error TS2694: Namespace 'x' has no exported member 'c'. tests/cases/compiler/importDeclWithClassModifiers.ts(7,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. -tests/cases/compiler/importDeclWithClassModifiers.ts(7,26): error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +tests/cases/compiler/importDeclWithClassModifiers.ts(7,26): error TS2708: Cannot use namespace 'x' as a value. tests/cases/compiler/importDeclWithClassModifiers.ts(7,28): error TS2694: Namespace 'x' has no exported member 'c'. @@ -18,21 +18,21 @@ tests/cases/compiler/importDeclWithClassModifiers.ts(7,28): error TS2694: Namesp ~~~~~~ !!! error TS1044: 'public' modifier cannot appear on a module or namespace element. ~ -!!! error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'x' as a value. ~ !!! error TS2694: Namespace 'x' has no exported member 'c'. export private import b = x.c; ~~~~~~~ !!! error TS1044: 'private' modifier cannot appear on a module or namespace element. ~ -!!! error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'x' as a value. ~ !!! error TS2694: Namespace 'x' has no exported member 'c'. export static import c = x.c; ~~~~~~ !!! error TS1044: 'static' modifier cannot appear on a module or namespace element. ~ -!!! error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'x' as a value. ~ !!! error TS2694: Namespace 'x' has no exported member 'c'. var b: a; diff --git a/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt b/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt index 696926dd4a1..93619813aa2 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt +++ b/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/importDeclWithDeclareModifier.ts(5,9): error TS1029: 'export' modifier must precede 'declare' modifier. -tests/cases/compiler/importDeclWithDeclareModifier.ts(5,27): error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +tests/cases/compiler/importDeclWithDeclareModifier.ts(5,27): error TS2708: Cannot use namespace 'x' as a value. tests/cases/compiler/importDeclWithDeclareModifier.ts(5,29): error TS2694: Namespace 'x' has no exported member 'c'. @@ -12,7 +12,7 @@ tests/cases/compiler/importDeclWithDeclareModifier.ts(5,29): error TS2694: Names ~~~~~~ !!! error TS1029: 'export' modifier must precede 'declare' modifier. ~ -!!! error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'x' as a value. ~ !!! error TS2694: Namespace 'x' has no exported member 'c'. var b: a; diff --git a/tests/baselines/reference/importDeclWithExportModifier.errors.txt b/tests/baselines/reference/importDeclWithExportModifier.errors.txt index d211b750ca3..2a5dbbf74ef 100644 --- a/tests/baselines/reference/importDeclWithExportModifier.errors.txt +++ b/tests/baselines/reference/importDeclWithExportModifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importDeclWithExportModifier.ts(5,19): error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +tests/cases/compiler/importDeclWithExportModifier.ts(5,19): error TS2708: Cannot use namespace 'x' as a value. tests/cases/compiler/importDeclWithExportModifier.ts(5,21): error TS2694: Namespace 'x' has no exported member 'c'. @@ -9,7 +9,7 @@ tests/cases/compiler/importDeclWithExportModifier.ts(5,21): error TS2694: Namesp } export import a = x.c; ~ -!!! error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'x' as a value. ~ !!! error TS2694: Namespace 'x' has no exported member 'c'. var b: a; diff --git a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt index fbe7fde272d..f9f683c502b 100644 --- a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt +++ b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(5,19): error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(5,19): error TS2708: Cannot use namespace 'x' as a value. tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(5,21): error TS2694: Namespace 'x' has no exported member 'c'. tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -10,7 +10,7 @@ tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(6,1): er } export import a = x.c; ~ -!!! error TS2708: Cannot use namespace 'x' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'x' as a value. ~ !!! error TS2694: Namespace 'x' has no exported member 'c'. export = x; diff --git a/tests/baselines/reference/importStatementsInterfaces.errors.txt b/tests/baselines/reference/importStatementsInterfaces.errors.txt index d591997117f..a43c368a2c2 100644 --- a/tests/baselines/reference/importStatementsInterfaces.errors.txt +++ b/tests/baselines/reference/importStatementsInterfaces.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/internalModules/codeGeneration/importStatementsInterfaces.ts(23,19): error TS2708: Cannot use namespace 'a' as a value here because it has no value export. +tests/cases/conformance/internalModules/codeGeneration/importStatementsInterfaces.ts(23,19): error TS2708: Cannot use namespace 'a' as a value. ==== tests/cases/conformance/internalModules/codeGeneration/importStatementsInterfaces.ts (1 errors) ==== @@ -26,7 +26,7 @@ tests/cases/conformance/internalModules/codeGeneration/importStatementsInterface import b = a.inA; var m: typeof a; ~ -!!! error TS2708: Cannot use namespace 'a' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'a' as a value. var p: b.Point3D; var p = {x:0, y:0, z: 0 }; } diff --git a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt index faa6a0096fa..cc9cc927d0f 100644 --- a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt +++ b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2693: 'C' only refers to a type, but is being used as a value here. -tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2708: Cannot use namespace 'm2' as a value here because it has no value export. +tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2708: Cannot use namespace 'm2' as a value. ==== tests/cases/compiler/interfaceNameAsIdentifier.ts (2 errors) ==== @@ -18,5 +18,5 @@ tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2708: Cannot us m2.C(); ~~ -!!! error TS2708: Cannot use namespace 'm2' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'm2' as a value. \ No newline at end of file diff --git a/tests/baselines/reference/memberScope.errors.txt b/tests/baselines/reference/memberScope.errors.txt index 1d69c350d7c..7af426828db 100644 --- a/tests/baselines/reference/memberScope.errors.txt +++ b/tests/baselines/reference/memberScope.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/memberScope.ts(4,11): error TS2708: Cannot use namespace 'Basil' as a value here because it has no value export. +tests/cases/compiler/memberScope.ts(4,11): error TS2708: Cannot use namespace 'Basil' as a value. ==== tests/cases/compiler/memberScope.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/memberScope.ts(4,11): error TS2708: Cannot use namespace 'B export module Basil { } var z = Basil.Pepper; ~~~~~ -!!! error TS2708: Cannot use namespace 'Basil' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'Basil' as a value. } \ No newline at end of file diff --git a/tests/baselines/reference/moduleAsBaseType.errors.txt b/tests/baselines/reference/moduleAsBaseType.errors.txt index 5313c28fbae..fd5b4f581f9 100644 --- a/tests/baselines/reference/moduleAsBaseType.errors.txt +++ b/tests/baselines/reference/moduleAsBaseType.errors.txt @@ -1,16 +1,16 @@ -tests/cases/compiler/moduleAsBaseType.ts(2,17): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. -tests/cases/compiler/moduleAsBaseType.ts(3,21): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. -tests/cases/compiler/moduleAsBaseType.ts(4,21): error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +tests/cases/compiler/moduleAsBaseType.ts(2,17): error TS2708: Cannot use namespace 'M' as a value. +tests/cases/compiler/moduleAsBaseType.ts(3,21): error TS2709: Cannot use namespace 'M' as a type. +tests/cases/compiler/moduleAsBaseType.ts(4,21): error TS2709: Cannot use namespace 'M' as a type. ==== tests/cases/compiler/moduleAsBaseType.ts (3 errors) ==== module M {} class C extends M {} ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'M' as a value. interface I extends M { } ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. +!!! error TS2709: Cannot use namespace 'M' as a type. class C2 implements M { } ~ -!!! error TS2708: Cannot use namespace 'M' as a value here because it has no value export. \ No newline at end of file +!!! error TS2709: Cannot use namespace 'M' as a type. \ No newline at end of file diff --git a/tests/baselines/reference/moduleWithNoValuesAsType.errors.txt b/tests/baselines/reference/moduleWithNoValuesAsType.errors.txt index 5636b97e8cd..21abac79217 100644 --- a/tests/baselines/reference/moduleWithNoValuesAsType.errors.txt +++ b/tests/baselines/reference/moduleWithNoValuesAsType.errors.txt @@ -1,20 +1,20 @@ -tests/cases/compiler/moduleWithNoValuesAsType.ts(2,8): error TS2708: Cannot use namespace 'A' as a value here because it has no value export. -tests/cases/compiler/moduleWithNoValuesAsType.ts(7,8): error TS2708: Cannot use namespace 'B' as a value here because it has no value export. -tests/cases/compiler/moduleWithNoValuesAsType.ts(15,8): error TS2708: Cannot use namespace 'C' as a value here because it has no value export. +tests/cases/compiler/moduleWithNoValuesAsType.ts(2,8): error TS2709: Cannot use namespace 'A' as a type. +tests/cases/compiler/moduleWithNoValuesAsType.ts(7,8): error TS2709: Cannot use namespace 'B' as a type. +tests/cases/compiler/moduleWithNoValuesAsType.ts(15,8): error TS2709: Cannot use namespace 'C' as a type. ==== tests/cases/compiler/moduleWithNoValuesAsType.ts (3 errors) ==== module A { } var a: A; // error ~ -!!! error TS2708: Cannot use namespace 'A' as a value here because it has no value export. +!!! error TS2709: Cannot use namespace 'A' as a type. module B { interface I {} } var b: B; // error ~ -!!! error TS2708: Cannot use namespace 'B' as a value here because it has no value export. +!!! error TS2709: Cannot use namespace 'B' as a type. module C { module M { @@ -24,4 +24,4 @@ tests/cases/compiler/moduleWithNoValuesAsType.ts(15,8): error TS2708: Cannot use var c: C; // error ~ -!!! error TS2708: Cannot use namespace 'C' as a value here because it has no value export. \ No newline at end of file +!!! error TS2709: Cannot use namespace 'C' as a type. \ No newline at end of file diff --git a/tests/baselines/reference/namespaceModule.errors.txt b/tests/baselines/reference/namespaceModule.errors.txt deleted file mode 100644 index b23f9621c58..00000000000 --- a/tests/baselines/reference/namespaceModule.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -tests/cases/compiler/namespaceModule.ts(3,1): error TS2708: Cannot use namespace 'z' as a value here because it has no value export. -tests/cases/compiler/namespaceModule.ts(9,1): error TS2708: Cannot use namespace 'x' as a value here because it has no value export. - - -==== tests/cases/compiler/namespaceModule.ts (2 errors) ==== - namespace z {} - - z; - ~ -!!! error TS2708: Cannot use namespace 'z' as a value here because it has no value export. - - namespace x { - export type z = string; - } - - x; - ~ -!!! error TS2708: Cannot use namespace 'x' as a value here because it has no value export. - \ No newline at end of file diff --git a/tests/baselines/reference/namespaceModule.js b/tests/baselines/reference/namespaceModule.js deleted file mode 100644 index 18bf3cf7b22..00000000000 --- a/tests/baselines/reference/namespaceModule.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [namespaceModule.ts] -namespace z {} - -z; - -namespace x { - export type z = string; -} - -x; - - -//// [namespaceModule.js] -z; -x; diff --git a/tests/baselines/reference/typeUsedAsValueError2.errors.txt b/tests/baselines/reference/typeUsedAsValueError2.errors.txt index a471055913d..4aac95faa25 100644 --- a/tests/baselines/reference/typeUsedAsValueError2.errors.txt +++ b/tests/baselines/reference/typeUsedAsValueError2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/world.ts(4,1): error TS2693: 'HelloInterface' only refers to a type, but is being used as a value here. -tests/cases/compiler/world.ts(5,1): error TS2708: Cannot use namespace 'HelloNamespace' as a value here because it has no value export. +tests/cases/compiler/world.ts(5,1): error TS2708: Cannot use namespace 'HelloNamespace' as a value. ==== tests/cases/compiler/world.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/world.ts(5,1): error TS2708: Cannot use namespace 'HelloNam !!! error TS2693: 'HelloInterface' only refers to a type, but is being used as a value here. HelloNamespace.world; ~~~~~~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'HelloNamespace' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'HelloNamespace' as a value. ==== tests/cases/compiler/helloInterface.ts (0 errors) ==== interface HelloInterface { world: any; diff --git a/tests/baselines/reference/typeofInternalModules.errors.txt b/tests/baselines/reference/typeofInternalModules.errors.txt index b84e65fe218..5402249ea63 100644 --- a/tests/baselines/reference/typeofInternalModules.errors.txt +++ b/tests/baselines/reference/typeofInternalModules.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/typeofInternalModules.ts(15,16): error TS2708: Cannot use namespace 'importUninst' as a value here because it has no value export. +tests/cases/compiler/typeofInternalModules.ts(15,16): error TS2708: Cannot use namespace 'importUninst' as a value. tests/cases/compiler/typeofInternalModules.ts(17,9): error TS2304: Cannot find name 'Outer'. tests/cases/compiler/typeofInternalModules.ts(19,1): error TS2322: Type 'typeof Outer' is not assignable to type 'typeof instantiated'. Property 'C' is missing in type 'typeof Outer'. -tests/cases/compiler/typeofInternalModules.ts(21,16): error TS2708: Cannot use namespace 'importUninst' as a value here because it has no value export. +tests/cases/compiler/typeofInternalModules.ts(21,16): error TS2708: Cannot use namespace 'importUninst' as a value. tests/cases/compiler/typeofInternalModules.ts(23,1): error TS2322: Type 'typeof instantiated' is not assignable to type 'typeof Outer'. Property 'instantiated' is missing in type 'typeof instantiated'. @@ -24,7 +24,7 @@ tests/cases/compiler/typeofInternalModules.ts(23,1): error TS2322: Type 'typeof var x2: importInst.C = new x1(); var x3: typeof importUninst.P; // Error again ~~~~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'importUninst' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'importUninst' as a value. var x4: Outer = Outer; ~~~~~ @@ -37,7 +37,7 @@ tests/cases/compiler/typeofInternalModules.ts(23,1): error TS2322: Type 'typeof x5 = Outer.instantiated; var x6: typeof importUninst; ~~~~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'importUninst' as a value here because it has no value export. +!!! error TS2708: Cannot use namespace 'importUninst' as a value. var x7: typeof Outer = Outer; x7 = importInst; ~~ diff --git a/tests/cases/compiler/namespaceModule.ts b/tests/cases/compiler/namespaceModule.ts deleted file mode 100644 index a1ad71d96a0..00000000000 --- a/tests/cases/compiler/namespaceModule.ts +++ /dev/null @@ -1,9 +0,0 @@ -namespace z {} - -z; - -namespace x { - export type z = string; -} - -x;