mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 17:41:26 -06:00
Create a new flag for diagnostics 'isEarly' and disable emit if this flag is set. Set the flag by default on all let and const errors to ensure we are not emitting invalid JS code.
This commit is contained in:
parent
d5fe43b53e
commit
dd7ca69866
@ -3,6 +3,7 @@
|
||||
interface DiagnosticDetails {
|
||||
category: string;
|
||||
code: number;
|
||||
isEarly?: boolean;
|
||||
}
|
||||
|
||||
interface InputDiagnosticMessageTable {
|
||||
@ -63,8 +64,9 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
|
||||
' ' + convertPropertyName(nameMap[name]) +
|
||||
': { code: ' + diagnosticDetails.code +
|
||||
', category: DiagnosticCategory.' + diagnosticDetails.category +
|
||||
', key: "' + name.replace('"', '\\"') +
|
||||
'" },\r\n';
|
||||
', key: "' + name.replace('"', '\\"') + '"' +
|
||||
(diagnosticDetails.isEarly ? ', isEarly: true' : '') +
|
||||
' },\r\n';
|
||||
}
|
||||
|
||||
result += ' };\r\n}';
|
||||
|
||||
@ -87,10 +87,11 @@ module ts {
|
||||
}
|
||||
// Report errors every position with duplicate declaration
|
||||
// Report errors on previous encountered declarations
|
||||
var message = symbol.flags & SymbolFlags.BlockScopedVariable ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
|
||||
forEach(symbol.declarations, (declaration) => {
|
||||
file.semanticErrors.push(createDiagnosticForNode(declaration.name, Diagnostics.Duplicate_identifier_0, getDisplayName(declaration)));
|
||||
file.semanticErrors.push(createDiagnosticForNode(declaration.name, message, getDisplayName(declaration)));
|
||||
});
|
||||
file.semanticErrors.push(createDiagnosticForNode(node.name, Diagnostics.Duplicate_identifier_0, getDisplayName(node)));
|
||||
file.semanticErrors.push(createDiagnosticForNode(node.name, message, getDisplayName(node)));
|
||||
|
||||
symbol = createSymbol(0, name);
|
||||
}
|
||||
|
||||
@ -109,7 +109,8 @@ module ts {
|
||||
isImplementationOfOverload: isImplementationOfOverload,
|
||||
getAliasedSymbol: resolveImport,
|
||||
isUndefinedSymbol: symbol => symbol === undefinedSymbol,
|
||||
isArgumentsSymbol: symbol => symbol === argumentsSymbol
|
||||
isArgumentsSymbol: symbol => symbol === argumentsSymbol,
|
||||
hasEarlyErrors: hasEarlyErrors
|
||||
};
|
||||
|
||||
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
|
||||
@ -228,11 +229,13 @@ module ts {
|
||||
recordMergedSymbol(target, source);
|
||||
}
|
||||
else {
|
||||
var message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable
|
||||
? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;
|
||||
forEach(source.declarations, node => {
|
||||
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
|
||||
error(node.name ? node.name : node, message, symbolToString(source));
|
||||
});
|
||||
forEach(target.declarations, node => {
|
||||
error(node.name ? node.name : node, Diagnostics.Duplicate_identifier_0, symbolToString(source));
|
||||
error(node.name ? node.name : node, message, symbolToString(source));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -327,7 +330,7 @@ module ts {
|
||||
if (s && s.flags & SymbolFlags.BlockScopedVariable) {
|
||||
// Block-scoped variables can not be used before their definition
|
||||
var declaration = forEach(s.declarations, d => d.flags & NodeFlags.BlockScoped ? d : undefined);
|
||||
Debug.assert(declaration, "Bock-scoped variable declaration is undefined");
|
||||
Debug.assert(declaration, "Block-scoped variable declaration is undefined");
|
||||
var declarationSourceFile = getSourceFileOfNode(declaration);
|
||||
var referenceSourceFile = getSourceFileOfNode(errorLocation);
|
||||
if (declarationSourceFile === referenceSourceFile && declaration.pos > errorLocation.pos) {
|
||||
@ -6864,7 +6867,7 @@ module ts {
|
||||
var localDeclarationSymbol = resolveName(node, node.name.text, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
|
||||
if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & SymbolFlags.BlockScopedVariable) {
|
||||
if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & NodeFlags.Const) {
|
||||
error(node, Diagnostics.Cannot_redeclare_constant_0, symbolToString(localDeclarationSymbol));
|
||||
error(node, Diagnostics.Cannot_redeclare_block_scoped_variable_0, symbolToString(localDeclarationSymbol));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8363,6 +8366,10 @@ module ts {
|
||||
return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0;
|
||||
}
|
||||
|
||||
function hasEarlyErrors(sourceFile?: SourceFile): boolean {
|
||||
return forEach(getDiagnostics(sourceFile), d => d.isEarly);
|
||||
}
|
||||
|
||||
function isReferencedImportDeclaration(node: ImportDeclaration): boolean {
|
||||
var symbol = getSymbolOfNode(node);
|
||||
if (getSymbolLinks(symbol).referenced) {
|
||||
@ -8446,6 +8453,7 @@ module ts {
|
||||
getEnumMemberValue: getEnumMemberValue,
|
||||
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
|
||||
hasSemanticErrors: hasSemanticErrors,
|
||||
hasEarlyErrors: hasEarlyErrors,
|
||||
isDeclarationVisible: isDeclarationVisible,
|
||||
isImplementationOfOverload: isImplementationOfOverload,
|
||||
writeTypeAtLocation: writeTypeAtLocation,
|
||||
|
||||
@ -232,7 +232,8 @@ module ts {
|
||||
|
||||
messageText: text,
|
||||
category: message.category,
|
||||
code: message.code
|
||||
code: message.code,
|
||||
isEarly: message.isEarly
|
||||
};
|
||||
}
|
||||
|
||||
@ -251,7 +252,8 @@ module ts {
|
||||
|
||||
messageText: text,
|
||||
category: message.category,
|
||||
code: message.code
|
||||
code: message.code,
|
||||
isEarly: message.isEarly
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,6 @@ module ts {
|
||||
Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." },
|
||||
Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "Filename '{0}' differs from already included filename '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
An_enum_member_cannot_have_a_numeric_name: { code: 1151, category: DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." },
|
||||
var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." },
|
||||
let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
@ -267,10 +266,11 @@ module ts {
|
||||
Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." },
|
||||
Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." },
|
||||
The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." },
|
||||
Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." },
|
||||
The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." },
|
||||
Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." },
|
||||
Cannot_redeclare_constant_0: { code: 2451, category: DiagnosticCategory.Error, key: "Cannot redeclare constant '{0}'." },
|
||||
Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration.", isEarly: true },
|
||||
The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant.", isEarly: true },
|
||||
Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant.", isEarly: true },
|
||||
Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'.", isEarly: true },
|
||||
An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
|
||||
@ -447,10 +447,6 @@
|
||||
"category": "Error",
|
||||
"code": 1150
|
||||
},
|
||||
"An enum member cannot have a numeric name.": {
|
||||
"category": "Error",
|
||||
"code": 1151
|
||||
},
|
||||
"'var', 'let' or 'const' expected.": {
|
||||
"category": "Error",
|
||||
"code": 1152
|
||||
@ -1062,19 +1058,27 @@
|
||||
},
|
||||
"Block-scoped variable '{0}' used before its declaration.": {
|
||||
"category": "Error",
|
||||
"code": 2448
|
||||
"code": 2448,
|
||||
"isEarly": true
|
||||
},
|
||||
"The operand of an increment or decrement operator cannot be a constant.": {
|
||||
"category": "Error",
|
||||
"code": 2449
|
||||
"code": 2449,
|
||||
"isEarly": true
|
||||
},
|
||||
"Left-hand side of assignment expression cannot be a constant.": {
|
||||
"category": "Error",
|
||||
"code": 2450
|
||||
"code": 2450,
|
||||
"isEarly": true
|
||||
},
|
||||
"Cannot redeclare constant '{0}'.": {
|
||||
"Cannot redeclare block-scoped variable '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2451
|
||||
"code": 2451,
|
||||
"isEarly": true
|
||||
},
|
||||
"An enum member cannot have a numeric name.": {
|
||||
"category": "Error",
|
||||
"code": 2452
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
|
||||
@ -3271,11 +3271,14 @@ module ts {
|
||||
}
|
||||
|
||||
var hasSemanticErrors = resolver.hasSemanticErrors();
|
||||
var hasEarlyErrors = resolver.hasEarlyErrors(targetSourceFile);
|
||||
|
||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||
emitJavaScript(jsFilePath, sourceFile);
|
||||
if (!hasSemanticErrors && compilerOptions.declaration) {
|
||||
emitDeclarations(jsFilePath, sourceFile);
|
||||
if (!hasEarlyErrors) {
|
||||
emitJavaScript(jsFilePath, sourceFile);
|
||||
if (!hasSemanticErrors && compilerOptions.declaration) {
|
||||
emitDeclarations(jsFilePath, sourceFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3315,7 +3318,9 @@ module ts {
|
||||
|
||||
// Check and update returnCode for syntactic and semantic
|
||||
var returnCode: EmitReturnStatus;
|
||||
if (hasEmitterError) {
|
||||
if (hasEarlyErrors) {
|
||||
returnCode = EmitReturnStatus.AllOutputGenerationSkipped;
|
||||
} else if (hasEmitterError) {
|
||||
returnCode = EmitReturnStatus.EmitErrorsEncountered;
|
||||
} else if (hasSemanticErrors && compilerOptions.declaration) {
|
||||
returnCode = EmitReturnStatus.DeclarationGenerationSkipped;
|
||||
|
||||
@ -356,13 +356,18 @@ module ts {
|
||||
else {
|
||||
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
|
||||
var checkStart = new Date().getTime();
|
||||
var semanticErrors = checker.getDiagnostics();
|
||||
var emitStart = new Date().getTime();
|
||||
var emitOutput = checker.emitFiles();
|
||||
var emitErrors = emitOutput.errors;
|
||||
exitStatus = emitOutput.emitResultStatus;
|
||||
var reportStart = new Date().getTime();
|
||||
errors = concatenate(semanticErrors, emitErrors);
|
||||
errors = checker.getDiagnostics();
|
||||
if (!checker.hasEarlyErrors()) {
|
||||
var emitStart = new Date().getTime();
|
||||
var emitOutput = checker.emitFiles();
|
||||
var emitErrors = emitOutput.errors;
|
||||
exitStatus = emitOutput.emitResultStatus;
|
||||
var reportStart = new Date().getTime();
|
||||
errors = concatenate(errors, emitErrors);
|
||||
}
|
||||
else {
|
||||
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
|
||||
}
|
||||
}
|
||||
|
||||
reportDiagnostics(errors);
|
||||
|
||||
@ -667,6 +667,7 @@ module ts {
|
||||
isImplementationOfOverload(node: FunctionDeclaration): boolean;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
hasEarlyErrors(sourceFile?: SourceFile): boolean;
|
||||
|
||||
// Returns the constant value of this enum member, or 'undefined' if the enum member has a
|
||||
// computed value.
|
||||
@ -762,6 +763,7 @@ module ts {
|
||||
// Returns the constant value this property access resolves to, or 'undefined' if it does
|
||||
// resolve to a constant.
|
||||
getConstantValue(node: PropertyAccess): number;
|
||||
hasEarlyErrors(sourceFile?: SourceFile): boolean;
|
||||
}
|
||||
|
||||
export enum SymbolFlags {
|
||||
@ -1041,6 +1043,7 @@ module ts {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
isEarly?: boolean;
|
||||
}
|
||||
|
||||
// A linked list of formatted diagnostic messages to be used as part of a multiline message.
|
||||
@ -1061,6 +1064,7 @@ module ts {
|
||||
messageText: string;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
isEarly?: boolean;
|
||||
}
|
||||
|
||||
export enum DiagnosticCategory {
|
||||
|
||||
@ -801,9 +801,11 @@ module Harness {
|
||||
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
|
||||
checker.checkProgram();
|
||||
|
||||
var hasEarlyErrors = checker.hasEarlyErrors();
|
||||
|
||||
// only emit if there weren't parse errors
|
||||
var emitResult: ts.EmitResult;
|
||||
if (!hadParseErrors) {
|
||||
if (!hadParseErrors && !hasEarlyErrors) {
|
||||
emitResult = checker.emitFiles();
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(7,9): error TS2451: Cannot redeclare constant 'x'.
|
||||
tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(15,13): error TS2451: Cannot redeclare constant 'y'.
|
||||
tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(22,7): error TS2451: Cannot redeclare constant 'z'.
|
||||
tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(7,9): error TS2451: Cannot redeclare block-scoped variable 'x'.
|
||||
tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(15,13): error TS2451: Cannot redeclare block-scoped variable 'y'.
|
||||
tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(22,7): error TS2451: Cannot redeclare block-scoped variable 'z'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts (3 errors) ====
|
||||
@ -12,7 +12,7 @@ tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(22,7): error TS
|
||||
|
||||
var x = 0;
|
||||
~
|
||||
!!! error TS2451: Cannot redeclare constant 'x'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'x'.
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(22,7): error TS
|
||||
{
|
||||
var y = 0;
|
||||
~
|
||||
!!! error TS2451: Cannot redeclare constant 'y'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'y'.
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,5 +31,5 @@ tests/cases/compiler/constDeclarationShadowedByVarDeclaration.ts(22,7): error TS
|
||||
const z = 0;
|
||||
var z = 0
|
||||
~
|
||||
!!! error TS2451: Cannot redeclare constant 'z'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'z'.
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
//// [constDeclarationShadowedByVarDeclaration.ts]
|
||||
|
||||
// Error as declaration of var would cause a write to the const value
|
||||
var x = 0;
|
||||
{
|
||||
const x = 0;
|
||||
|
||||
var x = 0;
|
||||
}
|
||||
|
||||
|
||||
var y = 0;
|
||||
{
|
||||
const y = 0;
|
||||
{
|
||||
var y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
const z = 0;
|
||||
var z = 0
|
||||
}
|
||||
|
||||
//// [constDeclarationShadowedByVarDeclaration.js]
|
||||
// Error as declaration of var would cause a write to the const value
|
||||
var x = 0;
|
||||
{
|
||||
const x = 0;
|
||||
var x = 0;
|
||||
}
|
||||
var y = 0;
|
||||
{
|
||||
const y = 0;
|
||||
{
|
||||
var y = 0;
|
||||
}
|
||||
}
|
||||
{
|
||||
const z = 0;
|
||||
var z = 0;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/constDeclarations-access.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
const x = 0
|
||||
|
||||
//// [file2.ts]
|
||||
x++;
|
||||
|
||||
//// [file1.js]
|
||||
const x = 0;
|
||||
//// [file2.js]
|
||||
x++;
|
||||
@ -1,74 +0,0 @@
|
||||
//// [constDeclarations-access2.ts]
|
||||
|
||||
const x = 0
|
||||
|
||||
// Errors
|
||||
x = 1;
|
||||
x += 2;
|
||||
x -= 3;
|
||||
x *= 4;
|
||||
x /= 5;
|
||||
x %= 6;
|
||||
x <<= 7;
|
||||
x >>= 8;
|
||||
x >>>= 9;
|
||||
x &= 10;
|
||||
x |= 11;
|
||||
x ^= 12;
|
||||
|
||||
x++;
|
||||
x--;
|
||||
++x;
|
||||
--x;
|
||||
|
||||
++((x));
|
||||
|
||||
// OK
|
||||
var a = x + 1;
|
||||
|
||||
function f(v: number) { }
|
||||
f(x);
|
||||
|
||||
if (x) { }
|
||||
|
||||
x;
|
||||
(x);
|
||||
|
||||
-x;
|
||||
+x;
|
||||
|
||||
x.toString();
|
||||
|
||||
|
||||
//// [constDeclarations-access2.js]
|
||||
const x = 0;
|
||||
// Errors
|
||||
x = 1;
|
||||
x += 2;
|
||||
x -= 3;
|
||||
x *= 4;
|
||||
x /= 5;
|
||||
x %= 6;
|
||||
x <<= 7;
|
||||
x >>= 8;
|
||||
x >>>= 9;
|
||||
x &= 10;
|
||||
x |= 11;
|
||||
x ^= 12;
|
||||
x++;
|
||||
x--;
|
||||
++x;
|
||||
--x;
|
||||
++((x));
|
||||
// OK
|
||||
var a = x + 1;
|
||||
function f(v) {
|
||||
}
|
||||
f(x);
|
||||
if (x) {
|
||||
}
|
||||
x;
|
||||
(x);
|
||||
-x;
|
||||
+x;
|
||||
x.toString();
|
||||
@ -1,83 +0,0 @@
|
||||
//// [constDeclarations-access3.ts]
|
||||
|
||||
|
||||
module M {
|
||||
export const x = 0;
|
||||
}
|
||||
|
||||
// Errors
|
||||
M.x = 1;
|
||||
M.x += 2;
|
||||
M.x -= 3;
|
||||
M.x *= 4;
|
||||
M.x /= 5;
|
||||
M.x %= 6;
|
||||
M.x <<= 7;
|
||||
M.x >>= 8;
|
||||
M.x >>>= 9;
|
||||
M.x &= 10;
|
||||
M.x |= 11;
|
||||
M.x ^= 12;
|
||||
|
||||
M.x++;
|
||||
M.x--;
|
||||
++M.x;
|
||||
--M.x;
|
||||
|
||||
++((M.x));
|
||||
|
||||
M["x"] = 0;
|
||||
|
||||
// OK
|
||||
var a = M.x + 1;
|
||||
|
||||
function f(v: number) { }
|
||||
f(M.x);
|
||||
|
||||
if (M.x) { }
|
||||
|
||||
M.x;
|
||||
(M.x);
|
||||
|
||||
-M.x;
|
||||
+M.x;
|
||||
|
||||
M.x.toString();
|
||||
|
||||
|
||||
//// [constDeclarations-access3.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
M.x = 0;
|
||||
})(M || (M = {}));
|
||||
// Errors
|
||||
M.x = 1;
|
||||
M.x += 2;
|
||||
M.x -= 3;
|
||||
M.x *= 4;
|
||||
M.x /= 5;
|
||||
M.x %= 6;
|
||||
M.x <<= 7;
|
||||
M.x >>= 8;
|
||||
M.x >>>= 9;
|
||||
M.x &= 10;
|
||||
M.x |= 11;
|
||||
M.x ^= 12;
|
||||
M.x++;
|
||||
M.x--;
|
||||
++M.x;
|
||||
--M.x;
|
||||
++((M.x));
|
||||
M["x"] = 0;
|
||||
// OK
|
||||
var a = M.x + 1;
|
||||
function f(v) {
|
||||
}
|
||||
f(M.x);
|
||||
if (M.x) {
|
||||
}
|
||||
M.x;
|
||||
(M.x);
|
||||
-M.x;
|
||||
+M.x;
|
||||
M.x.toString();
|
||||
@ -1,79 +0,0 @@
|
||||
//// [constDeclarations-access4.ts]
|
||||
|
||||
|
||||
declare module M {
|
||||
const x: number;
|
||||
}
|
||||
|
||||
// Errors
|
||||
M.x = 1;
|
||||
M.x += 2;
|
||||
M.x -= 3;
|
||||
M.x *= 4;
|
||||
M.x /= 5;
|
||||
M.x %= 6;
|
||||
M.x <<= 7;
|
||||
M.x >>= 8;
|
||||
M.x >>>= 9;
|
||||
M.x &= 10;
|
||||
M.x |= 11;
|
||||
M.x ^= 12;
|
||||
|
||||
M.x++;
|
||||
M.x--;
|
||||
++M.x;
|
||||
--M.x;
|
||||
|
||||
++((M.x));
|
||||
|
||||
M["x"] = 0;
|
||||
|
||||
// OK
|
||||
var a = M.x + 1;
|
||||
|
||||
function f(v: number) { }
|
||||
f(M.x);
|
||||
|
||||
if (M.x) { }
|
||||
|
||||
M.x;
|
||||
(M.x);
|
||||
|
||||
-M.x;
|
||||
+M.x;
|
||||
|
||||
M.x.toString();
|
||||
|
||||
|
||||
//// [constDeclarations-access4.js]
|
||||
// Errors
|
||||
M.x = 1;
|
||||
M.x += 2;
|
||||
M.x -= 3;
|
||||
M.x *= 4;
|
||||
M.x /= 5;
|
||||
M.x %= 6;
|
||||
M.x <<= 7;
|
||||
M.x >>= 8;
|
||||
M.x >>>= 9;
|
||||
M.x &= 10;
|
||||
M.x |= 11;
|
||||
M.x ^= 12;
|
||||
M.x++;
|
||||
M.x--;
|
||||
++M.x;
|
||||
--M.x;
|
||||
++((M.x));
|
||||
M["x"] = 0;
|
||||
// OK
|
||||
var a = M.x + 1;
|
||||
function f(v) {
|
||||
}
|
||||
f(M.x);
|
||||
if (M.x) {
|
||||
}
|
||||
M.x;
|
||||
(M.x);
|
||||
-M.x;
|
||||
+M.x;
|
||||
M.x.toString();
|
||||
@ -1,89 +0,0 @@
|
||||
//// [tests/cases/compiler/constDeclarations-access5.ts] ////
|
||||
|
||||
//// [constDeclarations_access_1.ts]
|
||||
|
||||
|
||||
export const x = 0;
|
||||
|
||||
//// [constDeclarations_access_2.ts]
|
||||
///<reference path='constDeclarations_access_1.ts'/>
|
||||
import m = require('constDeclarations_access_1');
|
||||
// Errors
|
||||
m.x = 1;
|
||||
m.x += 2;
|
||||
m.x -= 3;
|
||||
m.x *= 4;
|
||||
m.x /= 5;
|
||||
m.x %= 6;
|
||||
m.x <<= 7;
|
||||
m.x >>= 8;
|
||||
m.x >>>= 9;
|
||||
m.x &= 10;
|
||||
m.x |= 11;
|
||||
m.x ^= 12;
|
||||
m
|
||||
m.x++;
|
||||
m.x--;
|
||||
++m.x;
|
||||
--m.x;
|
||||
|
||||
++((m.x));
|
||||
|
||||
m["x"] = 0;
|
||||
|
||||
// OK
|
||||
var a = m.x + 1;
|
||||
|
||||
function f(v: number) { }
|
||||
f(m.x);
|
||||
|
||||
if (m.x) { }
|
||||
|
||||
m.x;
|
||||
(m.x);
|
||||
|
||||
-m.x;
|
||||
+m.x;
|
||||
|
||||
m.x.toString();
|
||||
|
||||
|
||||
//// [constDeclarations_access_1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
exports.x = 0;
|
||||
});
|
||||
//// [constDeclarations_access_2.js]
|
||||
define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) {
|
||||
// Errors
|
||||
m.x = 1;
|
||||
m.x += 2;
|
||||
m.x -= 3;
|
||||
m.x *= 4;
|
||||
m.x /= 5;
|
||||
m.x %= 6;
|
||||
m.x <<= 7;
|
||||
m.x >>= 8;
|
||||
m.x >>>= 9;
|
||||
m.x &= 10;
|
||||
m.x |= 11;
|
||||
m.x ^= 12;
|
||||
m;
|
||||
m.x++;
|
||||
m.x--;
|
||||
++m.x;
|
||||
--m.x;
|
||||
++((m.x));
|
||||
m["x"] = 0;
|
||||
// OK
|
||||
var a = m.x + 1;
|
||||
function f(v) {
|
||||
}
|
||||
f(m.x);
|
||||
if (m.x) {
|
||||
}
|
||||
m.x;
|
||||
(m.x);
|
||||
-m.x;
|
||||
+m.x;
|
||||
m.x.toString();
|
||||
});
|
||||
@ -1,24 +0,0 @@
|
||||
//// [constDeclarations-useBeforeDefinition.ts]
|
||||
|
||||
{
|
||||
c1;
|
||||
const c1 = 0;
|
||||
}
|
||||
|
||||
var v1;
|
||||
{
|
||||
v1;
|
||||
const v1 = 0;
|
||||
}
|
||||
|
||||
|
||||
//// [constDeclarations-useBeforeDefinition.js]
|
||||
{
|
||||
c1;
|
||||
const c1 = 0;
|
||||
}
|
||||
var v1;
|
||||
{
|
||||
v1;
|
||||
const v1 = 0;
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
//// [tests/cases/compiler/constDeclarations-useBeforeDefinition2.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
c;
|
||||
|
||||
//// [file2.ts]
|
||||
const c = 0;
|
||||
|
||||
//// [out.js]
|
||||
c;
|
||||
const c = 0;
|
||||
@ -1,22 +1,22 @@
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(2,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(3,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(4,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(6,5): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(2,5): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(3,5): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(4,5): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/compiler/enumIdentifierLiterals.ts(6,5): error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumIdentifierLiterals.ts (4 errors) ====
|
||||
enum Nums {
|
||||
1.0,
|
||||
~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
11e-1,
|
||||
~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
0.12e1,
|
||||
~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
"13e-1",
|
||||
0xF00D
|
||||
~~~~~~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
}
|
||||
@ -1,27 +1,27 @@
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(3,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(4,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(6,5): error TS2300: Duplicate identifier 'var2'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(7,7): error TS2300: Duplicate identifier 'var2'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(9,7): error TS2300: Duplicate identifier 'var3'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(10,5): error TS2300: Duplicate identifier 'var3'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(12,7): error TS2300: Duplicate identifier 'var4'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(13,7): error TS2300: Duplicate identifier 'var4'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(3,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(4,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(6,5): error TS2451: Cannot redeclare block-scoped variable 'var2'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(7,7): error TS2451: Cannot redeclare block-scoped variable 'var2'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(9,7): error TS2451: Cannot redeclare block-scoped variable 'var3'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(10,5): error TS2451: Cannot redeclare block-scoped variable 'var3'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(12,7): error TS2451: Cannot redeclare block-scoped variable 'var4'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(13,7): error TS2451: Cannot redeclare block-scoped variable 'var4'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(15,5): error TS2300: Duplicate identifier 'var5'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(16,5): error TS2300: Duplicate identifier 'var5'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(18,5): error TS2300: Duplicate identifier 'var6'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(19,5): error TS2300: Duplicate identifier 'var6'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(22,9): error TS2300: Duplicate identifier 'var7'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(23,9): error TS2300: Duplicate identifier 'var7'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(25,13): error TS2300: Duplicate identifier 'var8'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(26,15): error TS2300: Duplicate identifier 'var8'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(32,13): error TS2300: Duplicate identifier 'var9'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(33,13): error TS2300: Duplicate identifier 'var9'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(37,11): error TS2300: Duplicate identifier 'var10'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(38,11): error TS2300: Duplicate identifier 'var10'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(41,9): error TS2300: Duplicate identifier 'var11'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(42,9): error TS2300: Duplicate identifier 'var11'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(46,9): error TS2300: Duplicate identifier 'var12'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(47,9): error TS2300: Duplicate identifier 'var12'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(18,5): error TS2451: Cannot redeclare block-scoped variable 'var6'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(19,5): error TS2451: Cannot redeclare block-scoped variable 'var6'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(22,9): error TS2451: Cannot redeclare block-scoped variable 'var7'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(23,9): error TS2451: Cannot redeclare block-scoped variable 'var7'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(25,13): error TS2451: Cannot redeclare block-scoped variable 'var8'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(26,15): error TS2451: Cannot redeclare block-scoped variable 'var8'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(32,13): error TS2451: Cannot redeclare block-scoped variable 'var9'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(33,13): error TS2451: Cannot redeclare block-scoped variable 'var9'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(37,11): error TS2451: Cannot redeclare block-scoped variable 'var10'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(38,11): error TS2451: Cannot redeclare block-scoped variable 'var10'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(41,9): error TS2451: Cannot redeclare block-scoped variable 'var11'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(42,9): error TS2451: Cannot redeclare block-scoped variable 'var11'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(46,9): error TS2451: Cannot redeclare block-scoped variable 'var12'.
|
||||
tests/cases/compiler/letDeclarations-scopes-duplicates.ts(47,9): error TS2451: Cannot redeclare block-scoped variable 'var12'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/letDeclarations-scopes-duplicates.ts (24 errors) ====
|
||||
@ -29,31 +29,31 @@ tests/cases/compiler/letDeclarations-scopes-duplicates.ts(47,9): error TS2300: D
|
||||
// Errors: redeclaration
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
let var1 = 0; // error
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
let var2 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var2'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var2'.
|
||||
const var2 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var2'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var2'.
|
||||
|
||||
const var3 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var3'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var3'.
|
||||
let var3 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var3'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var3'.
|
||||
|
||||
const var4 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var4'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var4'.
|
||||
const var4 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var4'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var4'.
|
||||
|
||||
var var5 = 0;
|
||||
~~~~
|
||||
@ -64,25 +64,25 @@ tests/cases/compiler/letDeclarations-scopes-duplicates.ts(47,9): error TS2300: D
|
||||
|
||||
let var6 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var6'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var6'.
|
||||
var var6 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var6'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var6'.
|
||||
|
||||
{
|
||||
let var7 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var7'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var7'.
|
||||
let var7 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var7'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var7'.
|
||||
{
|
||||
let var8 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var8'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var8'.
|
||||
const var8 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var8'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var8'.
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,36 +90,36 @@ tests/cases/compiler/letDeclarations-scopes-duplicates.ts(47,9): error TS2300: D
|
||||
default:
|
||||
let var9 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var9'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var9'.
|
||||
let var9 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var9'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var9'.
|
||||
}
|
||||
|
||||
try {
|
||||
const var10 = 0;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var10'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var10'.
|
||||
const var10 = 0;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var10'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var10'.
|
||||
}
|
||||
catch (e) {
|
||||
let var11 = 0;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var11'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var11'.
|
||||
let var11 = 0;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var11'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var11'.
|
||||
}
|
||||
|
||||
function F1() {
|
||||
let var12;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var12'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var12'.
|
||||
let var12;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var12'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var12'.
|
||||
}
|
||||
|
||||
// OK
|
||||
|
||||
@ -1,140 +0,0 @@
|
||||
//// [letDeclarations-scopes-duplicates.ts]
|
||||
|
||||
// Errors: redeclaration
|
||||
let var1 = 0;
|
||||
let var1 = 0; // error
|
||||
|
||||
let var2 = 0;
|
||||
const var2 = 0;
|
||||
|
||||
const var3 = 0;
|
||||
let var3 = 0;
|
||||
|
||||
const var4 = 0;
|
||||
const var4 = 0;
|
||||
|
||||
var var5 = 0;
|
||||
let var5 = 0;
|
||||
|
||||
let var6 = 0;
|
||||
var var6 = 0;
|
||||
|
||||
{
|
||||
let var7 = 0;
|
||||
let var7 = 0;
|
||||
{
|
||||
let var8 = 0;
|
||||
const var8 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch (0) {
|
||||
default:
|
||||
let var9 = 0;
|
||||
let var9 = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
const var10 = 0;
|
||||
const var10 = 0;
|
||||
}
|
||||
catch (e) {
|
||||
let var11 = 0;
|
||||
let var11 = 0;
|
||||
}
|
||||
|
||||
function F1() {
|
||||
let var12;
|
||||
let var12;
|
||||
}
|
||||
|
||||
// OK
|
||||
var var20 = 0;
|
||||
|
||||
var var20 = 0
|
||||
{
|
||||
let var20 = 0;
|
||||
{
|
||||
let var20 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch (0) {
|
||||
default:
|
||||
let var20 = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
let var20 = 0;
|
||||
}
|
||||
catch (e) {
|
||||
let var20 = 0;
|
||||
}
|
||||
|
||||
function F() {
|
||||
let var20;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [letDeclarations-scopes-duplicates.js]
|
||||
// Errors: redeclaration
|
||||
let var1 = 0;
|
||||
let var1 = 0; // error
|
||||
let var2 = 0;
|
||||
const var2 = 0;
|
||||
const var3 = 0;
|
||||
let var3 = 0;
|
||||
const var4 = 0;
|
||||
const var4 = 0;
|
||||
var var5 = 0;
|
||||
let var5 = 0;
|
||||
let var6 = 0;
|
||||
var var6 = 0;
|
||||
{
|
||||
let var7 = 0;
|
||||
let var7 = 0;
|
||||
{
|
||||
let var8 = 0;
|
||||
const var8 = 0;
|
||||
}
|
||||
}
|
||||
switch (0) {
|
||||
default:
|
||||
let var9 = 0;
|
||||
let var9 = 0;
|
||||
}
|
||||
try {
|
||||
const var10 = 0;
|
||||
const var10 = 0;
|
||||
}
|
||||
catch (e) {
|
||||
let var11 = 0;
|
||||
let var11 = 0;
|
||||
}
|
||||
function F1() {
|
||||
let var12;
|
||||
let var12;
|
||||
}
|
||||
// OK
|
||||
var var20 = 0;
|
||||
var var20 = 0;
|
||||
{
|
||||
let var20 = 0;
|
||||
{
|
||||
let var20 = 0;
|
||||
}
|
||||
}
|
||||
switch (0) {
|
||||
default:
|
||||
let var20 = 0;
|
||||
}
|
||||
try {
|
||||
let var20 = 0;
|
||||
}
|
||||
catch (e) {
|
||||
let var20 = 0;
|
||||
}
|
||||
function F() {
|
||||
let var20;
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/letDeclarations-scopes-duplicates2.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
let var1 = 0;
|
||||
|
||||
//// [file2.ts]
|
||||
let var1 = 0;
|
||||
|
||||
//// [file1.js]
|
||||
let var1 = 0;
|
||||
//// [file2.js]
|
||||
let var1 = 0;
|
||||
@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
const var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/letDeclarations-scopes-duplicates3.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
let var1 = 0;
|
||||
|
||||
//// [file2.ts]
|
||||
const var1 = 0;
|
||||
|
||||
//// [file1.js]
|
||||
let var1 = 0;
|
||||
//// [file2.js]
|
||||
const var1 = 0;
|
||||
@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file1.ts(2,7): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
const var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/letDeclarations-scopes-duplicates4.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
const var1 = 0;
|
||||
|
||||
//// [file2.ts]
|
||||
let var1 = 0;
|
||||
|
||||
//// [file1.js]
|
||||
const var1 = 0;
|
||||
//// [file2.js]
|
||||
let var1 = 0;
|
||||
@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/file1.ts(2,7): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file1.ts(2,7): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,7): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
const var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
const var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/letDeclarations-scopes-duplicates5.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
const var1 = 0;
|
||||
|
||||
//// [file2.ts]
|
||||
const var1 = 0;
|
||||
|
||||
//// [file1.js]
|
||||
const var1 = 0;
|
||||
//// [file2.js]
|
||||
const var1 = 0;
|
||||
@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
var var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/letDeclarations-scopes-duplicates6.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
var var1 = 0;
|
||||
|
||||
//// [file2.ts]
|
||||
let var1 = 0;
|
||||
|
||||
//// [file1.js]
|
||||
var var1 = 0;
|
||||
//// [file2.js]
|
||||
let var1 = 0;
|
||||
@ -1,14 +1,14 @@
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2300: Duplicate identifier 'var1'.
|
||||
tests/cases/compiler/file1.ts(2,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
tests/cases/compiler/file2.ts(1,5): error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/file1.ts (1 errors) ====
|
||||
|
||||
let var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
|
||||
==== tests/cases/compiler/file2.ts (1 errors) ====
|
||||
var var1 = 0;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'var1'.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'var1'.
|
||||
@ -1,13 +0,0 @@
|
||||
//// [tests/cases/compiler/letDeclarations-scopes-duplicates7.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
let var1 = 0;
|
||||
|
||||
//// [file2.ts]
|
||||
var var1 = 0;
|
||||
|
||||
//// [file1.js]
|
||||
let var1 = 0;
|
||||
//// [file2.js]
|
||||
var var1 = 0;
|
||||
@ -1,24 +0,0 @@
|
||||
//// [letDeclarations-useBeforeDefinition.ts]
|
||||
|
||||
{
|
||||
l1;
|
||||
let l1;
|
||||
}
|
||||
|
||||
var v1;
|
||||
{
|
||||
v1;
|
||||
let v1 = 0;
|
||||
}
|
||||
|
||||
|
||||
//// [letDeclarations-useBeforeDefinition.js]
|
||||
{
|
||||
l1;
|
||||
let l1;
|
||||
}
|
||||
var v1;
|
||||
{
|
||||
v1;
|
||||
let v1 = 0;
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
//// [tests/cases/compiler/letDeclarations-useBeforeDefinition2.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
l;
|
||||
|
||||
//// [file2.ts]
|
||||
const l = 0;
|
||||
|
||||
//// [out.js]
|
||||
l;
|
||||
const l = 0;
|
||||
@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(2,12): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,15): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,24): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(2,14): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,17): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,26): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(2,14): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,17): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,26): error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts (6 errors) ====
|
||||
@ -12,13 +12,13 @@ tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum5.ts(3,26)
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
enum E1 { a, b: 1, c, d: 2 = 3 }
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
@ -1,15 +1,15 @@
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts(2,3): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts(2,6): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts(2,9): error TS1151: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts(2,3): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts(2,6): error TS2452: An enum member cannot have a numeric name.
|
||||
tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts(2,9): error TS2452: An enum member cannot have a numeric name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserEnum7.ts (3 errors) ====
|
||||
enum E {
|
||||
1, 2, 3
|
||||
~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
~
|
||||
!!! error TS1151: An enum member cannot have a numeric name.
|
||||
!!! error TS2452: An enum member cannot have a numeric name.
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user