mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Update error message + refactor
This commit is contained in:
+8
-21
@@ -872,7 +872,7 @@ namespace ts {
|
||||
if (!errorLocation ||
|
||||
!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
|
||||
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
||||
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning, nameNotFoundMessage, nameArg)) {
|
||||
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) {
|
||||
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
|
||||
}
|
||||
}
|
||||
@@ -982,28 +982,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): boolean {
|
||||
const strictlyValueMeanings = SymbolFlags.Value & ~SymbolFlags.Type;
|
||||
const strictlyTypeMeanings = SymbolFlags.Type & ~SymbolFlags.Value;
|
||||
|
||||
if (!(meaning & strictlyValueMeanings) || meaning & SymbolFlags.NamespaceModule) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const nameAsType = resolveName(errorLocation, name, strictlyTypeMeanings, nameNotFoundMessage, nameArg);
|
||||
if (!nameAsType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nameAsType.flags & SymbolFlags.Alias) {
|
||||
const resolvedSymbol = resolveAlias(nameAsType);
|
||||
if (resolvedSymbol.flags & SymbolFlags.NamespaceModule) {
|
||||
return false;
|
||||
function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags): boolean {
|
||||
if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) {
|
||||
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined));
|
||||
if (symbol && !(symbol.flags & SymbolFlags.NamespaceModule)) {
|
||||
error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
error(errorLocation, Diagnostics.Cannot_find_name_0_A_type_exists_with_this_name_but_no_value, name);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
|
||||
|
||||
@@ -1959,6 +1959,10 @@
|
||||
"category": "Error",
|
||||
"code": 2692
|
||||
},
|
||||
"'{0}' only refers to a type, but is being used as a value here.": {
|
||||
"category": "Error",
|
||||
"code": 2693
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
|
||||
@@ -3,7 +3,7 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): er
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/valuesAndReferences/assignments.ts (6 errors) ====
|
||||
@@ -49,4 +49,4 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er
|
||||
interface I { }
|
||||
I = null; // Error
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2692: Cannot find name 'A'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2693: 'A' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classExtendsInterfaceInExpression.ts (1 errors) ====
|
||||
@@ -10,5 +10,5 @@ tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2692: C
|
||||
|
||||
class C extends factory(A) {}
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'A'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'A' only refers to a type, but is being used as a value here.
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorsOnImportedSymbol_1.ts (2 errors) ====
|
||||
import Sammy = require("./errorsOnImportedSymbol_0");
|
||||
var x = new Sammy.Sammy();
|
||||
~~~~~
|
||||
!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
var y = Sammy.Sammy();
|
||||
~~~~~
|
||||
!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorsOnImportedSymbol_0.ts (0 errors) ====
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/main.ts(15,1): error TS2692: Cannot find name 'z1'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/main.ts(15,1): error TS2693: 'z1' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'.
|
||||
tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'.
|
||||
tests/cases/compiler/main.ts(27,8): error TS1192: Module '"interface"' has no default export.
|
||||
@@ -49,7 +49,7 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses
|
||||
|
||||
z1.a;
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'z1'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'z1' only refers to a type, but is being used as a value here.
|
||||
z2.a;
|
||||
z3.a;
|
||||
z4.a;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts (2 errors) ====
|
||||
@@ -7,10 +7,10 @@ tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error T
|
||||
import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0');
|
||||
var x = new Sammy(); // error to use as constructor as there is not constructor symbol
|
||||
~~~~~
|
||||
!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
var y = Sammy(); // error to use interface name as call target
|
||||
~~~~~
|
||||
!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here.
|
||||
var z: Sammy; // no error - z is of type interface Sammy from module 'M'
|
||||
var a = new z(); // constructor - no error
|
||||
var b = z(); // call signature - no error
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2692: Cannot find name 'Foo'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2693: 'Foo' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts (1 errors) ====
|
||||
@@ -7,5 +7,5 @@ tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2
|
||||
}
|
||||
var f2: Foo<number> = new Foo(3);
|
||||
~~~
|
||||
!!! error TS2692: Cannot find name 'Foo'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'Foo' only refers to a type, but is being used as a value here.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ====
|
||||
class C<T> extends T { }
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
interface I<T> extends T { }
|
||||
~
|
||||
!!! error TS2312: An interface may only extend a class or another interface.
|
||||
@@ -10,7 +10,7 @@ tests/cases/compiler/intTypeCheck.ts(103,5): error TS2322: Type '() => void' is
|
||||
Property 'p' is missing in type '() => void'.
|
||||
tests/cases/compiler/intTypeCheck.ts(106,5): error TS2322: Type 'boolean' is not assignable to type 'i1'.
|
||||
tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(106,21): error TS2692: Cannot find name 'i1'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(106,21): error TS2693: 'i1' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(107,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(112,5): error TS2322: Type '{}' is not assignable to type 'i2'.
|
||||
Type '{}' provides no match for the signature '(): any'
|
||||
@@ -21,7 +21,7 @@ tests/cases/compiler/intTypeCheck.ts(115,5): error TS2322: Type 'Base' is not as
|
||||
Type 'Base' provides no match for the signature '(): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(120,5): error TS2322: Type 'boolean' is not assignable to type 'i2'.
|
||||
tests/cases/compiler/intTypeCheck.ts(120,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(120,22): error TS2692: Cannot find name 'i2'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(120,22): error TS2693: 'i2' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(121,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(126,5): error TS2322: Type '{}' is not assignable to type 'i3'.
|
||||
Type '{}' provides no match for the signature 'new (): any'
|
||||
@@ -33,12 +33,12 @@ tests/cases/compiler/intTypeCheck.ts(131,5): error TS2322: Type '() => void' is
|
||||
Type '() => void' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not assignable to type 'i3'.
|
||||
tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(134,22): error TS2692: Cannot find name 'i3'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(134,22): error TS2693: 'i3' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'.
|
||||
tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(148,22): error TS2692: Cannot find name 'i4'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(148,22): error TS2693: 'i4' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(154,5): error TS2322: Type '{}' is not assignable to type 'i5'.
|
||||
Property 'p' is missing in type '{}'.
|
||||
@@ -51,7 +51,7 @@ tests/cases/compiler/intTypeCheck.ts(159,5): error TS2322: Type '() => void' is
|
||||
Property 'p' is missing in type '() => void'.
|
||||
tests/cases/compiler/intTypeCheck.ts(162,5): error TS2322: Type 'boolean' is not assignable to type 'i5'.
|
||||
tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(162,22): error TS2692: Cannot find name 'i5'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(162,22): error TS2693: 'i5' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(163,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(168,5): error TS2322: Type '{}' is not assignable to type 'i6'.
|
||||
Type '{}' provides no match for the signature '(): any'
|
||||
@@ -64,7 +64,7 @@ tests/cases/compiler/intTypeCheck.ts(173,5): error TS2322: Type '() => void' is
|
||||
Type 'void' is not assignable to type 'number'.
|
||||
tests/cases/compiler/intTypeCheck.ts(176,5): error TS2322: Type 'boolean' is not assignable to type 'i6'.
|
||||
tests/cases/compiler/intTypeCheck.ts(176,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(176,22): error TS2692: Cannot find name 'i6'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(176,22): error TS2693: 'i6' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(177,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(182,5): error TS2322: Type '{}' is not assignable to type 'i7'.
|
||||
Type '{}' provides no match for the signature 'new (): any'
|
||||
@@ -76,12 +76,12 @@ tests/cases/compiler/intTypeCheck.ts(187,5): error TS2322: Type '() => void' is
|
||||
Type '() => void' provides no match for the signature 'new (): any'
|
||||
tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not assignable to type 'i7'.
|
||||
tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(190,22): error TS2692: Cannot find name 'i7'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(190,22): error TS2693: 'i7' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'.
|
||||
tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected.
|
||||
tests/cases/compiler/intTypeCheck.ts(204,22): error TS2692: Cannot find name 'i8'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/intTypeCheck.ts(204,22): error TS2693: 'i8' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i1'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i1' only refers to a type, but is being used as a value here.
|
||||
var obj10: i1 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -247,7 +247,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i2'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i2' only refers to a type, but is being used as a value here.
|
||||
var obj21: i2 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -281,7 +281,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i3'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i3' only refers to a type, but is being used as a value here.
|
||||
var obj32: i3 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -305,7 +305,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i4'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i4' only refers to a type, but is being used as a value here.
|
||||
var obj43: i4 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -341,7 +341,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i5'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i5' only refers to a type, but is being used as a value here.
|
||||
var obj54: i5 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -377,7 +377,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i6'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i6' only refers to a type, but is being used as a value here.
|
||||
var obj65: i6 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -411,7 +411,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i7'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i7' only refers to a type, but is being used as a value here.
|
||||
var obj76: i7 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -435,7 +435,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~
|
||||
!!! error TS2692: Cannot find name 'i8'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'i8' only refers to a type, but is being used as a value here.
|
||||
var obj87: i8 = new {};
|
||||
~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2692: Cannot find name 'C'. A type exists with this name, but no value.
|
||||
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 TS2304: Cannot find name 'm2'.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2304: Cannot fi
|
||||
}
|
||||
C();
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'C'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'C' only refers to a type, but is being used as a value here.
|
||||
|
||||
module m2 {
|
||||
export interface C {
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2692: Cannot find name 'interface'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2693: 'interface' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1005: ';' expected.
|
||||
tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2692: Cannot find name 'interface'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2693: 'interface' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/interfaceNaming1.ts (4 errors) ====
|
||||
interface { }
|
||||
~~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'interface'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'interface' only refers to a type, but is being used as a value here.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
interface interface{ }
|
||||
interface & { }
|
||||
~~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'interface'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'interface' only refers to a type, but is being used as a value here.
|
||||
~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(4,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(9,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
|
||||
@@ -28,7 +28,7 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.t
|
||||
g = x;
|
||||
I = x;
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
|
||||
module M { export var x = 1; }
|
||||
M = x;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
error TS2318: Cannot find global type 'Boolean'.
|
||||
error TS2318: Cannot find global type 'IArguments'.
|
||||
error TS2318: Cannot find global type 'Number'.
|
||||
tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2692: Cannot find name 'Array'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2693: 'Array' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'Boolean'.
|
||||
@@ -13,7 +13,7 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib
|
||||
function f(x: number, y: number, z: number) {
|
||||
return Array.from(arguments);
|
||||
~~~~~
|
||||
!!! error TS2692: Cannot find name 'Array'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'Array' only refers to a type, but is being used as a value here.
|
||||
}
|
||||
|
||||
f(1, 2, 3);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/newOperator.ts(3,13): error TS2692: Cannot find name 'ifc'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/newOperator.ts(3,13): error TS2693: 'ifc' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/newOperator.ts(10,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/newOperator.ts(11,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/newOperator.ts(12,5): error TS2304: Cannot find name 'string'.
|
||||
@@ -17,7 +17,7 @@ tests/cases/compiler/newOperator.ts(45,23): error TS1150: 'new T[]' cannot be us
|
||||
// Attempting to 'new' an interface yields poor error
|
||||
var i = new ifc();
|
||||
~~~
|
||||
!!! error TS2692: Cannot find name 'ifc'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'ifc' only refers to a type, but is being used as a value here.
|
||||
|
||||
// Parens are optional
|
||||
var x = new Date;
|
||||
|
||||
@@ -5,7 +5,7 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error TS2304: Cannot find name 'type'.
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected.
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected.
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ====
|
||||
@@ -30,4 +30,4 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/returnTypeParameter.ts (2 errors) ====
|
||||
@@ -8,4 +8,4 @@ tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2692: Cannot find nam
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
function f2<T>(a: T): T { return T; } // bug was that this satisfied the return statement requirement
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface.
|
||||
|
||||
|
||||
==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ====
|
||||
class C<T> extends T {}
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
class C2<T> implements T {}
|
||||
~
|
||||
!!! error TS2422: A class may only implement another class or interface.
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2692: Cannot find name 'U'. A type exists with this name, but no value.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2693: 'U' only refers to a type, but is being used as a value here.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface.
|
||||
|
||||
@@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e
|
||||
|
||||
class C<T> extends T { }
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
class C2<T, U> extends U { }
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'U'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'U' only refers to a type, but is being used as a value here.
|
||||
|
||||
interface I<T> extends T { }
|
||||
~
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(16,11): error TS2692: Cannot find name 'Interface'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(16,11): error TS2693: 'Interface' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(17,11): error TS2304: Cannot find name 'InterfaceNotFound'.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(18,13): error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(19,16): error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(18,13): error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(19,16): error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(20,16): error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(21,11): error TS2692: Cannot find name 'someType'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(22,17): error TS2692: Cannot find name 'someType'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(21,11): error TS2693: 'someType' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(22,17): error TS2693: 'someType' only refers to a type, but is being used as a value here.
|
||||
tests/cases/compiler/typeUsedAsValueError.ts(23,17): error TS2304: Cannot find name 'someTypeNotFound'.
|
||||
|
||||
|
||||
@@ -26,25 +26,25 @@ tests/cases/compiler/typeUsedAsValueError.ts(23,17): error TS2304: Cannot find n
|
||||
|
||||
let one = Interface;
|
||||
~~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'Interface'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'Interface' only refers to a type, but is being used as a value here.
|
||||
let two = InterfaceNotFound;
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'InterfaceNotFound'.
|
||||
let three = TypeAliasForSomeClass;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here.
|
||||
let four = new TypeAliasForSomeClass();
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here.
|
||||
let five = new TypeAliasForSomeClassNotFound();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'.
|
||||
let six = someType;
|
||||
~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'someType'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'someType' only refers to a type, but is being used as a value here.
|
||||
acceptsSomeType(someType);
|
||||
~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'someType'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'someType' only refers to a type, but is being used as a value here.
|
||||
acceptsSomeType(someTypeNotFound);
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'someTypeNotFound'.
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/world.ts(4,1): error TS2692: Cannot find name 'HelloInterface'. A type exists with this name, but no value.
|
||||
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 TS2304: Cannot find name 'HelloNamespace'.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ tests/cases/compiler/world.ts(5,1): error TS2304: Cannot find name 'HelloNamespa
|
||||
|
||||
HelloInterface.world;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2692: Cannot find name 'HelloInterface'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'HelloInterface' only refers to a type, but is being used as a value here.
|
||||
HelloNamespace.world;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'HelloNamespace'.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/typeofSimple.ts(3,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/compiler/typeofSimple.ts(8,21): error TS2692: Cannot find name 'J'. A type exists with this name, but no value.
|
||||
tests/cases/compiler/typeofSimple.ts(8,21): error TS2693: 'J' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/typeofSimple.ts (2 errors) ====
|
||||
@@ -14,7 +14,7 @@ tests/cases/compiler/typeofSimple.ts(8,21): error TS2692: Cannot find name 'J'.
|
||||
|
||||
var numberJ: typeof J; //Error, cannot reference type in typeof
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'J'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'J' only refers to a type, but is being used as a value here.
|
||||
var numberI: I<typeof v2>;
|
||||
|
||||
var fun: () => I<number>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts (1 errors) ====
|
||||
@@ -6,6 +6,6 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts
|
||||
var a: typeof x;
|
||||
var y: typeof T;
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'T' only refers to a type, but is being used as a value here.
|
||||
return a;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/types/primitives/null/validNullAssignments.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property.
|
||||
tests/cases/conformance/types/primitives/null/validNullAssignments.ts(15,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
tests/cases/conformance/types/primitives/null/validNullAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): error TS2364: Invalid left-hand side of assignment expression.
|
||||
|
||||
@@ -31,7 +31,7 @@ tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): err
|
||||
g = null; // ok
|
||||
I = null; // error
|
||||
~
|
||||
!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value.
|
||||
!!! error TS2693: 'I' only refers to a type, but is being used as a value here.
|
||||
|
||||
module M { export var x = 1; }
|
||||
M = null; // error
|
||||
|
||||
Reference in New Issue
Block a user