mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into navbar
Also fixed getSourceText and renamed it to getTextOfNode
This commit is contained in:
Binary file not shown.
Binary file not shown.
+4
-4
@@ -581,10 +581,10 @@ For this switch statement, the compiler will generate the following code.
|
||||
|
||||
```TypeScript
|
||||
switch (op) {
|
||||
case 0 /* Operator.ADD */ :
|
||||
case 0 /* Operator.ADD */:
|
||||
// execute add
|
||||
break;
|
||||
case 1 /* Operator.DIV */ :
|
||||
case 1 /* Operator.DIV */:
|
||||
// execute div
|
||||
break;
|
||||
// ...
|
||||
@@ -738,7 +738,7 @@ var M;
|
||||
return s;
|
||||
}
|
||||
M.f = f;
|
||||
})(M||(M={}));
|
||||
})(M || (M = {}));
|
||||
```
|
||||
|
||||
In this case, the compiler assumes that the module object resides in global variable ‘M’, which may or may not have been initialized to the desired module object.
|
||||
@@ -1068,7 +1068,7 @@ Type references (section [3.6.2](#3.6.2)) to class and interface types are class
|
||||
|
||||
### <a name="3.3.2"/>3.3.2 Array Types
|
||||
|
||||
***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type ‘Array’ in the global module with the array element type as a type argument. Array type literals (section [Error! Reference source not found.](#Error! Reference source not found.)) provide a shorthand notation for creating such references.
|
||||
***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type ‘Array’ in the global module with the array element type as a type argument. Array type literals (section [3.6.4](#3.6.4)) provide a shorthand notation for creating such references.
|
||||
|
||||
The declaration of the ‘Array’ interface includes a property ‘length’ and a numeric index signature for the element type, along with other members:
|
||||
|
||||
|
||||
@@ -84,8 +84,13 @@ module ts {
|
||||
if (node.name) {
|
||||
node.name.parent = node;
|
||||
}
|
||||
file.semanticErrors.push(createDiagnosticForNode(node.name ? node.name : node,
|
||||
Diagnostics.Duplicate_identifier_0, getDisplayName(node)));
|
||||
// Report errors every position with duplicate declaration
|
||||
// Report errors on previous encountered declarations
|
||||
forEach(symbol.declarations, (declaration) => {
|
||||
file.semanticErrors.push(createDiagnosticForNode(declaration.name, Diagnostics.Duplicate_identifier_0, getDisplayName(declaration)));
|
||||
});
|
||||
file.semanticErrors.push(createDiagnosticForNode(node.name, Diagnostics.Duplicate_identifier_0, getDisplayName(node)));
|
||||
|
||||
symbol = createSymbol(0, name);
|
||||
}
|
||||
}
|
||||
|
||||
+65
-109
@@ -92,7 +92,9 @@ module ts {
|
||||
getContextualType: getContextualType,
|
||||
getFullyQualifiedName: getFullyQualifiedName,
|
||||
getResolvedSignature: getResolvedSignature,
|
||||
getEnumMemberValue: getEnumMemberValue
|
||||
getEnumMemberValue: getEnumMemberValue,
|
||||
isValidPropertyAccess: isValidPropertyAccess,
|
||||
getAliasedSymbol: resolveImport
|
||||
};
|
||||
|
||||
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
|
||||
@@ -2573,7 +2575,7 @@ module ts {
|
||||
function getStringLiteralType(node: StringLiteralTypeNode): StringLiteralType {
|
||||
if (hasProperty(stringLiteralTypes, node.text)) return stringLiteralTypes[node.text];
|
||||
var type = stringLiteralTypes[node.text] = <StringLiteralType>createType(TypeFlags.StringLiteral);
|
||||
type.text = getSourceTextOfNode(node);
|
||||
type.text = getTextOfNode(node);
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -4239,6 +4241,25 @@ module ts {
|
||||
return anyType;
|
||||
}
|
||||
|
||||
function isValidPropertyAccess(node: PropertyAccess, propertyName: string): boolean {
|
||||
var type = checkExpression(node.left);
|
||||
if (type !== unknownType && type !== anyType) {
|
||||
var apparentType = getApparentType(getWidenedType(type));
|
||||
var prop = getPropertyOfApparentType(apparentType, propertyName);
|
||||
if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) {
|
||||
if (node.left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.Method) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
var diagnosticsCount = diagnostics.length;
|
||||
checkClassPropertyAccess(node, type, prop);
|
||||
return diagnostics.length === diagnosticsCount
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkIndexedAccess(node: IndexedAccess): Type {
|
||||
var objectType = checkExpression(node.object);
|
||||
var indexType = checkExpression(node.index);
|
||||
@@ -4311,25 +4332,32 @@ module ts {
|
||||
}
|
||||
|
||||
function signatureHasCorrectArity(node: CallExpression, signature: Signature): boolean {
|
||||
var args = node.arguments || emptyArray;
|
||||
var isCorrect = args.length >= signature.minArgumentCount &&
|
||||
(signature.hasRestParameter || args.length <= signature.parameters.length) &&
|
||||
(!node.typeArguments || signature.typeParameters && node.typeArguments.length === signature.typeParameters.length);
|
||||
|
||||
// For error recovery, since we have parsed OmittedExpressions for any extra commas
|
||||
// in the argument list, if we see any OmittedExpressions, just return true.
|
||||
// The reason this is ok is because omitted expressions here are syntactically
|
||||
// illegal, and will cause a parse error.
|
||||
// Note: It may be worth keeping the upper bound check on arity, but removing
|
||||
// the lower bound check if there are omitted expressions.
|
||||
if (!isCorrect) {
|
||||
// Technically this type assertion is not safe because args could be initialized to emptyArray
|
||||
// above.
|
||||
if ((<NodeArray<Node>>args).hasTrailingComma || forEach(args, arg => arg.kind === SyntaxKind.OmittedExpression)) {
|
||||
return true;
|
||||
}
|
||||
if (!node.arguments) {
|
||||
// This only happens when we have something of the form:
|
||||
// new C
|
||||
//
|
||||
return signature.minArgumentCount === 0;
|
||||
}
|
||||
return isCorrect;
|
||||
|
||||
// For IDE scenarios, since we may have an incomplete call, we make two modifications
|
||||
// to arity checking.
|
||||
// 1. A trailing comma is tantamount to adding another argument
|
||||
// 2. If the call is incomplete (no closing paren) allow fewer arguments than expected
|
||||
var args = node.arguments;
|
||||
var numberOfArgs = args.hasTrailingComma ? args.length + 1 : args.length;
|
||||
var hasTooManyArguments = !signature.hasRestParameter && numberOfArgs > signature.parameters.length;
|
||||
var hasRightNumberOfTypeArguments = !node.typeArguments ||
|
||||
(signature.typeParameters && node.typeArguments.length === signature.typeParameters.length);
|
||||
|
||||
if (hasTooManyArguments || !hasRightNumberOfTypeArguments) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we are missing the close paren, the call is incomplete, and we should skip
|
||||
// the lower bound check.
|
||||
var callIsIncomplete = args.end === node.end;
|
||||
var hasEnoughArguments = numberOfArgs >= signature.minArgumentCount;
|
||||
return callIsIncomplete || hasEnoughArguments;
|
||||
}
|
||||
|
||||
// If type has a single call signature and no other members, return that signature. Otherwise, return undefined.
|
||||
@@ -5672,6 +5700,8 @@ module ts {
|
||||
// when checking exported function declarations across modules check only duplicate implementations
|
||||
// names and consistency of modifiers are verified when we check local symbol
|
||||
var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & SymbolFlags.Module;
|
||||
var duplicateFunctionDeclaration = false;
|
||||
var multipleConstructorImplementation = false;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var node = <FunctionDeclaration>declarations[i];
|
||||
var inAmbientContext = isInAmbientContext(node);
|
||||
@@ -5694,10 +5724,10 @@ module ts {
|
||||
|
||||
if (node.body && bodyDeclaration) {
|
||||
if (isConstructor) {
|
||||
error(node, Diagnostics.Multiple_constructor_implementations_are_not_allowed);
|
||||
multipleConstructorImplementation = true;
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.Duplicate_function_implementation);
|
||||
duplicateFunctionDeclaration = true;
|
||||
}
|
||||
}
|
||||
else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
|
||||
@@ -5721,6 +5751,18 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (multipleConstructorImplementation) {
|
||||
forEach(declarations, declaration => {
|
||||
error(declaration, Diagnostics.Multiple_constructor_implementations_are_not_allowed);
|
||||
});
|
||||
}
|
||||
|
||||
if (duplicateFunctionDeclaration) {
|
||||
forEach( declarations, declaration => {
|
||||
error(declaration.name, Diagnostics.Duplicate_function_implementation);
|
||||
});
|
||||
}
|
||||
|
||||
if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) {
|
||||
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
|
||||
}
|
||||
@@ -7061,23 +7103,6 @@ module ts {
|
||||
return mapToArray(symbols);
|
||||
}
|
||||
|
||||
// True if the given identifier is the name of a type declaration node (class, interface, enum, type parameter, etc)
|
||||
function isTypeDeclarationName(name: Node): boolean {
|
||||
return name.kind == SyntaxKind.Identifier &&
|
||||
isTypeDeclaration(name.parent) &&
|
||||
(<Declaration>name.parent).name === name;
|
||||
}
|
||||
|
||||
function isTypeDeclaration(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// True if the given identifier is part of a type reference
|
||||
function isTypeReferenceIdentifier(entityName: EntityName): boolean {
|
||||
var node: Node = entityName;
|
||||
@@ -7156,75 +7181,6 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isTypeNode(node: Node): boolean {
|
||||
if (node.kind >= SyntaxKind.FirstTypeNode && node.kind <= SyntaxKind.LastTypeNode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
return true;
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return node.parent.kind !== SyntaxKind.PrefixOperator;
|
||||
case SyntaxKind.StringLiteral:
|
||||
// Specialized signatures can have string literals as their parameters' type names
|
||||
return node.parent.kind === SyntaxKind.Parameter;
|
||||
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
||||
// above them to find the lowest container
|
||||
case SyntaxKind.Identifier:
|
||||
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is.
|
||||
if (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
}
|
||||
// Fall through
|
||||
case SyntaxKind.QualifiedName:
|
||||
// At this point, node is either a qualified name or an identifier
|
||||
var parent = node.parent;
|
||||
if (parent.kind === SyntaxKind.TypeQuery) {
|
||||
return false;
|
||||
}
|
||||
// Do not recursively call isTypeNode on the parent. In the example:
|
||||
//
|
||||
// var a: A.B.C;
|
||||
//
|
||||
// Calling isTypeNode would consider the qualified name A.B a type node. Only C or
|
||||
// A.B.C is a type node.
|
||||
if (parent.kind >= SyntaxKind.FirstTypeNode && parent.kind <= SyntaxKind.LastTypeNode) {
|
||||
return true;
|
||||
}
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
return node === (<TypeParameterDeclaration>parent).constraint;
|
||||
case SyntaxKind.Property:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return node === (<VariableDeclaration>parent).type;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node === (<FunctionDeclaration>parent).type;
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
return node === (<SignatureDeclaration>parent).type;
|
||||
case SyntaxKind.TypeAssertion:
|
||||
return node === (<TypeAssertion>parent).type;
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
return (<CallExpression>parent).typeArguments.indexOf(node) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isInRightSideOfImportOrExportAssignment(node: EntityName) {
|
||||
while (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
@@ -7478,7 +7434,7 @@ module ts {
|
||||
while (!isUniqueLocalName(escapeIdentifier(prefix + name), container)) {
|
||||
prefix += "_";
|
||||
}
|
||||
links.localModuleName = prefix + getSourceTextOfNode(container.name);
|
||||
links.localModuleName = prefix + getTextOfNode(container.name);
|
||||
}
|
||||
return links.localModuleName;
|
||||
}
|
||||
|
||||
@@ -209,11 +209,9 @@ module ts {
|
||||
export var localizedDiagnosticMessages: Map<string> = undefined;
|
||||
|
||||
export function getLocaleSpecificMessage(message: string) {
|
||||
if (ts.localizedDiagnosticMessages) {
|
||||
message = localizedDiagnosticMessages[message];
|
||||
}
|
||||
|
||||
return message;
|
||||
return localizedDiagnosticMessages && localizedDiagnosticMessages[message]
|
||||
? localizedDiagnosticMessages[message]
|
||||
: message;
|
||||
}
|
||||
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
|
||||
@@ -5,6 +5,7 @@ module ts {
|
||||
Unterminated_string_literal: { code: 1002, category: DiagnosticCategory.Error, key: "Unterminated string literal." },
|
||||
Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." },
|
||||
_0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." },
|
||||
A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." },
|
||||
Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." },
|
||||
Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." },
|
||||
Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." },
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
"'{0}' expected.": {
|
||||
"category": "Error",
|
||||
"code": 1005
|
||||
},
|
||||
"A file cannot have a reference to itself.": {
|
||||
"category": "Error",
|
||||
"code": 1006
|
||||
},
|
||||
"Trailing comma not allowed.": {
|
||||
"category": "Error",
|
||||
@@ -1355,6 +1359,7 @@
|
||||
"category": "Error",
|
||||
"code": 5001
|
||||
},
|
||||
|
||||
"Cannot find the common subdirectory path for the input files.": {
|
||||
"category": "Error",
|
||||
"code": 5009
|
||||
|
||||
@@ -3127,7 +3127,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveScriptReference(sourceFile: SourceFile, reference: FileReference) {
|
||||
function tryResolveScriptReference(sourceFile: SourceFile, reference: FileReference) {
|
||||
var referenceFileName = normalizePath(combinePaths(getDirectoryPath(sourceFile.filename), reference.filename));
|
||||
return program.getSourceFile(referenceFileName);
|
||||
}
|
||||
@@ -3157,12 +3157,12 @@ module ts {
|
||||
if (!compilerOptions.noResolve) {
|
||||
var addedGlobalFileReference = false;
|
||||
forEach(root.referencedFiles, fileReference => {
|
||||
var referencedFile = resolveScriptReference(root, fileReference);
|
||||
var referencedFile = tryResolveScriptReference(root, fileReference);
|
||||
|
||||
// All the references that are not going to be part of same file
|
||||
if ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||
if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||
shouldEmitToOwnFile(referencedFile, compilerOptions) || // This is referenced file is emitting its own js file
|
||||
!addedGlobalFileReference) { // Or the global out file corresponding to this reference was not added
|
||||
!addedGlobalFileReference)) { // Or the global out file corresponding to this reference was not added
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
if (!isExternalModuleOrDeclarationFile(referencedFile)) {
|
||||
@@ -3182,11 +3182,11 @@ module ts {
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
var referencedFile = resolveScriptReference(sourceFile, fileReference);
|
||||
var referencedFile = tryResolveScriptReference(sourceFile, fileReference);
|
||||
|
||||
// If the reference file is a declaration file or an external module, emit that reference
|
||||
if (isExternalModuleOrDeclarationFile(referencedFile) &&
|
||||
!contains(emittedReferencedFiles, referencedFile)) { // If the file reference was not already emitted
|
||||
if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) &&
|
||||
!contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
emittedReferencedFiles.push(referencedFile);
|
||||
|
||||
+127
-22
@@ -43,11 +43,11 @@ module ts {
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
||||
export function getTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
||||
return sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNode(node: Node): string {
|
||||
export function getTextOfNode(node: Node): string {
|
||||
var text = getSourceFileOfNode(node).text;
|
||||
return text.substring(skipTrivia(text, node.pos), node.end);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ module ts {
|
||||
|
||||
// Return display name of an identifier
|
||||
export function identifierToString(identifier: Identifier) {
|
||||
return identifier.kind === SyntaxKind.Missing ? "(Missing)" : getSourceTextOfNode(identifier);
|
||||
return identifier.kind === SyntaxKind.Missing ? "(Missing)" : getTextOfNode(identifier);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
|
||||
@@ -391,6 +391,100 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this function only works when given a node with valid parent pointers.
|
||||
*/
|
||||
export function isTypeNode(node: Node): boolean {
|
||||
if (node.kind >= SyntaxKind.FirstTypeNode && node.kind <= SyntaxKind.LastTypeNode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
return true;
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return node.parent.kind !== SyntaxKind.PrefixOperator;
|
||||
case SyntaxKind.StringLiteral:
|
||||
// Specialized signatures can have string literals as their parameters' type names
|
||||
return node.parent.kind === SyntaxKind.Parameter;
|
||||
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
||||
// above them to find the lowest container
|
||||
case SyntaxKind.Identifier:
|
||||
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is.
|
||||
if (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
}
|
||||
// Fall through
|
||||
case SyntaxKind.QualifiedName:
|
||||
// At this point, node is either a qualified name or an identifier
|
||||
var parent = node.parent;
|
||||
if (parent.kind === SyntaxKind.TypeQuery) {
|
||||
return false;
|
||||
}
|
||||
// Do not recursively call isTypeNode on the parent. In the example:
|
||||
//
|
||||
// var a: A.B.C;
|
||||
//
|
||||
// Calling isTypeNode would consider the qualified name A.B a type node. Only C or
|
||||
// A.B.C is a type node.
|
||||
if (parent.kind >= SyntaxKind.FirstTypeNode && parent.kind <= SyntaxKind.LastTypeNode) {
|
||||
return true;
|
||||
}
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
return node === (<TypeParameterDeclaration>parent).constraint;
|
||||
case SyntaxKind.Property:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return node === (<VariableDeclaration>parent).type;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node === (<FunctionDeclaration>parent).type;
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
return node === (<SignatureDeclaration>parent).type;
|
||||
case SyntaxKind.TypeAssertion:
|
||||
return node === (<TypeAssertion>parent).type;
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
return (<CallExpression>parent).typeArguments && (<CallExpression>parent).typeArguments.indexOf(node) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this function only works when given a node with valid parent pointers.
|
||||
*
|
||||
* returns true if the given identifier is the name of a type declaration node (class, interface, enum, type parameter, etc)
|
||||
*/
|
||||
export function isTypeDeclarationName(name: Node): boolean {
|
||||
return name.kind == SyntaxKind.Identifier &&
|
||||
isTypeDeclaration(name.parent) &&
|
||||
(<Declaration>name.parent).name === name;
|
||||
}
|
||||
|
||||
|
||||
export function isTypeDeclaration(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export function getContainingFunction(node: Node): SignatureDeclaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
@@ -1065,7 +1159,7 @@ module ts {
|
||||
case ParsingContext.TypeParameters:
|
||||
return isIdentifier();
|
||||
case ParsingContext.ArgumentExpressions:
|
||||
return isExpression();
|
||||
return token === SyntaxKind.CommaToken || isExpression();
|
||||
case ParsingContext.ArrayLiteralMembers:
|
||||
return token === SyntaxKind.CommaToken || isExpression();
|
||||
case ParsingContext.Parameters:
|
||||
@@ -1218,18 +1312,6 @@ module ts {
|
||||
error(Diagnostics._0_expected, ",");
|
||||
}
|
||||
else if (isListTerminator(kind)) {
|
||||
// Check if the last token was a comma.
|
||||
if (commaStart >= 0) {
|
||||
if (!allowTrailingComma) {
|
||||
if (file.syntacticErrors.length === errorCountBeforeParsingList) {
|
||||
// Report a grammar error so we don't affect lookahead
|
||||
grammarErrorAtPos(commaStart, scanner.getStartPos() - commaStart, Diagnostics.Trailing_comma_not_allowed);
|
||||
}
|
||||
}
|
||||
// Always preserve a trailing comma by marking it on the NodeArray
|
||||
result.hasTrailingComma = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else {
|
||||
@@ -1240,6 +1322,23 @@ module ts {
|
||||
nextToken();
|
||||
}
|
||||
}
|
||||
|
||||
// Recording the trailing comma is deliberately done after the previous
|
||||
// loop, and not just if we see a list terminator. This is because the list
|
||||
// may have ended incorrectly, but it is still important to know if there
|
||||
// was a trailing comma.
|
||||
// Check if the last token was a comma.
|
||||
if (commaStart >= 0) {
|
||||
if (!allowTrailingComma) {
|
||||
if (file.syntacticErrors.length === errorCountBeforeParsingList) {
|
||||
// Report a grammar error so we don't affect lookahead
|
||||
grammarErrorAtPos(commaStart, scanner.getStartPos() - commaStart, Diagnostics.Trailing_comma_not_allowed);
|
||||
}
|
||||
}
|
||||
// Always preserve a trailing comma by marking it on the NodeArray
|
||||
result.hasTrailingComma = true;
|
||||
}
|
||||
|
||||
result.end = getNodeEnd();
|
||||
parsingContext = saveParsingContext;
|
||||
return result;
|
||||
@@ -2938,7 +3037,7 @@ module ts {
|
||||
parseExpected(SyntaxKind.ColonToken);
|
||||
|
||||
if (labelledStatementInfo.nodeIsNestedInLabel(node.label, /*requireIterationStatement*/ false, /*stopAtFunctionBoundary*/ true)) {
|
||||
grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getSourceTextOfNodeFromSourceText(sourceText, node.label));
|
||||
grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label));
|
||||
}
|
||||
labelledStatementInfo.addLabel(node.label);
|
||||
|
||||
@@ -3818,15 +3917,17 @@ module ts {
|
||||
}
|
||||
else {
|
||||
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
var start = range.pos;
|
||||
var end = range.end;
|
||||
var length = end - start;
|
||||
|
||||
if (!matchResult) {
|
||||
var start = range.pos;
|
||||
var length = range.end - start;
|
||||
errorAtPos(start, length, Diagnostics.Invalid_reference_directive_syntax);
|
||||
}
|
||||
else {
|
||||
referencedFiles.push({
|
||||
pos: range.pos,
|
||||
end: range.end,
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
});
|
||||
}
|
||||
@@ -3943,6 +4044,9 @@ module ts {
|
||||
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
}
|
||||
else if (refFile && host.getCanonicalFileName(filename) === host.getCanonicalFileName(refFile.filename)) {
|
||||
diagnostic = Diagnostics.A_file_cannot_have_a_reference_to_itself;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
||||
@@ -4001,7 +4105,8 @@ module ts {
|
||||
|
||||
function processReferencedFiles(file: SourceFile, basePath: string) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
processSourceFile(normalizePath(combinePaths(basePath, ref.filename)), /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
var referencedFilename = isRootedDiskPath(ref.filename) ? ref.filename : combinePaths(basePath, ref.filename);
|
||||
processSourceFile(normalizePath(referencedFilename), /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -655,6 +655,9 @@ module ts {
|
||||
// Returns the constant value of this enum member, or 'undefined' if the enum member has a
|
||||
// computed value.
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
|
||||
isValidPropertyAccess(node: PropertyAccess, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
}
|
||||
|
||||
export interface TextWriter {
|
||||
|
||||
+119
-88
@@ -412,6 +412,11 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private raiseError(message: string) {
|
||||
message = "Marker: " + currentTestState.lastKnownMarker + "\n" + message;
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
private getDiagnostics(fileName: string): ts.Diagnostic[] {
|
||||
var syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName);
|
||||
var semanticErrors = this.languageService.getSemanticDiagnostics(fileName);
|
||||
@@ -500,7 +505,7 @@ module FourSlash {
|
||||
this.printErrorLog(false, errors);
|
||||
var errorMsg = "Actual number of errors (" + actual + ") does not match expected number (" + expected + ")";
|
||||
Harness.IO.log(errorMsg);
|
||||
throw new Error(errorMsg);
|
||||
this.raiseError(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,7 +519,7 @@ module FourSlash {
|
||||
|
||||
var evaluation = new Function(emit.outputFiles[0].text + ';\r\nreturn (' + expr + ');')();
|
||||
if (evaluation !== value) {
|
||||
throw new Error('Expected evaluation of expression "' + expr + '" to equal "' + value + '", but got "' + evaluation + '"');
|
||||
this.raiseError('Expected evaluation of expression "' + expr + '" to equal "' + value + '", but got "' + evaluation + '"');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,7 +536,7 @@ module FourSlash {
|
||||
this.assertItemInCompletionList(members.entries, symbol, type, docComment, fullSymbolName, kind);
|
||||
}
|
||||
else {
|
||||
throw new Error("Expected a member list, but none was provided");
|
||||
this.raiseError("Expected a member list, but none was provided");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,11 +559,11 @@ module FourSlash {
|
||||
var match = members.entries.length === expectedCount;
|
||||
|
||||
if ((!match && !negative) || (match && negative)) {
|
||||
throw new Error("Member list count was " + members.entries.length + ". Expected " + expectedCount);
|
||||
this.raiseError("Member list count was " + members.entries.length + ". Expected " + expectedCount);
|
||||
}
|
||||
}
|
||||
else if (expectedCount) {
|
||||
throw new Error("Member list count was 0. Expected " + expectedCount);
|
||||
this.raiseError("Member list count was 0. Expected " + expectedCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,7 +573,7 @@ module FourSlash {
|
||||
|
||||
var members = this.getMemberListAtCaret();
|
||||
if (members.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
throw new Error('Member list did contain ' + symbol);
|
||||
this.raiseError('Member list did contain ' + symbol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +584,7 @@ module FourSlash {
|
||||
var itemsCount = completions.entries.length;
|
||||
|
||||
if (itemsCount <= count) {
|
||||
throw new Error('Expected completion list items count to be greater than ' + count + ', but is actually ' + itemsCount);
|
||||
this.raiseError('Expected completion list items count to be greater than ' + count + ', but is actually ' + itemsCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,7 +597,7 @@ module FourSlash {
|
||||
|
||||
var members = this.getMemberListAtCaret();
|
||||
if ((!members || members.entries.length === 0) && negative) {
|
||||
throw new Error("Member list is empty at Caret");
|
||||
this.raiseError("Member list is empty at Caret");
|
||||
} else if ((members && members.entries.length !== 0) && !negative) {
|
||||
|
||||
var errorMsg = "\n" + "Member List contains: [" + members.entries[0].name;
|
||||
@@ -602,7 +607,7 @@ module FourSlash {
|
||||
errorMsg += "]\n";
|
||||
|
||||
Harness.IO.log(errorMsg);
|
||||
throw new Error("Member list is not empty at Caret");
|
||||
this.raiseError("Member list is not empty at Caret");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -612,7 +617,7 @@ module FourSlash {
|
||||
|
||||
var completions = this.getCompletionListAtCaret();
|
||||
if ((!completions || completions.entries.length === 0) && negative) {
|
||||
throw new Error("Completion list is empty at Caret");
|
||||
this.raiseError("Completion list is empty at Caret");
|
||||
} else if ((completions && completions.entries.length !== 0) && !negative) {
|
||||
|
||||
var errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name;
|
||||
@@ -622,7 +627,7 @@ module FourSlash {
|
||||
errorMsg += "]\n";
|
||||
|
||||
Harness.IO.log(errorMsg);
|
||||
throw new Error("Completion list is not empty at Caret");
|
||||
this.raiseError("Completion list is not empty at Caret");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -638,7 +643,7 @@ module FourSlash {
|
||||
|
||||
var completions = this.getCompletionListAtCaret();
|
||||
if (completions && completions.entries && completions.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
throw new Error('Completion list did contain ' + symbol);
|
||||
this.raiseError('Completion list did contain ' + symbol);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,21 +673,21 @@ module FourSlash {
|
||||
var references = this.getReferencesAtCaret();
|
||||
|
||||
if (!references || references.length === 0) {
|
||||
throw new Error('verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.');
|
||||
this.raiseError('verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.');
|
||||
}
|
||||
|
||||
for (var i = 0; i < references.length; i++) {
|
||||
var reference = references[i];
|
||||
if (reference && reference.fileName === fileName && reference.textSpan.start() === start && reference.textSpan.end() === end) {
|
||||
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
|
||||
throw new Error('verifyReferencesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.');
|
||||
this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess };
|
||||
throw new Error('verifyReferencesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(references) + ')');
|
||||
this.raiseError('verifyReferencesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(references) + ')');
|
||||
}
|
||||
|
||||
public verifyReferencesCountIs(count: number, localFilesOnly: boolean = true) {
|
||||
@@ -706,7 +711,7 @@ module FourSlash {
|
||||
|
||||
if (referencesCount !== count) {
|
||||
var condition = localFilesOnly ? "excluding libs" : "including libs";
|
||||
throw new Error("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount);
|
||||
this.raiseError("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +734,7 @@ module FourSlash {
|
||||
|
||||
if (implementorsCount !== count) {
|
||||
var condition = localFilesOnly ? "excluding libs" : "including libs";
|
||||
throw new Error("Expected implementors count (" + condition + ") to be " + count + ", but is actually " + implementors.length);
|
||||
this.raiseError("Expected implementors count (" + condition + ") to be " + count + ", but is actually " + implementors.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,6 +758,10 @@ module FourSlash {
|
||||
return this.languageService.getImplementorsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private assertionMessage(name: string, actualValue: any, expectedValue: any) {
|
||||
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
|
||||
}
|
||||
|
||||
public verifyQuickInfo(negative: boolean, expectedTypeName?: string, docComment?: string, symbolName?: string, kind?: string) {
|
||||
[expectedTypeName, docComment, symbolName, kind].forEach(str => {
|
||||
if (str) {
|
||||
@@ -767,51 +776,79 @@ module FourSlash {
|
||||
var actualQuickInfoSymbolName = actualQuickInfo ? actualQuickInfo.fullSymbolName : "";
|
||||
var actualQuickInfoKind = actualQuickInfo ? actualQuickInfo.kind : "";
|
||||
|
||||
function assertionMessage(name: string, actualValue: string, expectedValue: string) {
|
||||
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
|
||||
}
|
||||
|
||||
if (negative) {
|
||||
if (expectedTypeName !== undefined) {
|
||||
assert.notEqual(actualQuickInfoMemberName, expectedTypeName, assertionMessage("quick info member name", actualQuickInfoMemberName, expectedTypeName));
|
||||
assert.notEqual(actualQuickInfoMemberName, expectedTypeName, this.assertionMessage("quick info member name", actualQuickInfoMemberName, expectedTypeName));
|
||||
}
|
||||
if (docComment != undefined) {
|
||||
assert.notEqual(actualQuickInfoDocComment, docComment, assertionMessage("quick info doc comment", actualQuickInfoDocComment, docComment));
|
||||
assert.notEqual(actualQuickInfoDocComment, docComment, this.assertionMessage("quick info doc comment", actualQuickInfoDocComment, docComment));
|
||||
}
|
||||
if (symbolName !== undefined) {
|
||||
assert.notEqual(actualQuickInfoSymbolName, symbolName, assertionMessage("quick info symbol name", actualQuickInfoSymbolName, symbolName));
|
||||
assert.notEqual(actualQuickInfoSymbolName, symbolName, this.assertionMessage("quick info symbol name", actualQuickInfoSymbolName, symbolName));
|
||||
}
|
||||
if (kind !== undefined) {
|
||||
assert.notEqual(actualQuickInfoKind, kind, assertionMessage("quick info kind", actualQuickInfoKind, kind));
|
||||
assert.notEqual(actualQuickInfoKind, kind, this.assertionMessage("quick info kind", actualQuickInfoKind, kind));
|
||||
}
|
||||
} else {
|
||||
if (expectedTypeName !== undefined) {
|
||||
assert.equal(actualQuickInfoMemberName, expectedTypeName, assertionMessage("quick info member", actualQuickInfoMemberName, expectedTypeName));
|
||||
assert.equal(actualQuickInfoMemberName, expectedTypeName, this.assertionMessage("quick info member", actualQuickInfoMemberName, expectedTypeName));
|
||||
}
|
||||
if (docComment != undefined) {
|
||||
assert.equal(actualQuickInfoDocComment, docComment, assertionMessage("quick info doc", actualQuickInfoDocComment, docComment));
|
||||
assert.equal(actualQuickInfoDocComment, docComment, this.assertionMessage("quick info doc", actualQuickInfoDocComment, docComment));
|
||||
}
|
||||
if (symbolName !== undefined) {
|
||||
assert.equal(actualQuickInfoSymbolName, symbolName, assertionMessage("quick info symbol name", actualQuickInfoSymbolName, symbolName));
|
||||
assert.equal(actualQuickInfoSymbolName, symbolName, this.assertionMessage("quick info symbol name", actualQuickInfoSymbolName, symbolName));
|
||||
}
|
||||
if (kind !== undefined) {
|
||||
assert.equal(actualQuickInfoKind, kind, assertionMessage("quick info kind", actualQuickInfoKind, kind));
|
||||
assert.equal(actualQuickInfoKind, kind, this.assertionMessage("quick info kind", actualQuickInfoKind, kind));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public verifyQuickInfoExists(negative: number) {
|
||||
public verifyRenameLocations(findInStrings: boolean, findInComments: boolean) {
|
||||
var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (renameInfo.canRename) {
|
||||
var references = this.languageService.findRenameLocations(
|
||||
this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments);
|
||||
|
||||
var ranges = this.getRanges();
|
||||
if (ranges.length !== references.length) {
|
||||
this.raiseError(this.assertionMessage("Rename locations", references.length, ranges.length));
|
||||
}
|
||||
|
||||
ranges = ranges.sort((r1, r2) => r1.start - r2.start);
|
||||
references = references.sort((r1, r2) => r1.textSpan.start() - r2.textSpan.start());
|
||||
|
||||
for (var i = 0, n = ranges.length; i < n; i++) {
|
||||
var reference = references[i];
|
||||
var range = ranges[i];
|
||||
|
||||
if (reference.textSpan.start() !== range.start ||
|
||||
reference.textSpan.end() !== range.end) {
|
||||
|
||||
this.raiseError(this.assertionMessage("Rename location",
|
||||
"[" + reference.textSpan.start() + "," + reference.textSpan.end() + ")",
|
||||
"[" + range.start + "," + range.end + ")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.raiseError("Expected rename to succeed, but it actually failed.");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyQuickInfoExists(negative: boolean) {
|
||||
this.taoInvalidReason = 'verifyQuickInfoExists NYI';
|
||||
|
||||
var actualQuickInfo = this.languageService.getTypeAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (negative) {
|
||||
if (actualQuickInfo) {
|
||||
throw new Error('verifyQuickInfoExists failed. Expected quick info NOT to exist');
|
||||
this.raiseError('verifyQuickInfoExists failed. Expected quick info NOT to exist');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!actualQuickInfo) {
|
||||
throw new Error('verifyQuickInfoExists failed. Expected quick info to exist');
|
||||
this.raiseError('verifyQuickInfoExists failed. Expected quick info to exist');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -886,31 +923,38 @@ module FourSlash {
|
||||
assert.equal(actual, expected);
|
||||
}
|
||||
|
||||
public verifySignatureHelpArgumentCount(expected: number) {
|
||||
this.taoInvalidReason = 'verifySignatureHelpArgumentCount NYI';
|
||||
var signatureHelpItems = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
|
||||
var actual = signatureHelpItems.argumentCount;
|
||||
assert.equal(actual, expected);
|
||||
}
|
||||
|
||||
public verifySignatureHelpPresent(shouldBePresent = true) {
|
||||
this.taoInvalidReason = 'verifySignatureHelpPresent NYI';
|
||||
|
||||
var actual = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (shouldBePresent) {
|
||||
if (!actual) {
|
||||
throw new Error("Expected signature help to be present, but it wasn't");
|
||||
this.raiseError("Expected signature help to be present, but it wasn't");
|
||||
}
|
||||
} else {
|
||||
if (actual) {
|
||||
throw new Error("Expected no signature help, but got '" + JSON.stringify(actual) + "'");
|
||||
this.raiseError("Expected no signature help, but got '" + JSON.stringify(actual) + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private validate(name: string, expected: string, actual: string) {
|
||||
if (expected && expected !== actual) {
|
||||
throw new Error("Expected " + name + " '" + expected + "'. Got '" + actual + "' instead.");
|
||||
this.raiseError("Expected " + name + " '" + expected + "'. Got '" + actual + "' instead.");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyRenameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string) {
|
||||
var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (!renameInfo.canRename) {
|
||||
throw new Error("Rename did not succeed");
|
||||
this.raiseError("Rename did not succeed");
|
||||
}
|
||||
|
||||
this.validate("displayName", displayName, renameInfo.displayName);
|
||||
@@ -919,13 +963,13 @@ module FourSlash {
|
||||
this.validate("kindModifiers", kindModifiers, renameInfo.kindModifiers);
|
||||
|
||||
if (this.getRanges().length !== 1) {
|
||||
throw new Error("Expected a single range to be selected in the test file.");
|
||||
this.raiseError("Expected a single range to be selected in the test file.");
|
||||
}
|
||||
|
||||
var expectedRange = this.getRanges()[0];
|
||||
if (renameInfo.triggerSpan.start() !== expectedRange.start ||
|
||||
renameInfo.triggerSpan.end() !== expectedRange.end) {
|
||||
throw new Error("Expected triggerSpan [" + expectedRange.start + "," + expectedRange.end + "). Got [" +
|
||||
this.raiseError("Expected triggerSpan [" + expectedRange.start + "," + expectedRange.end + "). Got [" +
|
||||
renameInfo.triggerSpan.start() + "," + renameInfo.triggerSpan.end() + ") instead.");
|
||||
}
|
||||
}
|
||||
@@ -933,35 +977,22 @@ module FourSlash {
|
||||
public verifyRenameInfoFailed(message?: string) {
|
||||
var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (renameInfo.canRename) {
|
||||
throw new Error("Rename was expected to fail");
|
||||
this.raiseError("Rename was expected to fail");
|
||||
}
|
||||
|
||||
this.validate("error", message, renameInfo.localizedErrorMessage);
|
||||
}
|
||||
|
||||
//private getFormalParameter() {
|
||||
// var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
|
||||
// return help.formal;
|
||||
//}
|
||||
|
||||
private getActiveSignatureHelpItem() {
|
||||
var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
|
||||
|
||||
// If the signature hasn't been narrowed down yet (e.g. no parameters have yet been entered),
|
||||
// 'activeFormal' will be -1 (even if there is only 1 signature). Signature help will show the
|
||||
// first signature in the signature group, so go with that
|
||||
var index = help.selectedItemIndex < 0 ? 0 : help.selectedItemIndex;
|
||||
|
||||
var index = help.selectedItemIndex;
|
||||
return help.items[index];
|
||||
}
|
||||
|
||||
private getActiveParameter(): ts.SignatureHelpParameter {
|
||||
var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
|
||||
|
||||
var item = help.items[help.selectedItemIndex];
|
||||
|
||||
// Same logic as in getActiveSignatureHelp - this value might be -1 until a parameter value actually gets typed
|
||||
var currentParam = help.argumentIndex < 0 ? 0 : help.argumentIndex;
|
||||
var currentParam = help.argumentIndex;
|
||||
return item.parameters[currentParam];
|
||||
}
|
||||
|
||||
@@ -1009,7 +1040,7 @@ module FourSlash {
|
||||
|
||||
// If there is not emiThisFile flag specified in the test file, throw an error
|
||||
if (emitFiles.length === 0) {
|
||||
throw new Error("No emitThisFile is specified in the test file");
|
||||
this.raiseError("No emitThisFile is specified in the test file");
|
||||
}
|
||||
|
||||
Harness.Baseline.runBaseline(
|
||||
@@ -1309,7 +1340,7 @@ module FourSlash {
|
||||
//var fullSyntaxErrs = JSON.stringify(refSyntaxTree.diagnostics());
|
||||
|
||||
//if (incrSyntaxErrs !== fullSyntaxErrs) {
|
||||
// throw new Error('Mismatched incremental/full syntactic errors for file ' + this.activeFile.fileName + '.\n=== Incremental errors ===\n' + incrSyntaxErrs + '\n=== Full Errors ===\n' + fullSyntaxErrs);
|
||||
// this.raiseError('Mismatched incremental/full syntactic errors for file ' + this.activeFile.fileName + '.\n=== Incremental errors ===\n' + incrSyntaxErrs + '\n=== Full Errors ===\n' + fullSyntaxErrs);
|
||||
//}
|
||||
|
||||
// if (this.editValidation !== IncrementalEditValidation.SyntacticOnly) {
|
||||
@@ -1326,7 +1357,7 @@ module FourSlash {
|
||||
// var incrSemanticErrs = JSON.stringify(this.languageService.getSemanticDiagnostics(this.testData.files[i].fileName));
|
||||
|
||||
// if (incrSemanticErrs !== refSemanticErrs) {
|
||||
// throw new Error('Mismatched incremental/full semantic errors for file ' + this.testData.files[i].fileName + '\n=== Incremental errors ===\n' + incrSemanticErrs + '\n=== Full Errors ===\n' + refSemanticErrs);
|
||||
// this.raiseError('Mismatched incremental/full semantic errors for file ' + this.testData.files[i].fileName + '\n=== Incremental errors ===\n' + incrSemanticErrs + '\n=== Full Errors ===\n' + refSemanticErrs);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1365,7 +1396,7 @@ module FourSlash {
|
||||
var newContent = snapshot.getText(0, snapshot.getLength());
|
||||
|
||||
if (newContent.replace(/\s/g, '') !== oldContent.replace(/\s/g, '')) {
|
||||
throw new Error('Formatting operation destroyed non-whitespace content');
|
||||
this.raiseError('Formatting operation destroyed non-whitespace content');
|
||||
}
|
||||
}
|
||||
return runningOffset;
|
||||
@@ -1422,11 +1453,11 @@ module FourSlash {
|
||||
|
||||
var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (!definitions || !definitions.length) {
|
||||
throw new Error('goToDefinition failed - expected to at least one definition location but got 0');
|
||||
this.raiseError('goToDefinition failed - expected to at least one definition location but got 0');
|
||||
}
|
||||
|
||||
if (definitionIndex >= definitions.length) {
|
||||
throw new Error('goToDefinition failed - definitionIndex value (' + definitionIndex + ') exceeds definition list size (' + definitions.length + ')');
|
||||
this.raiseError('goToDefinition failed - definitionIndex value (' + definitionIndex + ') exceeds definition list size (' + definitions.length + ')');
|
||||
}
|
||||
|
||||
var definition = definitions[definitionIndex];
|
||||
@@ -1442,10 +1473,10 @@ module FourSlash {
|
||||
var foundDefinitions = definitions && definitions.length;
|
||||
|
||||
if (foundDefinitions && negative) {
|
||||
throw new Error('goToDefinition - expected to 0 definition locations but got ' + definitions.length);
|
||||
this.raiseError('goToDefinition - expected to 0 definition locations but got ' + definitions.length);
|
||||
}
|
||||
else if (!foundDefinitions && !negative) {
|
||||
throw new Error('goToDefinition - expected to at least one definition location but got 0');
|
||||
this.raiseError('goToDefinition - expected to at least one definition location but got 0');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1480,7 +1511,7 @@ module FourSlash {
|
||||
|
||||
var actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (actual != numberOfSpaces) {
|
||||
throw new Error('verifyIndentationAtCurrentPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
this.raiseError('verifyIndentationAtCurrentPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1489,7 +1520,7 @@ module FourSlash {
|
||||
|
||||
var actual = this.getIndentation(fileName, position);
|
||||
if (actual !== numberOfSpaces) {
|
||||
throw new Error('verifyIndentationAtPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
this.raiseError('verifyIndentationAtPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1532,14 +1563,14 @@ module FourSlash {
|
||||
|
||||
var span = this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, this.currentCaretPosition, this.currentCaretPosition);
|
||||
if (span === null) {
|
||||
throw new Error('verifyCurrentNameOrDottedNameSpanText\n' +
|
||||
this.raiseError('verifyCurrentNameOrDottedNameSpanText\n' +
|
||||
'\tExpected: "' + text + '"\n' +
|
||||
'\t Actual: null');
|
||||
}
|
||||
|
||||
var actual = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getText(span.start(), span.end());
|
||||
if (actual !== text) {
|
||||
throw new Error('verifyCurrentNameOrDottedNameSpanText\n' +
|
||||
this.raiseError('verifyCurrentNameOrDottedNameSpanText\n' +
|
||||
'\tExpected: "' + text + '"\n' +
|
||||
'\t Actual: "' + actual + '"');
|
||||
}
|
||||
@@ -1577,7 +1608,7 @@ module FourSlash {
|
||||
|
||||
private verifyClassifications(expected: { classificationType: string; text: string }[], actual: ts.ClassifiedSpan[]) {
|
||||
if (actual.length !== expected.length) {
|
||||
throw new Error('verifySyntacticClassification failed - expected total classifications to be ' + expected.length + ', but was ' + actual.length);
|
||||
this.raiseError('verifyClassifications failed - expected total classifications to be ' + expected.length + ', but was ' + actual.length);
|
||||
}
|
||||
|
||||
for (var i = 0; i < expected.length; i++) {
|
||||
@@ -1586,7 +1617,7 @@ module FourSlash {
|
||||
|
||||
var expectedType: string = (<any>ts.ClassificationTypeNames)[expectedClassification.classificationType];
|
||||
if (expectedType !== actualClassification.classificationType) {
|
||||
throw new Error('verifySyntacticClassification failed - expected classifications type to be ' +
|
||||
this.raiseError('verifyClassifications failed - expected classifications type to be ' +
|
||||
expectedType + ', but was ' +
|
||||
actualClassification.classificationType);
|
||||
}
|
||||
@@ -1594,7 +1625,7 @@ module FourSlash {
|
||||
var actualSpan = actualClassification.textSpan;
|
||||
var actualText = this.activeFile.content.substr(actualSpan.start(), actualSpan.length());
|
||||
if (expectedClassification.text !== actualText) {
|
||||
throw new Error('verifySyntacticClassification failed - expected classificatied text to be ' +
|
||||
this.raiseError('verifyClassifications failed - expected classificatied text to be ' +
|
||||
expectedClassification.text + ', but was ' +
|
||||
actualText);
|
||||
}
|
||||
@@ -1621,14 +1652,14 @@ module FourSlash {
|
||||
var actual = this.languageService.getOutliningSpans(this.activeFile.fileName);
|
||||
|
||||
if (actual.length !== spans.length) {
|
||||
throw new Error('verifyOutliningSpans failed - expected total spans to be ' + spans.length + ', but was ' + actual.length);
|
||||
this.raiseError('verifyOutliningSpans failed - expected total spans to be ' + spans.length + ', but was ' + actual.length);
|
||||
}
|
||||
|
||||
for (var i = 0; i < spans.length; i++) {
|
||||
var expectedSpan = spans[i];
|
||||
var actualSpan = actual[i];
|
||||
if (expectedSpan.start !== actualSpan.textSpan.start() || expectedSpan.end !== actualSpan.textSpan.end()) {
|
||||
throw new Error('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualSpan.textSpan.start() + ',' + actualSpan.textSpan.end() + ')');
|
||||
this.raiseError('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualSpan.textSpan.start() + ',' + actualSpan.textSpan.end() + ')');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1638,7 +1669,7 @@ module FourSlash {
|
||||
descriptors.map(d => { return { text: d, priority: 0 }; }));
|
||||
|
||||
if (actual.length !== spans.length) {
|
||||
throw new Error('verifyTodoComments failed - expected total spans to be ' + spans.length + ', but was ' + actual.length);
|
||||
this.raiseError('verifyTodoComments failed - expected total spans to be ' + spans.length + ', but was ' + actual.length);
|
||||
}
|
||||
|
||||
for (var i = 0; i < spans.length; i++) {
|
||||
@@ -1647,7 +1678,7 @@ module FourSlash {
|
||||
var actualCommentSpan = new TypeScript.TextSpan(actualComment.position, actualComment.message.length);
|
||||
|
||||
if (expectedSpan.start !== actualCommentSpan.start() || expectedSpan.end !== actualCommentSpan.end()) {
|
||||
throw new Error('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualCommentSpan.start() + ',' + actualCommentSpan.end() + ')');
|
||||
this.raiseError('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualCommentSpan.start() + ',' + actualCommentSpan.end() + ')');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1658,7 +1689,7 @@ module FourSlash {
|
||||
var actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition);
|
||||
|
||||
if (actual.length !== 2) {
|
||||
throw new Error('verifyMatchingBracePosition failed - expected result to contain 2 spans, but it had ' + actual.length);
|
||||
this.raiseError('verifyMatchingBracePosition failed - expected result to contain 2 spans, but it had ' + actual.length);
|
||||
}
|
||||
|
||||
var actualMatchPosition = -1;
|
||||
@@ -1667,11 +1698,11 @@ module FourSlash {
|
||||
} else if (bracePosition === actual[1].start()) {
|
||||
actualMatchPosition = actual[0].start();
|
||||
} else {
|
||||
throw new Error('verifyMatchingBracePosition failed - could not find the brace position: ' + bracePosition + ' in the returned list: (' + actual[0].start() + ',' + actual[0].end() + ') and (' + actual[1].start() + ',' + actual[1].end() + ')');
|
||||
this.raiseError('verifyMatchingBracePosition failed - could not find the brace position: ' + bracePosition + ' in the returned list: (' + actual[0].start() + ',' + actual[0].end() + ') and (' + actual[1].start() + ',' + actual[1].end() + ')');
|
||||
}
|
||||
|
||||
if (actualMatchPosition !== expectedMatchPosition) {
|
||||
throw new Error('verifyMatchingBracePosition failed - expected: ' + actualMatchPosition + ', actual: ' + expectedMatchPosition);
|
||||
this.raiseError('verifyMatchingBracePosition failed - expected: ' + actualMatchPosition + ', actual: ' + expectedMatchPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1681,7 +1712,7 @@ module FourSlash {
|
||||
var actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition);
|
||||
|
||||
if (actual.length !== 0) {
|
||||
throw new Error('verifyNoMatchingBracePosition failed - expected: 0 spans, actual: ' + actual.length);
|
||||
this.raiseError('verifyNoMatchingBracePosition failed - expected: 0 spans, actual: ' + actual.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1768,7 +1799,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
if (expected != actual) {
|
||||
throw new Error('verifyNavigationItemsCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
|
||||
this.raiseError('verifyNavigationItemsCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1788,7 +1819,7 @@ module FourSlash {
|
||||
var items = this.languageService.getNavigateToItems(searchValue);
|
||||
|
||||
if (!items || items.length === 0) {
|
||||
throw new Error('verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one.');
|
||||
this.raiseError('verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one.');
|
||||
}
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
@@ -1804,7 +1835,7 @@ module FourSlash {
|
||||
// if there was an explicit match kind specified, then it should be validated.
|
||||
if (matchKind !== undefined) {
|
||||
var missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName };
|
||||
throw new Error('verifyNavigationItemsListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')');
|
||||
this.raiseError('verifyNavigationItemsListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1815,7 +1846,7 @@ module FourSlash {
|
||||
var actual = this.getNavigationBarItemsCount(items);
|
||||
|
||||
if (expected != actual) {
|
||||
throw new Error('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
|
||||
this.raiseError('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1840,7 +1871,7 @@ module FourSlash {
|
||||
var items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
|
||||
if (!items || items.length === 0) {
|
||||
throw new Error('verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one.');
|
||||
this.raiseError('verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one.');
|
||||
}
|
||||
|
||||
if (this.navigationBarItemsContains(items, name, kind)) {
|
||||
@@ -1848,7 +1879,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
var missingItem = { name: name, kind: kind };
|
||||
throw new Error('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')');
|
||||
this.raiseError('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')');
|
||||
}
|
||||
|
||||
private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) {
|
||||
@@ -1902,21 +1933,21 @@ module FourSlash {
|
||||
var occurances = this.getOccurancesAtCurrentPosition();
|
||||
|
||||
if (!occurances || occurances.length === 0) {
|
||||
throw new Error('verifyOccurancesAtPositionListContains failed - found 0 references, expected at least one.');
|
||||
this.raiseError('verifyOccurancesAtPositionListContains failed - found 0 references, expected at least one.');
|
||||
}
|
||||
|
||||
for (var i = 0; i < occurances.length; i++) {
|
||||
var occurance = occurances[i];
|
||||
if (occurance && occurance.fileName === fileName && occurance.textSpan.start() === start && occurance.textSpan.end() === end) {
|
||||
if (typeof isWriteAccess !== "undefined" && occurance.isWriteAccess !== isWriteAccess) {
|
||||
throw new Error('verifyOccurancesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + occurance.isWriteAccess + ', expected: ' + isWriteAccess + '.');
|
||||
this.raiseError('verifyOccurancesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + occurance.isWriteAccess + ', expected: ' + isWriteAccess + '.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess };
|
||||
throw new Error('verifyOccurancesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(occurances) + ')');
|
||||
this.raiseError('verifyOccurancesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(occurances) + ')');
|
||||
}
|
||||
|
||||
public verifyOccurrencesAtPositionListCount(expectedCount: number) {
|
||||
@@ -1925,7 +1956,7 @@ module FourSlash {
|
||||
var occurances = this.getOccurancesAtCurrentPosition();
|
||||
var actualCount = occurances ? occurances.length : 0;
|
||||
if (expectedCount !== actualCount) {
|
||||
throw new Error('verifyOccurrencesAtPositionListCount failed - actual: ' + actualCount + ', expected:' + expectedCount);
|
||||
this.raiseError('verifyOccurrencesAtPositionListCount failed - actual: ' + actualCount + ', expected:' + expectedCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2010,7 +2041,7 @@ module FourSlash {
|
||||
|
||||
var itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n");
|
||||
|
||||
throw new Error("Marker: " + currentTestState.lastKnownMarker + "\n" + 'Expected "' + JSON.stringify({ name: name, type: type, docComment: docComment, fullSymbolName: fullSymbolName, kind: kind }) + '" to be in list [' + itemsString + ']');
|
||||
this.raiseError('Expected "' + JSON.stringify({ name: name, type: type, docComment: docComment, fullSymbolName: fullSymbolName, kind: kind }) + '" to be in list [' + itemsString + ']');
|
||||
}
|
||||
|
||||
private findFile(indexOrName: any) {
|
||||
|
||||
@@ -76,7 +76,7 @@ class TypeWriterWalker {
|
||||
private log(node: ts.Node, type: ts.Type): void {
|
||||
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterFromPosition(actualPos);
|
||||
var sourceText = ts.getSourceTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
|
||||
// If we got an unknown type, we temporarily want to fall back to just pretending the name
|
||||
// (source text) of the node is the type. This is to align with the old typeWriter to make
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export var LocalizedDiagnosticMessages: ts.Map<any> = null;
|
||||
|
||||
export class Location {
|
||||
private _fileName: string;
|
||||
private _lineMap: LineMap;
|
||||
|
||||
@@ -166,26 +166,26 @@ module ts.NavigationBar {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return createItem(node, getSourceText(parameter.name), ts.ScriptElementKind.memberVariableElement);
|
||||
return createItem(node, getTextOfNode(parameter.name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.Method:
|
||||
var method = <MethodDeclaration>node;
|
||||
return createItem(node, getSourceText(method.name), ts.ScriptElementKind.memberFunctionElement);
|
||||
return createItem(node, getTextOfNode(method.name), ts.ScriptElementKind.memberFunctionElement);
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
var getAccessor = <AccessorDeclaration>node;
|
||||
return createItem(node, getSourceText(getAccessor.name), ts.ScriptElementKind.memberGetAccessorElement);
|
||||
return createItem(node, getTextOfNode(getAccessor.name), ts.ScriptElementKind.memberGetAccessorElement);
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
var setAccessor = <AccessorDeclaration>node;
|
||||
return createItem(node, getSourceText(setAccessor.name), ts.ScriptElementKind.memberSetAccessorElement);
|
||||
return createItem(node, getTextOfNode(setAccessor.name), ts.ScriptElementKind.memberSetAccessorElement);
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement);
|
||||
|
||||
case SyntaxKind.EnumMember:
|
||||
var enumMember = <EnumMember>node;
|
||||
return createItem(node, getSourceText(enumMember.name), ts.ScriptElementKind.memberVariableElement);
|
||||
return createItem(node, getTextOfNode(enumMember.name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
return createItem(node, "()", ts.ScriptElementKind.callSignatureElement);
|
||||
@@ -195,18 +195,18 @@ module ts.NavigationBar {
|
||||
|
||||
case SyntaxKind.Property:
|
||||
var property = <PropertyDeclaration>node;
|
||||
return createItem(node, getSourceText(property.name), ts.ScriptElementKind.memberVariableElement);
|
||||
return createItem(node, getTextOfNode(property.name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionDeclaration>node;
|
||||
if (!isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
return createItem(node, getSourceText(functionDeclaration.name), ts.ScriptElementKind.functionElement);
|
||||
return createItem(node, getTextOfNode(functionDeclaration.name), ts.ScriptElementKind.functionElement);
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
var variableDeclaration = <VariableDeclaration>node;
|
||||
return createItem(node, getSourceText(variableDeclaration.name), ts.ScriptElementKind.variableElement);
|
||||
return createItem(node, getTextOfNode(variableDeclaration.name), ts.ScriptElementKind.variableElement);
|
||||
|
||||
case SyntaxKind.Constructor:
|
||||
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
|
||||
@@ -258,7 +258,7 @@ module ts.NavigationBar {
|
||||
function getModuleName(moduleDeclaration: ModuleDeclaration): string {
|
||||
// We want to maintain quotation marks.
|
||||
if (moduleDeclaration.name.kind === SyntaxKind.StringLiteral) {
|
||||
return getSourceText(moduleDeclaration.name);
|
||||
return getTextOfNode(moduleDeclaration.name);
|
||||
}
|
||||
|
||||
// Otherwise, we need to aggregate each identifier to build up the qualified name.
|
||||
@@ -382,8 +382,8 @@ module ts.NavigationBar {
|
||||
return TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd());
|
||||
}
|
||||
|
||||
function getSourceText(node: Node): string {
|
||||
return getSourceTextOfNodeFromSourceText(sourceFile.text, node);
|
||||
function getTextOfNode(node: Node): string {
|
||||
return getTextOfNodeFromSourceText(sourceFile.text, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,18 +34,30 @@ module ts {
|
||||
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
|
||||
var elements: OutliningSpan[] = [];
|
||||
|
||||
function addOutlineRange(hintSpanNode: Node, startElement: Node, endElement: Node) {
|
||||
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
|
||||
if (hintSpanNode && startElement && endElement) {
|
||||
var span: OutliningSpan = {
|
||||
textSpan: TypeScript.TextSpan.fromBounds(startElement.pos, endElement.end),
|
||||
hintSpan: TypeScript.TextSpan.fromBounds(hintSpanNode.getStart(), hintSpanNode.end),
|
||||
bannerText: "...",
|
||||
autoCollapse: false
|
||||
autoCollapse: autoCollapse
|
||||
};
|
||||
elements.push(span);
|
||||
}
|
||||
}
|
||||
|
||||
function autoCollapse(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var depth = 0;
|
||||
var maxDepth = 20;
|
||||
function walk(n: Node): void {
|
||||
@@ -62,7 +74,7 @@ module ts {
|
||||
case SyntaxKind.FinallyBlock:
|
||||
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutlineRange(n.parent, openBrace, closeBrace);
|
||||
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
@@ -71,12 +83,12 @@ module ts {
|
||||
case SyntaxKind.SwitchStatement:
|
||||
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutlineRange(n, openBrace, closeBrace);
|
||||
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
case SyntaxKind.ArrayLiteral:
|
||||
var openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
|
||||
var closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||
addOutlineRange(n, openBracket, closeBracket);
|
||||
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
depth++;
|
||||
|
||||
+361
-59
@@ -256,7 +256,7 @@ module ts {
|
||||
var declarations = this.getDeclarations();
|
||||
if (declarations) {
|
||||
for (var i = 0, n = declarations.length; i < n; i++) {
|
||||
this.processDocumentationCommentDeclaration(lines, declarations[0]);
|
||||
this.processDocumentationCommentDeclaration(lines, declarations[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ module ts {
|
||||
|
||||
for (var i = 0, n = commentRanges.length; i < n; i++) {
|
||||
this.processDocumentationCommentRange(
|
||||
lines, sourceFile, commentRanges[0]);
|
||||
lines, sourceFile, commentRanges[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -666,6 +666,8 @@ module ts {
|
||||
getSignatureAtPosition(fileName: string, position: number): SignatureInfo;
|
||||
|
||||
getRenameInfo(fileName: string, position: number): RenameInfo;
|
||||
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
|
||||
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
@@ -757,6 +759,11 @@ module ts {
|
||||
newText: string;
|
||||
}
|
||||
|
||||
export interface RenameLocation {
|
||||
textSpan: TypeScript.TextSpan;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
export interface ReferenceEntry {
|
||||
textSpan: TypeScript.TextSpan;
|
||||
fileName: string;
|
||||
@@ -1025,6 +1032,8 @@ module ts {
|
||||
static primitiveType = "primitive type";
|
||||
|
||||
static label = "label";
|
||||
|
||||
static alias = "alias"
|
||||
}
|
||||
|
||||
export class ScriptElementKindModifier {
|
||||
@@ -1662,8 +1671,8 @@ module ts {
|
||||
var writer: (filename: string, data: string, writeByteOrderMark: boolean) => void = undefined;
|
||||
|
||||
// Check if the localized messages json is set, otherwise query the host for it
|
||||
if (!TypeScript.LocalizedDiagnosticMessages) {
|
||||
TypeScript.LocalizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
|
||||
if (!localizedDiagnosticMessages) {
|
||||
localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string): SourceFile {
|
||||
@@ -2052,15 +2061,6 @@ module ts {
|
||||
return (SyntaxKind.FirstPunctuation <= kind && kind <= SyntaxKind.LastPunctuation);
|
||||
}
|
||||
|
||||
function isVisibleWithinClassDeclaration(symbol: Symbol, containingClass: Declaration): boolean {
|
||||
var declaration = symbol.declarations && symbol.declarations[0];
|
||||
if (declaration && (declaration.flags & NodeFlags.Private)) {
|
||||
var declarationClass = getAncestor(declaration, SyntaxKind.ClassDeclaration);
|
||||
return containingClass === declarationClass;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function filterContextualMembersList(contextualMemberSymbols: Symbol[], existingMembers: Declaration[]): Symbol[] {
|
||||
if (!existingMembers || existingMembers.length === 0) {
|
||||
return contextualMemberSymbols;
|
||||
@@ -2144,7 +2144,7 @@ module ts {
|
||||
}
|
||||
|
||||
// TODO: this is a hack for now, we need a proper walking mechanism to verify that we have the correct node
|
||||
var mappedNode = getNodeAtPosition(sourceFile, TypeScript.end(node) - 1);
|
||||
var mappedNode = getTouchingToken(sourceFile, TypeScript.end(node) - 1);
|
||||
if (isPunctuation(mappedNode.kind)) {
|
||||
mappedNode = mappedNode.parent;
|
||||
}
|
||||
@@ -2164,15 +2164,20 @@ module ts {
|
||||
// Right of dot member completion list
|
||||
if (isRightOfDot) {
|
||||
var symbols: Symbol[] = [];
|
||||
var containingClass = getAncestor(mappedNode, SyntaxKind.ClassDeclaration);
|
||||
isMemberCompletion = true;
|
||||
|
||||
if (mappedNode.kind === SyntaxKind.Identifier || mappedNode.kind === SyntaxKind.QualifiedName || mappedNode.kind === SyntaxKind.PropertyAccess) {
|
||||
var symbol = typeInfoResolver.getSymbolInfo(mappedNode);
|
||||
|
||||
// This is an alias, follow what it aliases
|
||||
if (symbol && symbol.flags & SymbolFlags.Import) {
|
||||
symbol = typeInfoResolver.getAliasedSymbol(symbol);
|
||||
}
|
||||
|
||||
if (symbol && symbol.flags & SymbolFlags.HasExports) {
|
||||
// Extract module or enum members
|
||||
forEachValue(symbol.exports, symbol => {
|
||||
if (isVisibleWithinClassDeclaration(symbol, containingClass)) {
|
||||
if (typeInfoResolver.isValidPropertyAccess(<PropertyAccess>(mappedNode.parent), symbol.name)) {
|
||||
symbols.push(symbol);
|
||||
}
|
||||
});
|
||||
@@ -2184,7 +2189,7 @@ module ts {
|
||||
if (apparentType) {
|
||||
// Filter private properties
|
||||
forEach(apparentType.getApparentProperties(), symbol => {
|
||||
if (isVisibleWithinClassDeclaration(symbol, containingClass)) {
|
||||
if (typeInfoResolver.isValidPropertyAccess(<PropertyAccess>(mappedNode.parent), symbol.name)) {
|
||||
symbols.push(symbol);
|
||||
}
|
||||
});
|
||||
@@ -2219,7 +2224,7 @@ module ts {
|
||||
else {
|
||||
isMemberCompletion = false;
|
||||
/// TODO filter meaning based on the current context
|
||||
var symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace;
|
||||
var symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Import;
|
||||
var symbols = typeInfoResolver.getSymbolsInScope(mappedNode, symbolMeanings);
|
||||
|
||||
getCompletionEntriesFromSymbols(symbols, activeCompletionSession);
|
||||
@@ -2317,6 +2322,7 @@ module ts {
|
||||
if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement;
|
||||
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
|
||||
if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement;
|
||||
if (flags & SymbolFlags.Import) return ScriptElementKind.alias;
|
||||
|
||||
return ScriptElementKind.unknown;
|
||||
}
|
||||
@@ -2368,7 +2374,7 @@ module ts {
|
||||
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2476,7 +2482,7 @@ module ts {
|
||||
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2559,7 +2565,7 @@ module ts {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2574,7 +2580,8 @@ module ts {
|
||||
/// Triple slash reference comments
|
||||
var comment = forEach(sourceFile.referencedFiles, r => (r.pos <= position && position < r.end) ? r : undefined);
|
||||
if (comment) {
|
||||
var targetFilename = normalizePath(combinePaths(getDirectoryPath(filename), comment.filename));
|
||||
var targetFilename = isRootedDiskPath(comment.filename) ? comment.filename : combinePaths(getDirectoryPath(filename), comment.filename);
|
||||
targetFilename = normalizePath(targetFilename);
|
||||
if (program.getSourceFile(targetFilename)) {
|
||||
return [{
|
||||
fileName: targetFilename,
|
||||
@@ -2623,7 +2630,7 @@ module ts {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2645,6 +2652,11 @@ module ts {
|
||||
return getReturnOccurrences(<ReturnStatement>node.parent);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ThrowKeyword:
|
||||
if (hasKind(node.parent, SyntaxKind.ThrowStatement)) {
|
||||
return getThrowOccurrences(<ThrowStatement>node.parent);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.TryKeyword:
|
||||
case SyntaxKind.CatchKeyword:
|
||||
case SyntaxKind.FinallyKeyword:
|
||||
@@ -2685,6 +2697,11 @@ module ts {
|
||||
return getConstructorOccurrences(<ConstructorDeclaration>node.parent);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) {
|
||||
return getGetAndSetOccurrences(<AccessorDeclaration>node.parent);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -2762,12 +2779,108 @@ module ts {
|
||||
}
|
||||
|
||||
var keywords: Node[] = []
|
||||
forEachReturnStatement(<Block>(<FunctionDeclaration>func).body, returnStatement => {
|
||||
forEachReturnStatement(<Block>func.body, returnStatement => {
|
||||
pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword);
|
||||
});
|
||||
|
||||
// Include 'throw' statements that do not occur within a try block.
|
||||
forEach(aggregateOwnedThrowStatements(func.body), throwStatement => {
|
||||
pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword);
|
||||
});
|
||||
|
||||
return map(keywords, getReferenceEntryFromNode);
|
||||
}
|
||||
|
||||
function getThrowOccurrences(throwStatement: ThrowStatement) {
|
||||
var owner = getThrowStatementOwner(throwStatement);
|
||||
|
||||
if (!owner) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var keywords: Node[] = [];
|
||||
|
||||
forEach(aggregateOwnedThrowStatements(owner), throwStatement => {
|
||||
pushKeywordIf(keywords, throwStatement.getFirstToken(), SyntaxKind.ThrowKeyword);
|
||||
});
|
||||
|
||||
// If the "owner" is a function, then we equate 'return' and 'throw' statements in their
|
||||
// ability to "jump out" of the function, and include occurrences for both.
|
||||
if (owner.kind === SyntaxKind.FunctionBlock) {
|
||||
forEachReturnStatement(<Block>owner, returnStatement => {
|
||||
pushKeywordIf(keywords, returnStatement.getFirstToken(), SyntaxKind.ReturnKeyword);
|
||||
});
|
||||
}
|
||||
|
||||
return map(keywords, getReferenceEntryFromNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregates all throw-statements within this node *without* crossing
|
||||
* into function boundaries and try-blocks with catch-clauses.
|
||||
*/
|
||||
function aggregateOwnedThrowStatements(node: Node): ThrowStatement[] {
|
||||
var statementAccumulator: ThrowStatement[] = []
|
||||
aggregate(node);
|
||||
return statementAccumulator;
|
||||
|
||||
function aggregate(node: Node): void {
|
||||
if (node.kind === SyntaxKind.ThrowStatement) {
|
||||
statementAccumulator.push(<ThrowStatement>node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.TryStatement) {
|
||||
var tryStatement = <TryStatement>node;
|
||||
|
||||
if (tryStatement.catchBlock) {
|
||||
aggregate(tryStatement.catchBlock);
|
||||
}
|
||||
else {
|
||||
// Exceptions thrown within a try block lacking a catch clause
|
||||
// are "owned" in the current context.
|
||||
aggregate(tryStatement.tryBlock);
|
||||
}
|
||||
|
||||
if (tryStatement.finallyBlock) {
|
||||
aggregate(tryStatement.finallyBlock);
|
||||
}
|
||||
}
|
||||
// Do not cross function boundaries.
|
||||
else if (!isAnyFunction(node)) {
|
||||
forEachChild(node, aggregate);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* For lack of a better name, this function takes a throw statement and returns the
|
||||
* nearest ancestor that is a try-block (whose try statement has a catch clause),
|
||||
* function-block, or source file.
|
||||
*/
|
||||
function getThrowStatementOwner(throwStatement: ThrowStatement): Node {
|
||||
var child: Node = throwStatement;
|
||||
|
||||
while (child.parent) {
|
||||
var parent = child.parent;
|
||||
|
||||
if (parent.kind === SyntaxKind.FunctionBlock || parent.kind === SyntaxKind.SourceFile) {
|
||||
return parent;
|
||||
}
|
||||
|
||||
// A throw-statement is only owned by a try-statement if the try-statement has
|
||||
// a catch clause, and if the throw-statement occurs within the try block.
|
||||
if (parent.kind === SyntaxKind.TryStatement) {
|
||||
var tryStatement = <TryStatement>parent;
|
||||
|
||||
if (tryStatement.tryBlock === child && tryStatement.catchBlock) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
child = parent;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getTryCatchFinallyOccurrences(tryStatement: TryStatement): ReferenceEntry[] {
|
||||
var keywords: Node[] = [];
|
||||
@@ -2919,6 +3032,23 @@ module ts {
|
||||
return map(keywords, getReferenceEntryFromNode);
|
||||
}
|
||||
|
||||
function getGetAndSetOccurrences(accessorDeclaration: AccessorDeclaration): ReferenceEntry[] {
|
||||
var keywords: Node[] = [];
|
||||
|
||||
tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.GetAccessor);
|
||||
tryPushAccessorKeyword(accessorDeclaration.symbol, SyntaxKind.SetAccessor);
|
||||
|
||||
return map(keywords, getReferenceEntryFromNode);
|
||||
|
||||
function tryPushAccessorKeyword(accessorSymbol: Symbol, accessorKind: SyntaxKind): void {
|
||||
var accessor = getDeclarationOfKind(accessorSymbol, accessorKind);
|
||||
|
||||
if (accessor) {
|
||||
forEach(accessor.getChildren(), child => pushKeywordIf(keywords, child, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if 'node' is defined and has a matching 'kind'.
|
||||
function hasKind(node: Node, kind: SyntaxKind) {
|
||||
return node !== undefined && node.kind === kind;
|
||||
@@ -2939,13 +3069,21 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getReferencesAtPosition(filename: string, position: number): ReferenceEntry[] {
|
||||
function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] {
|
||||
return findReferences(fileName, position, findInStrings, findInComments);
|
||||
}
|
||||
|
||||
function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
return findReferences(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
}
|
||||
|
||||
function findReferences(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2959,7 +3097,88 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return getReferencesForNode(node, program.getSourceFiles());
|
||||
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral);
|
||||
var references = getReferencesForNode(node, program.getSourceFiles());
|
||||
|
||||
var name = (<Identifier>node).text;
|
||||
var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*</
|
||||
|
||||
if (findInStrings) {
|
||||
forEach(program.getSourceFiles(), addStringReferences);
|
||||
}
|
||||
|
||||
if (findInComments) {
|
||||
forEach(program.getSourceFiles(), addCommentReferences);
|
||||
}
|
||||
|
||||
return references;
|
||||
|
||||
function addReferencesInRawText(rawText: string, rawTextPositionInSourceText: number, sourceText: string) {
|
||||
var matchIndex = 0;
|
||||
while ((matchIndex = rawText.indexOf(name, matchIndex)) >= 0) {
|
||||
// Only consider it a match if there isn't a letter/number before or after
|
||||
// the match.
|
||||
var indexInSourceText = rawTextPositionInSourceText + matchIndex;
|
||||
|
||||
if (indexInSourceText === 0 || !isIdentifierPart(sourceText.charCodeAt(indexInSourceText - 1), ScriptTarget.ES5)) {
|
||||
var matchEnd = indexInSourceText + name.length;
|
||||
if (matchEnd >= sourceText.length || !isIdentifierPart(sourceText.charCodeAt(matchEnd), ScriptTarget.ES5)) {
|
||||
|
||||
references.push({
|
||||
fileName: sourceFile.filename,
|
||||
textSpan: new TypeScript.TextSpan(indexInSourceText, name.length),
|
||||
isWriteAccess: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Advance the matchIndex forward (if we don't, then we'll simply find the same
|
||||
// match at the same position again).
|
||||
matchIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
function addCommentReferences(sourceFile: SourceFile) {
|
||||
var sourceText = sourceFile.text;
|
||||
forEachChild(sourceFile, addCommentReferencesInNode);
|
||||
|
||||
function addCommentReferencesInNode(node: Node) {
|
||||
if (isToken(node)) {
|
||||
// Found a token, walk its comments (if it has any) for matches).
|
||||
forEach(getLeadingCommentRanges(sourceText, node.pos), addReferencesInCommentRange);
|
||||
}
|
||||
else {
|
||||
forEach(node.getChildren(), addCommentReferencesInNode);
|
||||
}
|
||||
}
|
||||
|
||||
function addReferencesInCommentRange(range: CommentRange) {
|
||||
var commentText = sourceText.substring(range.pos, range.end);
|
||||
|
||||
// Don't add matches in ///<reference comments. We don't want to
|
||||
// unintentionally update a file name.
|
||||
if (!tripleSlashDirectivePrefixRegex.test(commentText)) {
|
||||
addReferencesInRawText(commentText, range.pos, sourceText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addStringReferences(sourceFile: SourceFile) {
|
||||
var sourceText = sourceFile.text;
|
||||
|
||||
forEachChild(sourceFile, addStringReferencesInNode);
|
||||
|
||||
function addStringReferencesInNode(node: Node) {
|
||||
if (node.kind === SyntaxKind.StringLiteral) {
|
||||
// Found a string literal. See if we can find any matches in it.
|
||||
addReferencesInRawText(getTextOfNodeFromSourceText(sourceText, node), node.getStart(sourceFile), sourceText);
|
||||
}
|
||||
else {
|
||||
// Recurse and keep looking for references in strings.
|
||||
forEachChild(node, addStringReferencesInNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getReferencesForNode(node: Node, sourceFiles: SourceFile[]): ReferenceEntry[] {
|
||||
@@ -3128,7 +3347,7 @@ module ts {
|
||||
forEach(possiblePositions, position => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
if (!node || node.getWidth() !== labelName.length) {
|
||||
return;
|
||||
}
|
||||
@@ -3184,7 +3403,7 @@ module ts {
|
||||
forEach(possiblePositions, position => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var referenceLocation = getNodeAtPosition(sourceFile, position);
|
||||
var referenceLocation = getTouchingPropertyName(sourceFile, position);
|
||||
if (!isValidReferencePosition(referenceLocation, searchText)) {
|
||||
return;
|
||||
}
|
||||
@@ -3236,7 +3455,7 @@ module ts {
|
||||
forEach(possiblePositions, position => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
|
||||
if (!node || node.kind !== SyntaxKind.SuperKeyword) {
|
||||
return;
|
||||
@@ -3302,7 +3521,7 @@ module ts {
|
||||
forEach(possiblePositions, position => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
if (!node || node.kind !== SyntaxKind.ThisKeyword) {
|
||||
return;
|
||||
}
|
||||
@@ -3921,7 +4140,7 @@ module ts {
|
||||
|
||||
return result;
|
||||
|
||||
function classifySymbol(symbol: Symbol) {
|
||||
function classifySymbol(symbol: Symbol, isInTypePosition: boolean) {
|
||||
var flags = symbol.getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Class) {
|
||||
@@ -3930,14 +4149,16 @@ module ts {
|
||||
else if (flags & SymbolFlags.Enum) {
|
||||
return ClassificationTypeNames.enumName;
|
||||
}
|
||||
else if (flags & SymbolFlags.Interface) {
|
||||
return ClassificationTypeNames.interfaceName;
|
||||
}
|
||||
else if (flags & SymbolFlags.Module) {
|
||||
return ClassificationTypeNames.moduleName;
|
||||
}
|
||||
else if (flags & SymbolFlags.TypeParameter) {
|
||||
return ClassificationTypeNames.typeParameterName;
|
||||
else if (isInTypePosition) {
|
||||
if (flags & SymbolFlags.Interface) {
|
||||
return ClassificationTypeNames.interfaceName;
|
||||
}
|
||||
else if (flags & SymbolFlags.TypeParameter) {
|
||||
return ClassificationTypeNames.typeParameterName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3947,7 +4168,7 @@ module ts {
|
||||
if (node.kind === SyntaxKind.Identifier && node.getWidth() > 0) {
|
||||
var symbol = typeInfoResolver.getSymbolInfo(node);
|
||||
if (symbol) {
|
||||
var type = classifySymbol(symbol);
|
||||
var type = classifySymbol(symbol, isTypeNode(node) || isTypeDeclarationName(node));
|
||||
if (type) {
|
||||
result.push({
|
||||
textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()),
|
||||
@@ -4116,7 +4337,7 @@ module ts {
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
var result: TypeScript.TextSpan[] = [];
|
||||
|
||||
var token = getTokenAtPosition(sourceFile, position);
|
||||
var token = getTouchingToken(sourceFile, position);
|
||||
|
||||
if (token.getStart(sourceFile) === position) {
|
||||
var matchKind = getMatchingTokenKind(token);
|
||||
@@ -4400,7 +4621,7 @@ module ts {
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
var node = getNodeAtPosition(sourceFile, position);
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
|
||||
// Can only rename an identifier.
|
||||
if (node && node.kind === SyntaxKind.Identifier) {
|
||||
@@ -4465,6 +4686,7 @@ module ts {
|
||||
getBreakpointStatementAtPosition: getBreakpointStatementAtPosition,
|
||||
getNavigateToItems: getNavigateToItems,
|
||||
getRenameInfo: getRenameInfo,
|
||||
findRenameLocations: findRenameLocations,
|
||||
getNavigationBarItems: getNavigationBarItems,
|
||||
getOutliningSpans: getOutliningSpans,
|
||||
getTodoComments: getTodoComments,
|
||||
@@ -4486,26 +4708,58 @@ module ts {
|
||||
/// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where
|
||||
/// we have a series of divide operator. this list allows us to be more accurate by ruling out
|
||||
/// locations where a regexp cannot exist.
|
||||
var noRegexTable: boolean[];
|
||||
if (!noRegexTable) {
|
||||
noRegexTable = [];
|
||||
noRegexTable[SyntaxKind.Identifier] = true;
|
||||
noRegexTable[SyntaxKind.StringLiteral] = true;
|
||||
noRegexTable[SyntaxKind.NumericLiteral] = true;
|
||||
noRegexTable[SyntaxKind.RegularExpressionLiteral] = true;
|
||||
noRegexTable[SyntaxKind.ThisKeyword] = true;
|
||||
noRegexTable[SyntaxKind.PlusPlusToken] = true;
|
||||
noRegexTable[SyntaxKind.MinusMinusToken] = true;
|
||||
noRegexTable[SyntaxKind.CloseParenToken] = true;
|
||||
noRegexTable[SyntaxKind.CloseBracketToken] = true;
|
||||
noRegexTable[SyntaxKind.CloseBraceToken] = true;
|
||||
noRegexTable[SyntaxKind.TrueKeyword] = true;
|
||||
noRegexTable[SyntaxKind.FalseKeyword] = true;
|
||||
var noRegexTable: boolean[] = [];
|
||||
noRegexTable[SyntaxKind.Identifier] = true;
|
||||
noRegexTable[SyntaxKind.StringLiteral] = true;
|
||||
noRegexTable[SyntaxKind.NumericLiteral] = true;
|
||||
noRegexTable[SyntaxKind.RegularExpressionLiteral] = true;
|
||||
noRegexTable[SyntaxKind.ThisKeyword] = true;
|
||||
noRegexTable[SyntaxKind.PlusPlusToken] = true;
|
||||
noRegexTable[SyntaxKind.MinusMinusToken] = true;
|
||||
noRegexTable[SyntaxKind.CloseParenToken] = true;
|
||||
noRegexTable[SyntaxKind.CloseBracketToken] = true;
|
||||
noRegexTable[SyntaxKind.CloseBraceToken] = true;
|
||||
noRegexTable[SyntaxKind.TrueKeyword] = true;
|
||||
noRegexTable[SyntaxKind.FalseKeyword] = true;
|
||||
|
||||
function isAccessibilityModifier(kind: SyntaxKind) {
|
||||
switch (kind) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */
|
||||
function canFollow(keyword1: SyntaxKind, keyword2: SyntaxKind) {
|
||||
if (isAccessibilityModifier(keyword1)) {
|
||||
if (keyword2 === SyntaxKind.GetKeyword ||
|
||||
keyword2 === SyntaxKind.SetKeyword ||
|
||||
keyword2 === SyntaxKind.ConstructorKeyword ||
|
||||
keyword2 === SyntaxKind.StaticKeyword) {
|
||||
|
||||
// Allow things like "public get", "public constructor" and "public static".
|
||||
// These are all legal.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Any other keyword following "public" is actually an identifier an not a real
|
||||
// keyword.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assume any other keyword combination is legal. This can be refined in the future
|
||||
// if there are more cases we want the classifier to be better at.
|
||||
return true;
|
||||
}
|
||||
|
||||
function getClassificationsForLine(text: string, lexState: EndOfLineState): ClassificationResult {
|
||||
var offset = 0;
|
||||
var lastTokenOrCommentEnd = 0;
|
||||
var token = SyntaxKind.Unknown;
|
||||
var lastNonTriviaToken = SyntaxKind.Unknown;
|
||||
|
||||
// If we're in a string literal, then prepend: "\
|
||||
@@ -4535,8 +4789,27 @@ module ts {
|
||||
entries: []
|
||||
};
|
||||
|
||||
|
||||
var token = SyntaxKind.Unknown;
|
||||
// We can run into an unfortunate interaction between the lexical and syntactic classifier
|
||||
// when the user is typing something generic. Consider the case where the user types:
|
||||
//
|
||||
// Foo<number
|
||||
//
|
||||
// From the lexical classifier's perspective, 'number' is a keyword, and so the word will
|
||||
// be classified as such. However, from the syntactic classifier's tree-based perspective
|
||||
// this is simply an expression with the identifier 'number' on the RHS of the less than
|
||||
// token. So the classification will go back to being an identifier. The moment the user
|
||||
// types again, number will become a keyword, then an identifier, etc. etc.
|
||||
//
|
||||
// To try to avoid this problem, we avoid classifying contextual keywords as keywords
|
||||
// when the user is potentially typing something generic. We just can't do a good enough
|
||||
// job at the lexical level, and so well leave it up to the syntactic classifier to make
|
||||
// the determination.
|
||||
//
|
||||
// In order to determine if the user is potentially typing something generic, we use a
|
||||
// weak heuristic where we track < and > tokens. It's a weak heuristic, but should
|
||||
// work well enough in practice.
|
||||
var angleBracketStack = 0;
|
||||
|
||||
do {
|
||||
token = scanner.scan();
|
||||
|
||||
@@ -4549,6 +4822,35 @@ module ts {
|
||||
else if (lastNonTriviaToken === SyntaxKind.DotToken && isKeyword(token)) {
|
||||
token = SyntaxKind.Identifier;
|
||||
}
|
||||
else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) {
|
||||
// We have two keywords in a row. Only treat the second as a keyword if
|
||||
// it's a sequence that could legally occur in the language. Otherwise
|
||||
// treat it as an identifier. This way, if someone writes "private var"
|
||||
// we recognize that 'var' is actually an identifier here.
|
||||
token = SyntaxKind.Identifier;
|
||||
}
|
||||
else if (lastNonTriviaToken === SyntaxKind.Identifier &&
|
||||
token === SyntaxKind.LessThanToken) {
|
||||
// Could be the start of something generic. Keep track of that by bumping
|
||||
// up the current count of generic contexts we may be in.
|
||||
angleBracketStack++;
|
||||
}
|
||||
else if (token === SyntaxKind.GreaterThanToken && angleBracketStack > 0) {
|
||||
// If we think we're currently in something generic, then mark that that
|
||||
// generic entity is complete.
|
||||
angleBracketStack--;
|
||||
}
|
||||
else if (token === SyntaxKind.AnyKeyword ||
|
||||
token === SyntaxKind.StringKeyword ||
|
||||
token === SyntaxKind.NumberKeyword ||
|
||||
token === SyntaxKind.BooleanKeyword) {
|
||||
if (angleBracketStack > 0) {
|
||||
// If it looks like we're could be in something generic, don't classify this
|
||||
// as a keyword. We may just get overwritten by the syntactic classifier,
|
||||
// causing a noisy experience for the user.
|
||||
token = SyntaxKind.Identifier;
|
||||
}
|
||||
}
|
||||
|
||||
lastNonTriviaToken = token;
|
||||
}
|
||||
|
||||
+15
-6
@@ -102,6 +102,12 @@ module ts {
|
||||
*/
|
||||
getRenameInfo(fileName: string, position: number): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string, textSpan: { start: number, length: number } }[]
|
||||
*/
|
||||
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; kind: string; name: string; containerKind: string; containerName: string }
|
||||
@@ -344,12 +350,6 @@ module ts {
|
||||
}
|
||||
var options = compilationSettingsToCompilerOptions(<CompilerOptions>JSON.parse(<any>settingsJson));
|
||||
|
||||
/// TODO: this should be pushed into VS.
|
||||
/// We can not ask the LS instance to resolve, as this will lead to asking the host about files it does not know about,
|
||||
/// something it is not designed to handle. for now make sure we never get a "noresolve == false".
|
||||
/// This value should not matter, as the host runs resolution logic independently
|
||||
options.noResolve = true;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -375,6 +375,7 @@ module ts {
|
||||
if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(diagnosticMessagesJson);
|
||||
}
|
||||
@@ -655,6 +656,14 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
public findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string {
|
||||
return this.forwardJSONCall(
|
||||
"findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")",
|
||||
() => {
|
||||
return this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments);
|
||||
});
|
||||
}
|
||||
|
||||
/// GET BRACE MATCHING
|
||||
public getBraceMatchingAtPosition(fileName: string, position: number): string {
|
||||
return this.forwardJSONCall(
|
||||
|
||||
@@ -172,15 +172,15 @@ module ts.SignatureHelp {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var argumentList = getContainingArgumentList(startingToken);
|
||||
var argumentInfo = getContainingArgumentInfo(startingToken);
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
// Semantic filtering of signature help
|
||||
if (!argumentList) {
|
||||
if (!argumentInfo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var call = <CallExpression>argumentList.parent;
|
||||
var call = <CallExpression>argumentInfo.list.parent;
|
||||
var candidates = <Signature[]>[];
|
||||
var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
@@ -189,13 +189,13 @@ module ts.SignatureHelp {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return createSignatureHelpItems(candidates, resolvedSignature, argumentList);
|
||||
return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo);
|
||||
|
||||
/**
|
||||
* If node is an argument, returns its index in the argument list.
|
||||
* If not, returns -1.
|
||||
*/
|
||||
function getImmediatelyContainingArgumentList(node: Node): Node {
|
||||
function getImmediatelyContainingArgumentInfo(node: Node): ListItemInfo {
|
||||
if (node.parent.kind !== SyntaxKind.CallExpression && node.parent.kind !== SyntaxKind.NewExpression) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -216,10 +216,14 @@ module ts.SignatureHelp {
|
||||
var parent = <CallExpression>node.parent;
|
||||
// Find out if 'node' is an argument, a type argument, or neither
|
||||
if (node.kind === SyntaxKind.LessThanToken || node.kind === SyntaxKind.OpenParenToken) {
|
||||
// Find the list that starts right *after* the < or ( token
|
||||
// Find the list that starts right *after* the < or ( token.
|
||||
// If the user has just opened a list, consider this item 0.
|
||||
var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile);
|
||||
Debug.assert(list);
|
||||
return list;
|
||||
return {
|
||||
list: list,
|
||||
listItemIndex: 0
|
||||
};
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.GreaterThanToken
|
||||
@@ -228,18 +232,18 @@ module ts.SignatureHelp {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return findContainingList(node);
|
||||
return findListItemInfo(node);
|
||||
}
|
||||
|
||||
function getContainingArgumentList(node: Node): Node {
|
||||
function getContainingArgumentInfo(node: Node): ListItemInfo {
|
||||
for (var n = node; n.kind !== SyntaxKind.SourceFile; n = n.parent) {
|
||||
if (n.kind === SyntaxKind.FunctionBlock) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var argumentList = getImmediatelyContainingArgumentList(n);
|
||||
if (argumentList) {
|
||||
return argumentList;
|
||||
var argumentInfo = getImmediatelyContainingArgumentInfo(n);
|
||||
if (argumentInfo) {
|
||||
return argumentInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +252,35 @@ module ts.SignatureHelp {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentListOrTypeArgumentList: Node): SignatureHelpItems {
|
||||
/**
|
||||
* The selectedItemIndex could be negative for several reasons.
|
||||
* 1. There are too many arguments for all of the overloads
|
||||
* 2. None of the overloads were type compatible
|
||||
* The solution here is to try to pick the best overload by picking
|
||||
* either the first one that has an appropriate number of parameters,
|
||||
* or the one with the most parameters.
|
||||
*/
|
||||
function selectBestInvalidOverloadIndex(candidates: Signature[], argumentCount: number): number {
|
||||
var maxParamsSignatureIndex = -1;
|
||||
var maxParams = -1;
|
||||
for (var i = 0; i < candidates.length; i++) {
|
||||
var candidate = candidates[i];
|
||||
|
||||
if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) {
|
||||
return i;
|
||||
}
|
||||
|
||||
if (candidate.parameters.length > maxParams) {
|
||||
maxParams = candidate.parameters.length;
|
||||
maxParamsSignatureIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
return maxParamsSignatureIndex;
|
||||
}
|
||||
|
||||
function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentInfoOrTypeArgumentInfo: ListItemInfo): SignatureHelpItems {
|
||||
var argumentListOrTypeArgumentList = argumentInfoOrTypeArgumentInfo.list;
|
||||
var items: SignatureHelpItem[] = map(candidates, candidateSignature => {
|
||||
var parameters = candidateSignature.parameters;
|
||||
var parameterHelpItems: SignatureHelpParameter[] = parameters.length === 0 ? emptyArray : map(parameters, p => {
|
||||
@@ -321,11 +353,6 @@ module ts.SignatureHelp {
|
||||
};
|
||||
});
|
||||
|
||||
var selectedItemIndex = candidates.indexOf(bestSignature);
|
||||
if (selectedItemIndex < 0) {
|
||||
selectedItemIndex = 0;
|
||||
}
|
||||
|
||||
// We use full start and skip trivia on the end because we want to include trivia on
|
||||
// both sides. For example,
|
||||
//
|
||||
@@ -338,63 +365,38 @@ module ts.SignatureHelp {
|
||||
var applicableSpanEnd = skipTrivia(sourceFile.text, argumentListOrTypeArgumentList.end, /*stopAfterLineBreak*/ false);
|
||||
var applicableSpan = new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
|
||||
|
||||
var state = getSignatureHelpCurrentArgumentState(sourceFile, position, applicableSpanStart);
|
||||
// The listItemIndex we got back includes commas. Our goal is to return the index of the proper
|
||||
// item (not including commas). Here are some examples:
|
||||
// 1. foo(a, b, c $) -> the listItemIndex is 4, we want to return 2
|
||||
// 2. foo(a, b, $ c) -> listItemIndex is 3, we want to return 2
|
||||
// 3. foo($a) -> listItemIndex is 0, we want to return 0
|
||||
//
|
||||
// In general, we want to subtract the number of commas before the current index.
|
||||
// But if we are on a comma, we also want to pretend we are on the argument *following*
|
||||
// the comma. That amounts to taking the ceiling of half the index.
|
||||
var argumentIndex = (argumentInfoOrTypeArgumentInfo.listItemIndex + 1) >> 1;
|
||||
|
||||
// argumentCount is the number of commas plus one, unless the list is completely empty,
|
||||
// in which case there are 0.
|
||||
var argumentCount = argumentListOrTypeArgumentList.getChildCount() === 0
|
||||
? 0
|
||||
: 1 + countWhere(argumentListOrTypeArgumentList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken);
|
||||
|
||||
var selectedItemIndex = candidates.indexOf(bestSignature);
|
||||
if (selectedItemIndex < 0) {
|
||||
selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount);
|
||||
}
|
||||
|
||||
return {
|
||||
items: items,
|
||||
applicableSpan: applicableSpan,
|
||||
selectedItemIndex: selectedItemIndex,
|
||||
argumentIndex: state.argumentIndex,
|
||||
argumentCount: state.argumentCount
|
||||
argumentIndex: argumentIndex,
|
||||
argumentCount: argumentCount
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function getSignatureHelpCurrentArgumentState(sourceFile: SourceFile, position: number, applicableSpanStart: number): { argumentIndex: number; argumentCount: number } {
|
||||
var tokenPrecedingSpanStart = findPrecedingToken(applicableSpanStart, sourceFile);
|
||||
if (!tokenPrecedingSpanStart) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (tokenPrecedingSpanStart.kind !== SyntaxKind.OpenParenToken && tokenPrecedingSpanStart.kind !== SyntaxKind.LessThanToken) {
|
||||
// The span start must have moved backward in the file (for example if the open paren was backspaced)
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var tokenPrecedingCurrentPosition = findPrecedingToken(position, sourceFile);
|
||||
var call = <CallExpression>tokenPrecedingSpanStart.parent;
|
||||
Debug.assert(call.kind === SyntaxKind.CallExpression || call.kind === SyntaxKind.NewExpression, "wrong call kind " + SyntaxKind[call.kind]);
|
||||
if (tokenPrecedingCurrentPosition.kind === SyntaxKind.CloseParenToken || tokenPrecedingCurrentPosition.kind === SyntaxKind.GreaterThanToken) {
|
||||
if (tokenPrecedingCurrentPosition.parent === call) {
|
||||
// This call expression is complete. Stop signature help.
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
var argumentListOrTypeArgumentList = getChildListThatStartsWithOpenerToken(call, tokenPrecedingSpanStart, sourceFile);
|
||||
// Debug.assert(argumentListOrTypeArgumentList.getChildCount() === 0 || argumentListOrTypeArgumentList.getChildCount() % 2 === 1, "Even number of children");
|
||||
|
||||
// The call might be finished, but incorrectly. Check if we are still within the bounds of the call
|
||||
if (position > skipTrivia(sourceFile.text, argumentListOrTypeArgumentList.end, /*stopAfterLineBreak*/ false)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var numberOfCommas = countWhere(argumentListOrTypeArgumentList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken);
|
||||
var argumentCount = numberOfCommas + 1;
|
||||
if (argumentCount <= 1) {
|
||||
return { argumentIndex: 0, argumentCount: argumentCount };
|
||||
}
|
||||
|
||||
var indexOfNodeContainingPosition = findListItemIndexContainingPosition(argumentListOrTypeArgumentList, position);
|
||||
|
||||
// indexOfNodeContainingPosition checks that position is between pos and end of each child, so it is
|
||||
// possible that we are to the right of all children. Assume that we are still within
|
||||
// the applicable span and that we are typing the last argument
|
||||
// Alternatively, we could be in range of one of the arguments, in which case we need to divide
|
||||
// by 2 to exclude commas. Use bit shifting in order to take the floor of the division.
|
||||
var argumentIndex = indexOfNodeContainingPosition < 0 ? argumentCount - 1 : indexOfNodeContainingPosition >> 1;
|
||||
return { argumentIndex: argumentIndex, argumentCount: argumentCount };
|
||||
}
|
||||
|
||||
function getChildListThatStartsWithOpenerToken(parent: Node, openerToken: Node, sourceFile: SourceFile): Node {
|
||||
var children = parent.getChildren(sourceFile);
|
||||
var indexOfOpenerToken = children.indexOf(openerToken);
|
||||
|
||||
+59
-27
@@ -50,34 +50,54 @@ module ts {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Get a token that contains the position. This is guaranteed to return a token, the position can be in the
|
||||
* leading trivia or within the token text.
|
||||
*/
|
||||
export function getTokenAtPosition(sourceFile: SourceFile, position: number) {
|
||||
var current: Node = sourceFile;
|
||||
outer: while (true) {
|
||||
// find the child that has this
|
||||
for (var i = 0, n = current.getChildCount(); i < n; i++) {
|
||||
var child = current.getChildAt(i);
|
||||
if (child.getFullStart() <= position && position < child.getEnd()) {
|
||||
current = child;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
/* Gets the token whose text has range [start, end) and
|
||||
* position >= start and (position < end or (position === end && token is keyword or identifier))
|
||||
*/
|
||||
export function getTouchingWord(sourceFile: SourceFile, position: number): Node {
|
||||
return getTouchingToken(sourceFile, position, isWord);
|
||||
}
|
||||
|
||||
/** Get the token whose text contains the position, or the containing node. */
|
||||
export function getNodeAtPosition(sourceFile: SourceFile, position: number) {
|
||||
/* Gets the token whose text has range [start, end) and position >= start
|
||||
* and (position < end or (position === end && token is keyword or identifier or numeric\string litera))
|
||||
*/
|
||||
export function getTouchingPropertyName(sourceFile: SourceFile, position: number): Node {
|
||||
return getTouchingToken(sourceFile, position, isPropertyName);
|
||||
}
|
||||
|
||||
/** Returns the token if position is in [start, end) or if position === end and includeItemAtEndPosition(token) === true */
|
||||
export function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean): Node {
|
||||
return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ false, includeItemAtEndPosition);
|
||||
}
|
||||
|
||||
/** Returns a token if position is in [start-of-leading-trivia, end) */
|
||||
export function getTokenAtPosition(sourceFile: SourceFile, position: number): Node {
|
||||
return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includeItemAtEndPosition*/ undefined);
|
||||
}
|
||||
|
||||
/** Get the token whose text contains the position */
|
||||
function getTokenAtPositionWorker(sourceFile: SourceFile, position: number, allowPositionInLeadingTrivia: boolean, includeItemAtEndPosition: (n: Node) => boolean): Node {
|
||||
var current: Node = sourceFile;
|
||||
outer: while (true) {
|
||||
// find the child that has this
|
||||
for (var i = 0, n = current.getChildCount(); i < n; i++) {
|
||||
if (isToken(current)) {
|
||||
// exit early
|
||||
return current;
|
||||
}
|
||||
|
||||
// find the child that contains 'position'
|
||||
for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) {
|
||||
var child = current.getChildAt(i);
|
||||
if (child.getStart() <= position && position < child.getEnd()) {
|
||||
current = child;
|
||||
continue outer;
|
||||
var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile);
|
||||
if (start <= position) {
|
||||
if (position < child.getEnd()) {
|
||||
current = child;
|
||||
continue outer;
|
||||
}
|
||||
else if (includeItemAtEndPosition && child.getEnd() === position) {
|
||||
var previousToken = findPrecedingToken(position, sourceFile, child);
|
||||
if (previousToken && includeItemAtEndPosition(previousToken)) {
|
||||
return previousToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return current;
|
||||
@@ -130,8 +150,8 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function findPrecedingToken(position: number, sourceFile: SourceFile): Node {
|
||||
return find(sourceFile);
|
||||
export function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node {
|
||||
return find(startNode || sourceFile);
|
||||
|
||||
function findRightmostToken(n: Node): Node {
|
||||
if (isToken(n)) {
|
||||
@@ -167,7 +187,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
Debug.assert(n.kind === SyntaxKind.SourceFile);
|
||||
Debug.assert(startNode || n.kind === SyntaxKind.SourceFile);
|
||||
|
||||
// Here we know that none of child token nodes embrace the position,
|
||||
// the only known case is when position is at the end of the file.
|
||||
@@ -202,7 +222,19 @@ module ts {
|
||||
return n.kind !== SyntaxKind.SyntaxList || n.getChildCount() !== 0;
|
||||
}
|
||||
|
||||
function isToken(n: Node): boolean {
|
||||
export function isToken(n: Node): boolean {
|
||||
return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken;
|
||||
}
|
||||
|
||||
function isKeyword(n: Node): boolean {
|
||||
return n.kind >= SyntaxKind.FirstKeyword && n.kind <= SyntaxKind.LastKeyword;
|
||||
}
|
||||
|
||||
function isWord(n: Node): boolean {
|
||||
return n.kind === SyntaxKind.Identifier || isKeyword(n);
|
||||
}
|
||||
|
||||
function isPropertyName(n: Node): boolean {
|
||||
return n.kind === SyntaxKind.StringLiteral || n.kind === SyntaxKind.NumericLiteral || isWord(n);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,12 +1,15 @@
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts(5,12): error TS2300: Duplicate identifier 'fn'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts(10,21): error TS2300: Duplicate identifier 'fn'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts (1 errors) ====
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts (2 errors) ====
|
||||
class clodule<T> {
|
||||
id: string;
|
||||
value: T;
|
||||
|
||||
static fn<U>(id: U) { }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'fn'.
|
||||
}
|
||||
|
||||
module clodule {
|
||||
|
||||
+4
-1
@@ -1,12 +1,15 @@
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts(5,12): error TS2300: Duplicate identifier 'fn'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts(10,21): error TS2300: Duplicate identifier 'fn'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts (1 errors) ====
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts (2 errors) ====
|
||||
class clodule<T> {
|
||||
id: string;
|
||||
value: T;
|
||||
|
||||
static fn(id: string) { }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'fn'.
|
||||
}
|
||||
|
||||
module clodule {
|
||||
|
||||
+7
-1
@@ -1,12 +1,16 @@
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts(4,12): error TS2300: Duplicate identifier 'Origin'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts(8,21): error TS2300: Duplicate identifier 'Origin'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts(16,16): error TS2300: Duplicate identifier 'Origin'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts(20,25): error TS2300: Duplicate identifier 'Origin'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts (2 errors) ====
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts (4 errors) ====
|
||||
class Point {
|
||||
constructor(public x: number, public y: number) { }
|
||||
|
||||
static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||
}
|
||||
|
||||
module Point {
|
||||
@@ -21,6 +25,8 @@ tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMer
|
||||
constructor(public x: number, public y: number) { }
|
||||
|
||||
static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||
}
|
||||
|
||||
export module Point {
|
||||
|
||||
+7
-1
@@ -1,12 +1,16 @@
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts(4,12): error TS2300: Duplicate identifier 'Origin'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts(8,16): error TS2300: Duplicate identifier 'Origin'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts(16,16): error TS2300: Duplicate identifier 'Origin'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts(20,20): error TS2300: Duplicate identifier 'Origin'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts (2 errors) ====
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts (4 errors) ====
|
||||
class Point {
|
||||
constructor(public x: number, public y: number) { }
|
||||
|
||||
static Origin: Point = { x: 0, y: 0 };
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||
}
|
||||
|
||||
module Point {
|
||||
@@ -21,6 +25,8 @@ tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMer
|
||||
constructor(public x: number, public y: number) { }
|
||||
|
||||
static Origin: Point = { x: 0, y: 0 };
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||
}
|
||||
|
||||
export module Point {
|
||||
|
||||
+7
-1
@@ -1,10 +1,14 @@
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts(2,18): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts(10,18): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts(17,18): error TS2300: Duplicate identifier 'Line'.
|
||||
tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts(26,26): error TS2300: Duplicate identifier 'Line'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts (2 errors) ====
|
||||
==== tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts (4 errors) ====
|
||||
module A {
|
||||
export class Point {
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Point'.
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
@@ -22,6 +26,8 @@ tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesTha
|
||||
|
||||
module X.Y.Z {
|
||||
export class Line {
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Line'.
|
||||
length: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/ambientClassOverloadForFunction.ts(1,15): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/ambientClassOverloadForFunction.ts(2,10): error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/ambientClassOverloadForFunction.ts (1 errors) ====
|
||||
==== tests/cases/compiler/ambientClassOverloadForFunction.ts (2 errors) ====
|
||||
declare class foo{};
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
function foo() { return null; }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
tests/cases/compiler/anyDeclare.ts(3,9): error TS2300: Duplicate identifier 'myFn'.
|
||||
tests/cases/compiler/anyDeclare.ts(4,14): error TS2300: Duplicate identifier 'myFn'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/anyDeclare.ts (1 errors) ====
|
||||
==== tests/cases/compiler/anyDeclare.ts (2 errors) ====
|
||||
declare var x: any;
|
||||
module myMod {
|
||||
var myFn;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'myFn'.
|
||||
function myFn() { }
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'myFn'.
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
tests/cases/compiler/augmentedTypesClass.ts(2,7): error TS2300: Duplicate identifier 'c1'.
|
||||
tests/cases/compiler/augmentedTypesClass.ts(3,5): error TS2300: Duplicate identifier 'c1'.
|
||||
tests/cases/compiler/augmentedTypesClass.ts(6,7): error TS2300: Duplicate identifier 'c4'.
|
||||
tests/cases/compiler/augmentedTypesClass.ts(7,6): error TS2300: Duplicate identifier 'c4'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesClass.ts (2 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesClass.ts (4 errors) ====
|
||||
//// class then var
|
||||
class c1 { public foo() { } }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c1'.
|
||||
var c1 = 1; // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c1'.
|
||||
|
||||
//// class then enum
|
||||
class c4 { public foo() { } }
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c4'.
|
||||
enum c4 { One } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c4'.
|
||||
@@ -1,12 +1,16 @@
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(4,7): error TS2300: Duplicate identifier 'c11'.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(10,11): error TS2300: Duplicate identifier 'c11'.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'.
|
||||
tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesClass2.ts (2 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesClass2.ts (4 errors) ====
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 {
|
||||
class c11 { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'c11'.
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
@@ -21,6 +25,8 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden
|
||||
// class then class - covered
|
||||
// class then enum
|
||||
class c33 {
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'c33'.
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Checking class with other things in type space not value space
|
||||
|
||||
// class then interface
|
||||
class c11 {
|
||||
class c11 { // error
|
||||
foo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(2,7): error TS2300: Duplicate identifier 'c2'.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(3,10): error TS2300: Duplicate identifier 'c2'.
|
||||
tests/cases/compiler/augmentedTypesClass2a.ts(4,5): error TS2300: Duplicate identifier 'c2'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesClass2a.ts (2 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesClass2a.ts (3 errors) ====
|
||||
//// class then function
|
||||
class c2 { public foo() { } }
|
||||
class c2 { public foo() { } } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c2'.
|
||||
function c2() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c2'.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [augmentedTypesClass2a.ts]
|
||||
//// class then function
|
||||
class c2 { public foo() { } }
|
||||
class c2 { public foo() { } } // error
|
||||
function c2() { } // error
|
||||
var c2 = () => { }
|
||||
|
||||
@@ -12,7 +12,7 @@ var c2 = (function () {
|
||||
c2.prototype.foo = function () {
|
||||
};
|
||||
return c2;
|
||||
})();
|
||||
})(); // error
|
||||
function c2() {
|
||||
} // error
|
||||
var c2 = function () {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/augmentedTypesClass4.ts(2,7): error TS2300: Duplicate identifier 'c3'.
|
||||
tests/cases/compiler/augmentedTypesClass4.ts(3,7): error TS2300: Duplicate identifier 'c3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesClass4.ts (1 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesClass4.ts (2 errors) ====
|
||||
//// class then class
|
||||
class c3 { public foo() { } }
|
||||
class c3 { public foo() { } } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c3'.
|
||||
class c3 { public bar() { } } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'c3'.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//// [augmentedTypesClass4.ts]
|
||||
//// class then class
|
||||
class c3 { public foo() { } }
|
||||
class c3 { public foo() { } } // error
|
||||
class c3 { public bar() { } } // error
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ var c3 = (function () {
|
||||
c3.prototype.foo = function () {
|
||||
};
|
||||
return c3;
|
||||
})();
|
||||
})(); // error
|
||||
var c3 = (function () {
|
||||
function c3() {
|
||||
}
|
||||
|
||||
@@ -1,43 +1,58 @@
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(2,6): error TS2300: Duplicate identifier 'e1111'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(3,5): error TS2300: Duplicate identifier 'e1111'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(6,6): error TS2300: Duplicate identifier 'e2'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(7,10): error TS2300: Duplicate identifier 'e2'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(9,6): error TS2300: Duplicate identifier 'e3'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(10,5): error TS2300: Duplicate identifier 'e3'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(13,6): error TS2300: Duplicate identifier 'e4'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(14,7): error TS2300: Duplicate identifier 'e4'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(18,11): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(20,12): error TS2300: Duplicate identifier 'One'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(21,12): error TS2300: Duplicate identifier 'One'.
|
||||
tests/cases/compiler/augmentedTypesEnum.ts(21,12): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesEnum.ts (7 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesEnum.ts (12 errors) ====
|
||||
// enum then var
|
||||
enum e1111 { One }
|
||||
enum e1111 { One } // error
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'e1111'.
|
||||
var e1111 = 1; // error
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'e1111'.
|
||||
|
||||
// enum then function
|
||||
enum e2 { One }
|
||||
enum e2 { One } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e2'.
|
||||
function e2() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e2'.
|
||||
|
||||
enum e3 { One }
|
||||
enum e3 { One } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e3'.
|
||||
var e3 = () => { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e3'.
|
||||
|
||||
// enum then class
|
||||
enum e4 { One }
|
||||
enum e4 { One } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e4'.
|
||||
class e4 { public foo() { } } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e4'.
|
||||
|
||||
// enum then enum
|
||||
enum e5 { One }
|
||||
enum e5 { Two }
|
||||
enum e5 { Two } // error
|
||||
~~~
|
||||
!!! error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.
|
||||
|
||||
enum e5a { One }
|
||||
enum e5a { One } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'One'.
|
||||
enum e5a { One } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'One'.
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
//// [augmentedTypesEnum.ts]
|
||||
// enum then var
|
||||
enum e1111 { One }
|
||||
enum e1111 { One } // error
|
||||
var e1111 = 1; // error
|
||||
|
||||
// enum then function
|
||||
enum e2 { One }
|
||||
enum e2 { One } // error
|
||||
function e2() { } // error
|
||||
|
||||
enum e3 { One }
|
||||
enum e3 { One } // error
|
||||
var e3 = () => { } // error
|
||||
|
||||
// enum then class
|
||||
enum e4 { One }
|
||||
enum e4 { One } // error
|
||||
class e4 { public foo() { } } // error
|
||||
|
||||
// enum then enum
|
||||
enum e5 { One }
|
||||
enum e5 { Two }
|
||||
enum e5 { Two } // error
|
||||
|
||||
enum e5a { One }
|
||||
enum e5a { One } // error
|
||||
enum e5a { One } // error
|
||||
|
||||
// enum then internal module
|
||||
@@ -40,26 +40,26 @@ module e6b { export var y = 2; } // should be error
|
||||
var e1111;
|
||||
(function (e1111) {
|
||||
e1111[e1111["One"] = 0] = "One";
|
||||
})(e1111 || (e1111 = {}));
|
||||
})(e1111 || (e1111 = {})); // error
|
||||
var e1111 = 1; // error
|
||||
// enum then function
|
||||
var e2;
|
||||
(function (e2) {
|
||||
e2[e2["One"] = 0] = "One";
|
||||
})(e2 || (e2 = {}));
|
||||
})(e2 || (e2 = {})); // error
|
||||
function e2() {
|
||||
} // error
|
||||
var e3;
|
||||
(function (e3) {
|
||||
e3[e3["One"] = 0] = "One";
|
||||
})(e3 || (e3 = {}));
|
||||
})(e3 || (e3 = {})); // error
|
||||
var e3 = function () {
|
||||
}; // error
|
||||
// enum then class
|
||||
var e4;
|
||||
(function (e4) {
|
||||
e4[e4["One"] = 0] = "One";
|
||||
})(e4 || (e4 = {}));
|
||||
})(e4 || (e4 = {})); // error
|
||||
var e4 = (function () {
|
||||
function e4() {
|
||||
}
|
||||
@@ -75,11 +75,11 @@ var e5;
|
||||
var e5;
|
||||
(function (e5) {
|
||||
e5[e5["Two"] = 0] = "Two";
|
||||
})(e5 || (e5 = {}));
|
||||
})(e5 || (e5 = {})); // error
|
||||
var e5a;
|
||||
(function (e5a) {
|
||||
e5a[e5a["One"] = 0] = "One";
|
||||
})(e5a || (e5a = {}));
|
||||
})(e5a || (e5a = {})); // error
|
||||
var e5a;
|
||||
(function (e5a) {
|
||||
e5a[e5a["One"] = 0] = "One";
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
tests/cases/compiler/augmentedTypesEnum2.ts(2,6): error TS2300: Duplicate identifier 'e1'.
|
||||
tests/cases/compiler/augmentedTypesEnum2.ts(4,11): error TS2300: Duplicate identifier 'e1'.
|
||||
tests/cases/compiler/augmentedTypesEnum2.ts(11,6): error TS2300: Duplicate identifier 'e2'.
|
||||
tests/cases/compiler/augmentedTypesEnum2.ts(12,7): error TS2300: Duplicate identifier 'e2'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesEnum2.ts (2 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesEnum2.ts (4 errors) ====
|
||||
// enum then interface
|
||||
enum e1 { One }
|
||||
enum e1 { One } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e1'.
|
||||
|
||||
interface e1 {
|
||||
interface e1 { // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e1'.
|
||||
foo(): void;
|
||||
@@ -15,7 +19,9 @@ tests/cases/compiler/augmentedTypesEnum2.ts(12,7): error TS2300: Duplicate ident
|
||||
// interface then enum works
|
||||
|
||||
// enum then class
|
||||
enum e2 { One };
|
||||
enum e2 { One }; // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e2'.
|
||||
class e2 { // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'e2'.
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
//// [augmentedTypesEnum2.ts]
|
||||
// enum then interface
|
||||
enum e1 { One }
|
||||
enum e1 { One } // error
|
||||
|
||||
interface e1 {
|
||||
interface e1 { // error
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
// interface then enum works
|
||||
|
||||
// enum then class
|
||||
enum e2 { One };
|
||||
enum e2 { One }; // error
|
||||
class e2 { // error
|
||||
foo() {
|
||||
return 1;
|
||||
@@ -24,7 +24,7 @@ class e2 { // error
|
||||
var e1;
|
||||
(function (e1) {
|
||||
e1[e1["One"] = 0] = "One";
|
||||
})(e1 || (e1 = {}));
|
||||
})(e1 || (e1 = {})); // error
|
||||
// interface then enum works
|
||||
// enum then class
|
||||
var e2;
|
||||
|
||||
@@ -1,42 +1,60 @@
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(2,10): error TS2300: Duplicate identifier 'y1'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(3,5): error TS2300: Duplicate identifier 'y1'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(7,1): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(6,10): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(7,10): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(9,10): error TS2300: Duplicate identifier 'y2a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(10,5): error TS2300: Duplicate identifier 'y2a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(13,10): error TS2300: Duplicate identifier 'y3'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(14,7): error TS2300: Duplicate identifier 'y3'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(16,10): error TS2300: Duplicate identifier 'y3a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(17,7): error TS2300: Duplicate identifier 'y3a'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(20,10): error TS2300: Duplicate identifier 'y4'.
|
||||
tests/cases/compiler/augmentedTypesFunction.ts(21,6): error TS2300: Duplicate identifier 'y4'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesFunction.ts (6 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesFunction.ts (12 errors) ====
|
||||
// function then var
|
||||
function y1() { }
|
||||
function y1() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y1'.
|
||||
var y1 = 1; // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y1'.
|
||||
|
||||
// function then function
|
||||
function y2() { }
|
||||
function y2() { } // error
|
||||
~~~~~~~~~~~~~~~~~
|
||||
~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
function y2() { } // error
|
||||
~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
|
||||
function y2a() { }
|
||||
function y2a() { } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'y2a'.
|
||||
var y2a = () => { } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'y2a'.
|
||||
|
||||
// function then class
|
||||
function y3() { }
|
||||
function y3() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y3'.
|
||||
class y3 { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y3'.
|
||||
|
||||
function y3a() { }
|
||||
function y3a() { } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'y3a'.
|
||||
class y3a { public foo() { } } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'y3a'.
|
||||
|
||||
// function then enum
|
||||
function y4() { }
|
||||
function y4() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y4'.
|
||||
enum y4 { One } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'y4'.
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
//// [augmentedTypesFunction.ts]
|
||||
// function then var
|
||||
function y1() { }
|
||||
function y1() { } // error
|
||||
var y1 = 1; // error
|
||||
|
||||
// function then function
|
||||
function y2() { }
|
||||
function y2() { } // error
|
||||
function y2() { } // error
|
||||
|
||||
function y2a() { }
|
||||
function y2a() { } // error
|
||||
var y2a = () => { } // error
|
||||
|
||||
// function then class
|
||||
function y3() { }
|
||||
function y3() { } // error
|
||||
class y3 { } // error
|
||||
|
||||
function y3a() { }
|
||||
function y3a() { } // error
|
||||
class y3a { public foo() { } } // error
|
||||
|
||||
// function then enum
|
||||
function y4() { }
|
||||
function y4() { } // error
|
||||
enum y4 { One } // error
|
||||
|
||||
// function then internal module
|
||||
@@ -41,27 +41,27 @@ module y5c { export interface I { foo(): void } } // should be an error
|
||||
//// [augmentedTypesFunction.js]
|
||||
// function then var
|
||||
function y1() {
|
||||
}
|
||||
} // error
|
||||
var y1 = 1; // error
|
||||
// function then function
|
||||
function y2() {
|
||||
}
|
||||
} // error
|
||||
function y2() {
|
||||
} // error
|
||||
function y2a() {
|
||||
}
|
||||
} // error
|
||||
var y2a = function () {
|
||||
}; // error
|
||||
// function then class
|
||||
function y3() {
|
||||
}
|
||||
} // error
|
||||
var y3 = (function () {
|
||||
function y3() {
|
||||
}
|
||||
return y3;
|
||||
})(); // error
|
||||
function y3a() {
|
||||
}
|
||||
} // error
|
||||
var y3a = (function () {
|
||||
function y3a() {
|
||||
}
|
||||
@@ -71,7 +71,7 @@ var y3a = (function () {
|
||||
})(); // error
|
||||
// function then enum
|
||||
function y4() {
|
||||
}
|
||||
} // error
|
||||
var y4;
|
||||
(function (y4) {
|
||||
y4[y4["One"] = 0] = "One";
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(12,11): error TS2300: Duplicate identifier 'i2'.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(16,7): error TS2300: Duplicate identifier 'i2'.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'.
|
||||
tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesInterface.ts (2 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesInterface.ts (4 errors) ====
|
||||
// interface then interface
|
||||
|
||||
interface i {
|
||||
@@ -14,7 +16,9 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 {
|
||||
interface i2 { // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'i2'.
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
@@ -27,7 +31,9 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i
|
||||
}
|
||||
|
||||
// interface then enum
|
||||
interface i3 {
|
||||
interface i3 { // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'i3'.
|
||||
foo(): void;
|
||||
}
|
||||
enum i3 { One }; // error
|
||||
|
||||
@@ -10,7 +10,7 @@ interface i {
|
||||
}
|
||||
|
||||
// interface then class
|
||||
interface i2 {
|
||||
interface i2 { // error
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class i2 { // error
|
||||
}
|
||||
|
||||
// interface then enum
|
||||
interface i3 {
|
||||
interface i3 { // error
|
||||
foo(): void;
|
||||
}
|
||||
enum i3 { One }; // error
|
||||
|
||||
@@ -1,23 +1,30 @@
|
||||
tests/cases/compiler/augmentedTypesModules.ts(5,8): error TS2300: Duplicate identifier 'm1a'.
|
||||
tests/cases/compiler/augmentedTypesModules.ts(6,5): error TS2300: Duplicate identifier 'm1a'.
|
||||
tests/cases/compiler/augmentedTypesModules.ts(8,8): error TS2300: Duplicate identifier 'm1b'.
|
||||
tests/cases/compiler/augmentedTypesModules.ts(9,5): error TS2300: Duplicate identifier 'm1b'.
|
||||
tests/cases/compiler/augmentedTypesModules.ts(16,8): error TS2300: Duplicate identifier 'm1d'.
|
||||
tests/cases/compiler/augmentedTypesModules.ts(19,5): error TS2300: Duplicate identifier 'm1d'.
|
||||
tests/cases/compiler/augmentedTypesModules.ts(25,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||
tests/cases/compiler/augmentedTypesModules.ts(28,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||
tests/cases/compiler/augmentedTypesModules.ts(51,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesModules.ts (6 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesModules.ts (9 errors) ====
|
||||
// module then var
|
||||
module m1 { }
|
||||
var m1 = 1; // Should be allowed
|
||||
|
||||
module m1a { var y = 2; }
|
||||
var m1a = 1;
|
||||
module m1a { var y = 2; } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'm1a'.
|
||||
var m1a = 1; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'm1a'.
|
||||
|
||||
module m1b { export var y = 2; }
|
||||
var m1b = 1;
|
||||
module m1b { export var y = 2; } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'm1b'.
|
||||
var m1b = 1; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'm1b'.
|
||||
|
||||
@@ -26,7 +33,9 @@ tests/cases/compiler/augmentedTypesModules.ts(51,8): error TS2434: A module decl
|
||||
}
|
||||
var m1c = 1; // Should be allowed
|
||||
|
||||
module m1d {
|
||||
module m1d { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'm1d'.
|
||||
export class I { foo() { } }
|
||||
}
|
||||
var m1d = 1; // error
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
module m1 { }
|
||||
var m1 = 1; // Should be allowed
|
||||
|
||||
module m1a { var y = 2; }
|
||||
var m1a = 1;
|
||||
module m1a { var y = 2; } // error
|
||||
var m1a = 1; // error
|
||||
|
||||
module m1b { export var y = 2; }
|
||||
var m1b = 1;
|
||||
module m1b { export var y = 2; } // error
|
||||
var m1b = 1; // error
|
||||
|
||||
module m1c {
|
||||
export interface I { foo(): void; }
|
||||
}
|
||||
var m1c = 1; // Should be allowed
|
||||
|
||||
module m1d {
|
||||
module m1d { // error
|
||||
export class I { foo() { } }
|
||||
}
|
||||
var m1d = 1; // error
|
||||
@@ -102,13 +102,13 @@ var m1 = 1; // Should be allowed
|
||||
var m1a;
|
||||
(function (m1a) {
|
||||
var y = 2;
|
||||
})(m1a || (m1a = {}));
|
||||
var m1a = 1;
|
||||
})(m1a || (m1a = {})); // error
|
||||
var m1a = 1; // error
|
||||
var m1b;
|
||||
(function (m1b) {
|
||||
m1b.y = 2;
|
||||
})(m1b || (m1b = {}));
|
||||
var m1b = 1;
|
||||
})(m1b || (m1b = {})); // error
|
||||
var m1b = 1; // error
|
||||
var m1c = 1; // Should be allowed
|
||||
var m1d;
|
||||
(function (m1d) {
|
||||
|
||||
@@ -1,41 +1,55 @@
|
||||
tests/cases/compiler/augmentedTypesVar.ts(6,5): error TS2300: Duplicate identifier 'x2'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(7,10): error TS2300: Duplicate identifier 'x2'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x3' must be of type 'number', but here has type '() => void'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(13,5): error TS2300: Duplicate identifier 'x4'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(14,7): error TS2300: Duplicate identifier 'x4'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(16,5): error TS2300: Duplicate identifier 'x4a'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(17,7): error TS2300: Duplicate identifier 'x4a'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(20,5): error TS2300: Duplicate identifier 'x5'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(21,6): error TS2300: Duplicate identifier 'x5'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(27,5): error TS2300: Duplicate identifier 'x6a'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(28,8): error TS2300: Duplicate identifier 'x6a'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(30,5): error TS2300: Duplicate identifier 'x6b'.
|
||||
tests/cases/compiler/augmentedTypesVar.ts(31,8): error TS2300: Duplicate identifier 'x6b'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/augmentedTypesVar.ts (7 errors) ====
|
||||
==== tests/cases/compiler/augmentedTypesVar.ts (13 errors) ====
|
||||
// var then var
|
||||
var x1 = 1;
|
||||
var x1 = 2;
|
||||
|
||||
// var then function
|
||||
var x2 = 1;
|
||||
function x2() { } // should be an error
|
||||
var x2 = 1; // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x2'.
|
||||
function x2() { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x2'.
|
||||
|
||||
var x3 = 1;
|
||||
var x3 = () => { } // should be an error
|
||||
var x3 = 1;
|
||||
var x3 = () => { } // error
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x3' must be of type 'number', but here has type '() => void'.
|
||||
|
||||
// var then class
|
||||
var x4 = 1;
|
||||
var x4 = 1; // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x4'.
|
||||
class x4 { } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x4'.
|
||||
|
||||
var x4a = 1;
|
||||
var x4a = 1; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'x4a'.
|
||||
class x4a { public foo() { } } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'x4a'.
|
||||
|
||||
// var then enum
|
||||
var x5 = 1;
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x5'.
|
||||
enum x5 { One } // error
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x5'.
|
||||
@@ -44,12 +58,16 @@ tests/cases/compiler/augmentedTypesVar.ts(31,8): error TS2300: Duplicate identif
|
||||
var x6 = 1;
|
||||
module x6 { } // ok since non-instantiated
|
||||
|
||||
var x6a = 1;
|
||||
var x6a = 1; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'x6a'.
|
||||
module x6a { var y = 2; } // error since instantiated
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'x6a'.
|
||||
|
||||
var x6b = 1;
|
||||
var x6b = 1; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'x6b'.
|
||||
module x6b { export var y = 2; } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'x6b'.
|
||||
|
||||
@@ -4,17 +4,17 @@ var x1 = 1;
|
||||
var x1 = 2;
|
||||
|
||||
// var then function
|
||||
var x2 = 1;
|
||||
function x2() { } // should be an error
|
||||
var x2 = 1; // error
|
||||
function x2() { } // error
|
||||
|
||||
var x3 = 1;
|
||||
var x3 = () => { } // should be an error
|
||||
var x3 = 1;
|
||||
var x3 = () => { } // error
|
||||
|
||||
// var then class
|
||||
var x4 = 1;
|
||||
var x4 = 1; // error
|
||||
class x4 { } // error
|
||||
|
||||
var x4a = 1;
|
||||
var x4a = 1; // error
|
||||
class x4a { public foo() { } } // error
|
||||
|
||||
// var then enum
|
||||
@@ -25,10 +25,10 @@ enum x5 { One } // error
|
||||
var x6 = 1;
|
||||
module x6 { } // ok since non-instantiated
|
||||
|
||||
var x6a = 1;
|
||||
var x6a = 1; // error
|
||||
module x6a { var y = 2; } // error since instantiated
|
||||
|
||||
var x6b = 1;
|
||||
var x6b = 1; // error
|
||||
module x6b { export var y = 2; } // error
|
||||
|
||||
// var then import, messes with other error reporting
|
||||
@@ -41,20 +41,20 @@ module x6b { export var y = 2; } // error
|
||||
var x1 = 1;
|
||||
var x1 = 2;
|
||||
// var then function
|
||||
var x2 = 1;
|
||||
var x2 = 1; // error
|
||||
function x2() {
|
||||
} // should be an error
|
||||
} // error
|
||||
var x3 = 1;
|
||||
var x3 = function () {
|
||||
}; // should be an error
|
||||
}; // error
|
||||
// var then class
|
||||
var x4 = 1;
|
||||
var x4 = 1; // error
|
||||
var x4 = (function () {
|
||||
function x4() {
|
||||
}
|
||||
return x4;
|
||||
})(); // error
|
||||
var x4a = 1;
|
||||
var x4a = 1; // error
|
||||
var x4a = (function () {
|
||||
function x4a() {
|
||||
}
|
||||
@@ -70,12 +70,12 @@ var x5;
|
||||
})(x5 || (x5 = {})); // error
|
||||
// var then module
|
||||
var x6 = 1;
|
||||
var x6a = 1;
|
||||
var x6a = 1; // error
|
||||
var x6a;
|
||||
(function (x6a) {
|
||||
var y = 2;
|
||||
})(x6a || (x6a = {})); // error since instantiated
|
||||
var x6b = 1;
|
||||
var x6b = 1; // error
|
||||
var x6b;
|
||||
(function (x6b) {
|
||||
x6b.y = 2;
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
tests/cases/compiler/callOnInstance.ts(1,18): error TS2300: Duplicate identifier 'D'.
|
||||
tests/cases/compiler/callOnInstance.ts(3,15): error TS2300: Duplicate identifier 'D'.
|
||||
tests/cases/compiler/callOnInstance.ts(7,19): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/compiler/callOnInstance.ts(7,19): error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOnInstance.ts (4 errors) ====
|
||||
declare function D(): string;
|
||||
==== tests/cases/compiler/callOnInstance.ts (5 errors) ====
|
||||
declare function D(): string; // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'D'.
|
||||
|
||||
declare class D { constructor (value: number); } // Duplicate identifier
|
||||
declare class D { constructor (value: number); } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'D'.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [callOnInstance.ts]
|
||||
declare function D(): string;
|
||||
declare function D(): string; // error
|
||||
|
||||
declare class D { constructor (value: number); } // Duplicate identifier
|
||||
declare class D { constructor (value: number); } // error
|
||||
|
||||
var s1: string = D(); // OK
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
tests/cases/compiler/callOverloads1.ts(1,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads1.ts(9,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads1.ts(9,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads1.ts(17,1): error TS2348: Value of type 'typeof Foo' is not callable. Did you mean to include 'new'?
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads1.ts (3 errors) ====
|
||||
class Foo {
|
||||
==== tests/cases/compiler/callOverloads1.ts (4 errors) ====
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
constructor(x: any) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [callOverloads1.ts]
|
||||
class Foo {
|
||||
class Foo { // error
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
constructor(x: any) {
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
tests/cases/compiler/callOverloads2.ts(3,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads2.ts(11,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads2.ts(13,10): error TS2389: Function implementation name must be 'Foo'.
|
||||
tests/cases/compiler/callOverloads2.ts(14,1): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/callOverloads2.ts(13,10): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/callOverloads2.ts(14,10): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/callOverloads2.ts(16,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads2.ts(24,1): error TS2348: Value of type 'typeof Foo' is not callable. Did you mean to include 'new'?
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads2.ts (5 errors) ====
|
||||
==== tests/cases/compiler/callOverloads2.ts (7 errors) ====
|
||||
|
||||
|
||||
class Foo {
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
constructor(x: any) {
|
||||
@@ -16,15 +20,17 @@ tests/cases/compiler/callOverloads2.ts(24,1): error TS2348: Value of type 'typeo
|
||||
}
|
||||
}
|
||||
|
||||
function Foo();
|
||||
function Foo(); // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
|
||||
function F1(s:string) {return s;}
|
||||
function F1(s:string) {return s;} // error
|
||||
~~
|
||||
!!! error TS2389: Function implementation name must be 'Foo'.
|
||||
function F1(a:any) { return a;} // error - duplicate identifier
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
function F1(a:any) { return a;} // error
|
||||
~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
|
||||
function Goo(s:string); // error - no implementation
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [callOverloads2.ts]
|
||||
|
||||
|
||||
class Foo {
|
||||
class Foo { // error
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
constructor(x: any) {
|
||||
@@ -9,10 +9,10 @@ class Foo {
|
||||
}
|
||||
}
|
||||
|
||||
function Foo();
|
||||
function Foo(); // error
|
||||
|
||||
function F1(s:string) {return s;}
|
||||
function F1(a:any) { return a;} // error - duplicate identifier
|
||||
function F1(s:string) {return s;} // error
|
||||
function F1(a:any) { return a;} // error
|
||||
|
||||
function Goo(s:string); // error - no implementation
|
||||
|
||||
@@ -36,10 +36,10 @@ var Foo = (function () {
|
||||
})();
|
||||
function F1(s) {
|
||||
return s;
|
||||
}
|
||||
} // error
|
||||
function F1(a) {
|
||||
return a;
|
||||
} // error - duplicate identifier
|
||||
} // error
|
||||
var f1 = new Foo("hey");
|
||||
f1.bar1();
|
||||
Foo();
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
tests/cases/compiler/callOverloads3.ts(2,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(2,16): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(3,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(3,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads3.ts(3,24): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(4,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads3.ts(12,10): error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads3.ts (5 errors) ====
|
||||
==== tests/cases/compiler/callOverloads3.ts (7 errors) ====
|
||||
|
||||
function Foo():Foo;
|
||||
function Foo():Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
function Foo(s:string):Foo;
|
||||
function Foo(s:string):Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
class Foo {
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//// [callOverloads3.ts]
|
||||
|
||||
function Foo():Foo;
|
||||
function Foo(s:string):Foo;
|
||||
class Foo {
|
||||
function Foo():Foo; // error
|
||||
function Foo(s:string):Foo; // error
|
||||
class Foo { // error
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
constructor(x: any) {
|
||||
// WScript.Echo("Constructor function has executed");
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
tests/cases/compiler/callOverloads4.ts(2,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(2,16): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(3,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(3,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads4.ts(3,24): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(4,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads4.ts(12,10): error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads4.ts (5 errors) ====
|
||||
==== tests/cases/compiler/callOverloads4.ts (7 errors) ====
|
||||
|
||||
function Foo():Foo;
|
||||
function Foo():Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
function Foo(s:string):Foo;
|
||||
function Foo(s:string):Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
class Foo {
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//// [callOverloads4.ts]
|
||||
|
||||
function Foo():Foo;
|
||||
function Foo(s:string):Foo;
|
||||
class Foo {
|
||||
function Foo():Foo; // error
|
||||
function Foo(s:string):Foo; // error
|
||||
class Foo { // error
|
||||
bar1() { /*WScript.Echo("bar1");*/ }
|
||||
constructor(s: string);
|
||||
constructor(x: any) {
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
tests/cases/compiler/callOverloads5.ts(1,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(1,16): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(2,10): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/callOverloads5.ts(2,24): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(3,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/callOverloads5.ts(13,10): error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
|
||||
|
||||
==== tests/cases/compiler/callOverloads5.ts (5 errors) ====
|
||||
function Foo():Foo;
|
||||
==== tests/cases/compiler/callOverloads5.ts (7 errors) ====
|
||||
function Foo():Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
function Foo(s:string):Foo;
|
||||
function Foo(s:string):Foo; // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
class Foo {
|
||||
class Foo { // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
bar1(s:string);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [callOverloads5.ts]
|
||||
function Foo():Foo;
|
||||
function Foo(s:string):Foo;
|
||||
class Foo {
|
||||
function Foo():Foo; // error
|
||||
function Foo(s:string):Foo; // error
|
||||
class Foo { // error
|
||||
bar1(s:string);
|
||||
bar1(n:number);
|
||||
bar1(a:any) { /*WScript.Echo(a);*/ }
|
||||
|
||||
@@ -1,107 +1,173 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(3,14): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(3,17): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(4,22): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(4,25): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(5,20): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(5,23): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(6,11): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(6,14): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(7,14): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(7,20): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(9,15): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(9,26): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(10,23): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(10,34): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(11,20): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(11,31): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(12,11): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(12,22): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(16,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(16,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(17,10): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(17,21): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(18,13): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(18,19): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(22,6): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(22,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(23,6): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(23,17): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(24,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(24,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(25,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(25,20): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(26,13): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(26,19): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(30,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(30,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(31,10): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(31,21): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(35,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(35,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(36,21): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(36,32): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(37,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts(37,18): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts (22 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts (44 errors) ====
|
||||
// Duplicate parameter names are always an error
|
||||
|
||||
function foo(x, x) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f = function foo(x, x) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f2 = function (x, x) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f3 = (x, x) => { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f4 = <T>(x: T, x: T) => { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
function foo2(x: string, x: number) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f5 = function foo(x: string, x: number) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f6 = function (x: string, x: number) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f7 = (x: string, x: number) => { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
var f8 = <T>(x: T, y: T) => { }
|
||||
|
||||
class C {
|
||||
foo(x, x) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
foo2(x: number, x: string) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
foo3<T>(x: T, x: T) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
|
||||
interface I {
|
||||
(x, x);
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
(x: string, x: number);
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
foo(x, x);
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
foo(x: number, x: string);
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
foo3<T>(x: T, x: T);
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
|
||||
var a: {
|
||||
foo(x, x);
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
foo2(x: number, x: string);
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
};
|
||||
|
||||
var b = {
|
||||
foo(x, x) { },
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
a: function foo(x: number, x: string) { },
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
b: <T>(x: T, x: T) => { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(20,15): error TS1005: '{' expected.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(4,14): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(11,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(20,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(21,5): error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts (4 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts (5 errors) ====
|
||||
// Optional parameters allow initializers only in implementation signatures
|
||||
// All the below declarations are errors
|
||||
|
||||
@@ -28,10 +29,12 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWit
|
||||
c.foo(1);
|
||||
|
||||
var b = {
|
||||
foo(x = 1),
|
||||
foo(x = 1), // error
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
foo(x = 1) { },
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
foo(x = 1) { }, // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/class1.ts(1,11): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/class1.ts(2,7): error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/class1.ts (1 errors) ====
|
||||
interface foo{ }
|
||||
class foo{ }
|
||||
==== tests/cases/compiler/class1.ts (2 errors) ====
|
||||
interface foo{ } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
class foo{ } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
@@ -1,10 +1,10 @@
|
||||
//// [class1.ts]
|
||||
interface foo{ }
|
||||
class foo{ }
|
||||
interface foo{ } // error
|
||||
class foo{ } // error
|
||||
|
||||
//// [class1.js]
|
||||
var foo = (function () {
|
||||
function foo() {
|
||||
}
|
||||
return foo;
|
||||
})();
|
||||
})(); // error
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/classAndInterface1.ts(1,8): error TS2300: Duplicate identifier 'cli'.
|
||||
tests/cases/compiler/classAndInterface1.ts(2,11): error TS2300: Duplicate identifier 'cli'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classAndInterface1.ts (1 errors) ====
|
||||
class cli { }
|
||||
==== tests/cases/compiler/classAndInterface1.ts (2 errors) ====
|
||||
class cli { } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'cli'.
|
||||
interface cli { } // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'cli'.
|
||||
@@ -1,5 +1,5 @@
|
||||
//// [classAndInterface1.ts]
|
||||
class cli { }
|
||||
class cli { } // error
|
||||
interface cli { } // error
|
||||
|
||||
//// [classAndInterface1.js]
|
||||
@@ -7,4 +7,4 @@ var cli = (function () {
|
||||
function cli() {
|
||||
}
|
||||
return cli;
|
||||
})();
|
||||
})(); // error
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(1,7): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(2,11): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(5,11): error TS2300: Duplicate identifier 'D'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts(9,15): error TS2300: Duplicate identifier 'D'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (2 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceWithSameName.ts (4 errors) ====
|
||||
class C { foo: string; }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
interface C { foo: string; } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
|
||||
module M {
|
||||
class D {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'D'.
|
||||
bar: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAndVariableWithSameName.ts(1,7): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndVariableWithSameName.ts(2,5): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndVariableWithSameName.ts(5,11): error TS2300: Duplicate identifier 'D'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndVariableWithSameName.ts(9,9): error TS2300: Duplicate identifier 'D'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndVariableWithSameName.ts (2 errors) ====
|
||||
class C { foo: string; }
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndVariableWithSameName.ts (4 errors) ====
|
||||
class C { foo: string; } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
var C = ''; // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
|
||||
module M {
|
||||
class D {
|
||||
class D { // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'D'.
|
||||
bar: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//// [classAndVariableWithSameName.ts]
|
||||
class C { foo: string; }
|
||||
class C { foo: string; } // error
|
||||
var C = ''; // error
|
||||
|
||||
module M {
|
||||
class D {
|
||||
class D { // error
|
||||
bar: string;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
})(); // error
|
||||
var C = ''; // error
|
||||
var M;
|
||||
(function (M) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/classCannotExtendVar.ts(1,5): error TS2300: Duplicate identifier 'Markup'.
|
||||
tests/cases/compiler/classCannotExtendVar.ts(3,7): error TS2300: Duplicate identifier 'Markup'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classCannotExtendVar.ts (1 errors) ====
|
||||
==== tests/cases/compiler/classCannotExtendVar.ts (2 errors) ====
|
||||
var Markup;
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Markup'.
|
||||
|
||||
class Markup {
|
||||
~~~~~~
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/classOverloadForFunction.ts(1,7): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/classOverloadForFunction.ts(2,10): error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classOverloadForFunction.ts (1 errors) ====
|
||||
==== tests/cases/compiler/classOverloadForFunction.ts (2 errors) ====
|
||||
class foo { };
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
function foo() {}
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(1,10): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/classOverloadForFunction2.ts(2,7): error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classOverloadForFunction2.ts (2 errors) ====
|
||||
==== tests/cases/compiler/classOverloadForFunction2.ts (3 errors) ====
|
||||
function bar(): string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
class bar {}
|
||||
~~~
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
tests/cases/conformance/classes/constructorDeclarations/classWithTwoConstructorDefinitions.ts(2,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classWithTwoConstructorDefinitions.ts(3,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classWithTwoConstructorDefinitions.ts(7,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/conformance/classes/constructorDeclarations/classWithTwoConstructorDefinitions.ts(8,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/constructorDeclarations/classWithTwoConstructorDefinitions.ts (2 errors) ====
|
||||
==== tests/cases/conformance/classes/constructorDeclarations/classWithTwoConstructorDefinitions.ts (4 errors) ====
|
||||
class C {
|
||||
constructor() { }
|
||||
constructor() { } // error
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
constructor(x) { } // error
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
constructor(x: T) { }
|
||||
constructor(x: T) { } // error
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
constructor(x: T, y: T) { } // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
//// [classWithTwoConstructorDefinitions.ts]
|
||||
class C {
|
||||
constructor() { }
|
||||
constructor() { } // error
|
||||
constructor(x) { } // error
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
constructor(x: T) { }
|
||||
constructor(x: T) { } // error
|
||||
constructor(x: T, y: T) { } // error
|
||||
}
|
||||
|
||||
//// [classWithTwoConstructorDefinitions.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
} // error
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(x) {
|
||||
}
|
||||
} // error
|
||||
return D;
|
||||
})();
|
||||
|
||||
@@ -1,22 +1,32 @@
|
||||
tests/cases/compiler/clinterfaces.ts(2,11): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/compiler/clinterfaces.ts(3,15): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/compiler/clinterfaces.ts(4,15): error TS2300: Duplicate identifier 'D'.
|
||||
tests/cases/compiler/clinterfaces.ts(5,11): error TS2300: Duplicate identifier 'D'.
|
||||
tests/cases/compiler/clinterfaces.ts(8,11): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/clinterfaces.ts(12,7): error TS2300: Duplicate identifier 'Foo'.
|
||||
tests/cases/compiler/clinterfaces.ts(16,7): error TS2300: Duplicate identifier 'Bar'.
|
||||
tests/cases/compiler/clinterfaces.ts(20,11): error TS2300: Duplicate identifier 'Bar'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/clinterfaces.ts (4 errors) ====
|
||||
==== tests/cases/compiler/clinterfaces.ts (8 errors) ====
|
||||
module M {
|
||||
class C { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
interface C { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
interface D { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'D'.
|
||||
class D { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'D'.
|
||||
}
|
||||
|
||||
interface Foo<T> {
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Foo'.
|
||||
a: string;
|
||||
}
|
||||
|
||||
@@ -27,6 +37,8 @@ tests/cases/compiler/clinterfaces.ts(20,11): error TS2300: Duplicate identifier
|
||||
}
|
||||
|
||||
class Bar<T>{
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Bar'.
|
||||
b: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
tests/cases/compiler/cloduleWithDuplicateMember1.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember1.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember1.ts(3,16): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember1.ts(6,12): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember1.ts(10,16): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember1.ts(13,21): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember1.ts(14,21): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/cloduleWithDuplicateMember1.ts (5 errors) ====
|
||||
==== tests/cases/compiler/cloduleWithDuplicateMember1.ts (7 errors) ====
|
||||
class C {
|
||||
get x() { return 1; }
|
||||
~
|
||||
@@ -13,9 +15,13 @@ tests/cases/compiler/cloduleWithDuplicateMember1.ts(14,21): error TS2300: Duplic
|
||||
static get x() {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
return '';
|
||||
}
|
||||
static foo() { }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
}
|
||||
|
||||
module C {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
tests/cases/compiler/cloduleWithDuplicateMember2.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember2.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember2.ts(7,16): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/cloduleWithDuplicateMember2.ts(10,21): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/cloduleWithDuplicateMember2.ts (3 errors) ====
|
||||
==== tests/cases/compiler/cloduleWithDuplicateMember2.ts (4 errors) ====
|
||||
class C {
|
||||
set x(y) { }
|
||||
~
|
||||
@@ -15,6 +16,8 @@ tests/cases/compiler/cloduleWithDuplicateMember2.ts(10,21): error TS2300: Duplic
|
||||
|
||||
module C {
|
||||
export var x = 1;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
module C {
|
||||
export function x() { }
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
tests/cases/compiler/conflictingTypeAnnotatedVar.ts(1,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,10): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/conflictingTypeAnnotatedVar.ts(2,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,10): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/conflictingTypeAnnotatedVar.ts(3,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
|
||||
|
||||
==== tests/cases/compiler/conflictingTypeAnnotatedVar.ts (4 errors) ====
|
||||
==== tests/cases/compiler/conflictingTypeAnnotatedVar.ts (5 errors) ====
|
||||
var foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
function foo(): number { }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
+10
-1
@@ -1,8 +1,11 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(4,17): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(4,24): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(4,27): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(4,35): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(5,24): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(5,35): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(9,17): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(9,25): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(10,24): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(14,17): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(19,10): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
@@ -15,15 +18,19 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatur
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(35,10): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts (15 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts (18 errors) ====
|
||||
// Parameter properties are not valid in overloads of constructors
|
||||
|
||||
class C {
|
||||
constructor(public x, private y);
|
||||
~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
constructor(public x, private y) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
@@ -35,6 +42,8 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatur
|
||||
constructor(private x);
|
||||
~~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
constructor(public x) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
@@ -1,15 +1,26 @@
|
||||
tests/cases/compiler/constructorOverloads1.ts(2,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/compiler/constructorOverloads1.ts(3,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/compiler/constructorOverloads1.ts(4,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/compiler/constructorOverloads1.ts(7,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/compiler/constructorOverloads1.ts(16,18): error TS2345: Argument of type 'Foo' is not assignable to parameter of type 'number'.
|
||||
tests/cases/compiler/constructorOverloads1.ts(17,18): error TS2345: Argument of type 'unknown[]' is not assignable to parameter of type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constructorOverloads1.ts (3 errors) ====
|
||||
==== tests/cases/compiler/constructorOverloads1.ts (6 errors) ====
|
||||
class Foo {
|
||||
constructor(s: string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
constructor(n: number);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
constructor(x: any) {
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
}
|
||||
~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
constructor(x: any) {
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
tests/cases/compiler/constructorOverloads4.ts(2,18): error TS2300: Duplicate identifier 'Function'.
|
||||
tests/cases/compiler/constructorOverloads4.ts(5,21): error TS2300: Duplicate identifier 'Function'.
|
||||
tests/cases/compiler/constructorOverloads4.ts(6,21): error TS2300: Duplicate identifier 'Function'.
|
||||
tests/cases/compiler/constructorOverloads4.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
tests/cases/compiler/constructorOverloads4.ts(11,1): error TS2348: Value of type 'typeof Function' is not callable. Did you mean to include 'new'?
|
||||
|
||||
|
||||
==== tests/cases/compiler/constructorOverloads4.ts (4 errors) ====
|
||||
==== tests/cases/compiler/constructorOverloads4.ts (5 errors) ====
|
||||
declare module M {
|
||||
export class Function {
|
||||
~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Function'.
|
||||
constructor(...args: string[]);
|
||||
}
|
||||
export function Function(...args: any[]): any;
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
tests/cases/compiler/constructorOverloads5.ts(4,21): error TS2300: Duplicate identifier 'RegExp'.
|
||||
tests/cases/compiler/constructorOverloads5.ts(5,21): error TS2300: Duplicate identifier 'RegExp'.
|
||||
tests/cases/compiler/constructorOverloads5.ts(6,18): error TS2300: Duplicate identifier 'RegExp'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constructorOverloads5.ts (1 errors) ====
|
||||
==== tests/cases/compiler/constructorOverloads5.ts (3 errors) ====
|
||||
interface IArguments {}
|
||||
|
||||
declare module M {
|
||||
export function RegExp(pattern: string): RegExp;
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'RegExp'.
|
||||
export function RegExp(pattern: string, flags: string): RegExp;
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'RegExp'.
|
||||
export class RegExp {
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'RegExp'.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/constructorOverloads7.ts(1,15): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/compiler/constructorOverloads7.ts(15,10): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/compiler/constructorOverloads7.ts(22,18): error TS2384: Overload signatures must all be ambient or non-ambient.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constructorOverloads7.ts (2 errors) ====
|
||||
==== tests/cases/compiler/constructorOverloads7.ts (3 errors) ====
|
||||
declare class Point
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Point'.
|
||||
{
|
||||
x: number;
|
||||
y: number;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/constructorOverloads8.ts(2,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
tests/cases/compiler/constructorOverloads8.ts(3,5): error TS2392: Multiple constructor implementations are not allowed.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constructorOverloads8.ts (1 errors) ====
|
||||
==== tests/cases/compiler/constructorOverloads8.ts (2 errors) ====
|
||||
class C {
|
||||
constructor(x) { }
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
constructor(y, x) { } // illegal, 2 constructor implementations
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2392: Multiple constructor implementations are not allowed.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(10,5): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(11,24): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(18,5): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(19,25): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(26,5): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(27,27): error TS2300: Duplicate identifier 'y'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts (3 errors) ====
|
||||
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts (6 errors) ====
|
||||
class C {
|
||||
y: number;
|
||||
constructor(y: number) { } // ok
|
||||
@@ -14,6 +17,8 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
|
||||
|
||||
class D {
|
||||
y: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
constructor(public y: number) { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
@@ -24,6 +29,8 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
|
||||
|
||||
class E {
|
||||
y: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
constructor(private y: number) { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
@@ -34,6 +41,8 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
|
||||
|
||||
class F {
|
||||
y: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
constructor(protected y: number) { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
tests/cases/compiler/contextualTyping.ts(189,18): error TS2384: Overload signatures must all be ambient or non-ambient.
|
||||
tests/cases/compiler/contextualTyping.ts(197,15): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/compiler/contextualTyping.ts(207,10): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/compiler/contextualTyping.ts(230,5): error TS2322: Type '{}' is not assignable to type 'B':\n Property 'x' is missing in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping.ts (3 errors) ====
|
||||
==== tests/cases/compiler/contextualTyping.ts (4 errors) ====
|
||||
// DEFAULT INTERFACES
|
||||
interface IFoo {
|
||||
n: number;
|
||||
@@ -203,6 +204,8 @@ tests/cases/compiler/contextualTyping.ts(230,5): error TS2322: Type '{}' is not
|
||||
|
||||
// contextually typing from ambient class declarations
|
||||
declare class Point
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'Point'.
|
||||
{
|
||||
constructor(x: number, y: number);
|
||||
x: number;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/declInput.ts(1,11): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/compiler/declInput.ts(5,7): error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declInput.ts (1 errors) ====
|
||||
==== tests/cases/compiler/declInput.ts (2 errors) ====
|
||||
interface bar {
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompa
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(11,5): error TS2412: Property ''1'' of type '{ y: number; }' is not assignable to numeric index type '{ x: number; y: number; }'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(15,5): error TS2411: Property 'foo' of type '{ y: number; }' is not assignable to string index type '{ x: number; }'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(19,5): error TS2411: Property 'foo' of type '() => { x: number; }' is not assignable to string index type '{ x: number; }'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(24,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(24,5): error TS2412: Property '1' of type '{ x: number; }' is not assignable to numeric index type '{ x: number; y: number; }'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts(28,5): error TS2300: Duplicate identifier ''1''.
|
||||
|
||||
|
||||
==== tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts (8 errors) ====
|
||||
==== tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompatibleWithBaseIndexer.ts (9 errors) ====
|
||||
interface Base {
|
||||
[x: number]: { x: number; y: number; };
|
||||
[x: string]: { x: number; }
|
||||
@@ -45,6 +46,8 @@ tests/cases/conformance/interfaces/interfaceDeclarations/derivedInterfaceIncompa
|
||||
// satisifies string indexer but not numeric indexer
|
||||
interface Derived5 extends Base {
|
||||
1: { x: number } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier '1'.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2412: Property '1' of type '{ x: number; }' is not assignable to numeric index type '{ x: number; y: number; }'.
|
||||
}
|
||||
|
||||
@@ -8,30 +8,43 @@ tests/cases/compiler/duplicateClassElements.ts(29,9): error TS1056: Accessors ar
|
||||
tests/cases/compiler/duplicateClassElements.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/duplicateClassElements.ts(36,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/duplicateClassElements.ts(39,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/duplicateClassElements.ts(2,12): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(3,12): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(6,5): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/duplicateClassElements.ts(4,12): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/duplicateClassElements.ts(6,12): error TS2393: Duplicate function implementation.
|
||||
tests/cases/compiler/duplicateClassElements.ts(8,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(9,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(12,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(21,12): error TS2300: Duplicate identifier 'z'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(23,9): error TS2300: Duplicate identifier 'z'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(26,9): error TS2300: Duplicate identifier 'z'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(29,9): error TS2300: Duplicate identifier 'x2'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(32,9): error TS2300: Duplicate identifier 'x2'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2300: Duplicate identifier 'x2'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(36,9): error TS2300: Duplicate identifier 'z2'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(39,9): error TS2300: Duplicate identifier 'z2'.
|
||||
tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate identifier 'z2'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateClassElements.ts (18 errors) ====
|
||||
==== tests/cases/compiler/duplicateClassElements.ts (26 errors) ====
|
||||
class a {
|
||||
public a;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
public a;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
public b() {
|
||||
~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
}
|
||||
public b() {
|
||||
~~~~~~~~~~~~
|
||||
}
|
||||
~~~~~
|
||||
~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
}
|
||||
public x;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
get x() {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
@@ -57,6 +70,8 @@ tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate i
|
||||
}
|
||||
|
||||
public z() {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'z'.
|
||||
}
|
||||
get z() {
|
||||
~
|
||||
@@ -75,11 +90,15 @@ tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate i
|
||||
get x2() {
|
||||
~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x2'.
|
||||
return 10;
|
||||
}
|
||||
set x2(_x: number) {
|
||||
~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'x2'.
|
||||
}
|
||||
public x2;
|
||||
~~
|
||||
@@ -88,11 +107,15 @@ tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate i
|
||||
get z2() {
|
||||
~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'z2'.
|
||||
return "Hello";
|
||||
}
|
||||
set z2(_y: string) {
|
||||
~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier 'z2'.
|
||||
}
|
||||
public z2() {
|
||||
~~
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(1,5): error TS2300: Duplicate identifier 'v'.
|
||||
tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(3,14): error TS2300: Duplicate identifier 'v'.
|
||||
tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(6,10): error TS2300: Duplicate identifier 'w'.
|
||||
tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(8,9): error TS2300: Duplicate identifier 'w'.
|
||||
tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(12,9): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(13,14): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(16,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'p' must be of type 'string', but here has type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateIdentifierInCatchBlock.ts (4 errors) ====
|
||||
==== tests/cases/compiler/duplicateIdentifierInCatchBlock.ts (7 errors) ====
|
||||
var v;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'v'.
|
||||
try { } catch (e) {
|
||||
function v() { }
|
||||
~
|
||||
@@ -13,6 +18,8 @@ tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(16,9): error TS2403: Sub
|
||||
}
|
||||
|
||||
function w() { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'w'.
|
||||
try { } catch (e) {
|
||||
var w;
|
||||
~
|
||||
@@ -21,6 +28,8 @@ tests/cases/compiler/duplicateIdentifierInCatchBlock.ts(16,9): error TS2403: Sub
|
||||
|
||||
try { } catch (e) {
|
||||
var x;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
function x() { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(2,22): error TS2300: Duplicate identifier 'I'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(5,18): error TS2300: Duplicate identifier 'I'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(9,21): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(12,18): error TS2300: Duplicate identifier 'f'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(37,12): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts (3 errors) ====
|
||||
==== tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts (6 errors) ====
|
||||
module M {
|
||||
export interface I { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'I'.
|
||||
}
|
||||
module M {
|
||||
export class I { } // error
|
||||
@@ -15,6 +20,8 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er
|
||||
|
||||
module M {
|
||||
export function f() { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'f'.
|
||||
}
|
||||
module M {
|
||||
export class f { } // error
|
||||
@@ -45,6 +52,8 @@ tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts(41,16): er
|
||||
|
||||
class Foo {
|
||||
static x: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
}
|
||||
|
||||
module Foo {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/duplicateInterfaceMembers1.ts(2,4): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicateInterfaceMembers1.ts(3,4): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateInterfaceMembers1.ts (1 errors) ====
|
||||
==== tests/cases/compiler/duplicateInterfaceMembers1.ts (2 errors) ====
|
||||
interface Bar {
|
||||
x: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
x: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
@@ -2,16 +2,22 @@ tests/cases/compiler/duplicateObjectLiteralProperty.ts(14,9): error TS1056: Acce
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS1118: An object literal cannot have multiple get/set accessors with the same name.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(2,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(4,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(5,5): error TS2300: Duplicate identifier '\u0061'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(6,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(7,9): error TS2300: Duplicate identifier 'c'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(8,9): error TS2300: Duplicate identifier '"c"'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(14,9): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(15,9): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS2300: Duplicate identifier 'a'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (9 errors) ====
|
||||
==== tests/cases/compiler/duplicateObjectLiteralProperty.ts (13 errors) ====
|
||||
var x = {
|
||||
a: 1,
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
b: true, // OK
|
||||
a: 56, // Duplicate
|
||||
~
|
||||
@@ -23,6 +29,8 @@ tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS2300: Dupl
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
c: 1,
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'c'.
|
||||
"c": 56, // Duplicate
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '"c"'.
|
||||
@@ -34,9 +42,13 @@ tests/cases/compiler/duplicateObjectLiteralProperty.ts(16,9): error TS2300: Dupl
|
||||
get a() { return 0; },
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
set a(v: number) { },
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
get a() { return 0; }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS1117: An object literal cannot have multiple properties with the same name in strict mode.
|
||||
tests/cases/compiler/duplicatePropertiesInStrictMode.ts(3,3): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/duplicatePropertiesInStrictMode.ts(4,3): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicatePropertiesInStrictMode.ts (2 errors) ====
|
||||
==== tests/cases/compiler/duplicatePropertiesInStrictMode.ts (3 errors) ====
|
||||
"use strict";
|
||||
var x = {
|
||||
x: 1,
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
x: 2
|
||||
~
|
||||
!!! error TS1117: An object literal cannot have multiple properties with the same name in strict mode.
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(4,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(5,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(14,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(15,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(19,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(20,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(22,5): error TS2393: Duplicate function implementation.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(23,5): error TS2393: Duplicate function implementation.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(25,5): error TS2300: Duplicate identifier 'baz'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(26,5): error TS2300: Duplicate identifier 'baz'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(30,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(31,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(35,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(36,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(38,5): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(39,5): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(43,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(44,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(45,5): error TS2300: Duplicate identifier 'bar'.
|
||||
tests/cases/conformance/types/members/duplicatePropertyNames.ts(46,5): error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/members/duplicatePropertyNames.ts (10 errors) ====
|
||||
==== tests/cases/conformance/types/members/duplicatePropertyNames.ts (20 errors) ====
|
||||
// duplicate property names are an error in all types
|
||||
|
||||
interface Number {
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
@@ -27,6 +39,8 @@ tests/cases/conformance/types/members/duplicatePropertyNames.ts(46,5): error TS2
|
||||
|
||||
interface Array<T> {
|
||||
foo: T;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
foo: T;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
@@ -34,16 +48,22 @@ tests/cases/conformance/types/members/duplicatePropertyNames.ts(46,5): error TS2
|
||||
|
||||
class C {
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
bar(x) { }
|
||||
~~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
bar(x) { }
|
||||
~~~~~~~~~~
|
||||
~~~
|
||||
!!! error TS2393: Duplicate function implementation.
|
||||
|
||||
baz = () => { }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'baz'.
|
||||
baz = () => { }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'baz'.
|
||||
@@ -51,6 +71,8 @@ tests/cases/conformance/types/members/duplicatePropertyNames.ts(46,5): error TS2
|
||||
|
||||
interface I {
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
@@ -58,11 +80,15 @@ tests/cases/conformance/types/members/duplicatePropertyNames.ts(46,5): error TS2
|
||||
|
||||
var a: {
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
bar: () => {};
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
bar: () => {};
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
@@ -70,10 +96,14 @@ tests/cases/conformance/types/members/duplicatePropertyNames.ts(46,5): error TS2
|
||||
|
||||
var b = {
|
||||
foo: '',
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
foo: '',
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
bar: () => { },
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
bar: () => { }
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'bar'.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/duplicateStringNamedProperty1.ts(2,5): error TS2300: Duplicate identifier '"artist"'.
|
||||
tests/cases/compiler/duplicateStringNamedProperty1.ts(3,5): error TS2300: Duplicate identifier 'artist'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateStringNamedProperty1.ts (1 errors) ====
|
||||
==== tests/cases/compiler/duplicateStringNamedProperty1.ts (2 errors) ====
|
||||
export interface Album {
|
||||
"artist": string;
|
||||
~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '"artist"'.
|
||||
artist: string;
|
||||
~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'artist'.
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/enumGenericTypeClash.ts(1,7): error TS2300: Duplicate identifier 'X'.
|
||||
tests/cases/compiler/enumGenericTypeClash.ts(2,6): error TS2300: Duplicate identifier 'X'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumGenericTypeClash.ts (1 errors) ====
|
||||
==== tests/cases/compiler/enumGenericTypeClash.ts (2 errors) ====
|
||||
class X<A,B,C> { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'X'.
|
||||
enum X { MyVal }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'X'.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/compiler/enumIdenticalIdentifierValues.ts(2,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/compiler/enumIdenticalIdentifierValues.ts(3,5): error TS2300: Duplicate identifier '1.0'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/enumIdenticalIdentifierValues.ts (1 errors) ====
|
||||
==== tests/cases/compiler/enumIdenticalIdentifierValues.ts (2 errors) ====
|
||||
enum Enum {
|
||||
1,
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier '1'.
|
||||
1.0
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '1.0'.
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
tests/cases/compiler/es6ClassTest9.ts(1,18): error TS1005: '{' expected.
|
||||
tests/cases/compiler/es6ClassTest9.ts(1,19): error TS1109: Expression expected.
|
||||
tests/cases/compiler/es6ClassTest9.ts(1,15): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/compiler/es6ClassTest9.ts(2,10): error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es6ClassTest9.ts (3 errors) ====
|
||||
==== tests/cases/compiler/es6ClassTest9.ts (4 errors) ====
|
||||
declare class foo();
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
function foo() {}
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/compiler/exportSameNameFuncVar.ts(1,12): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/exportSameNameFuncVar.ts(2,17): error TS2300: Duplicate identifier 'a'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/exportSameNameFuncVar.ts (1 errors) ====
|
||||
==== tests/cases/compiler/exportSameNameFuncVar.ts (2 errors) ====
|
||||
export var a = 10;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
export function a() {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
tests/cases/compiler/extension.ts(16,5): error TS1128: Declaration or statement expected.
|
||||
tests/cases/compiler/extension.ts(16,22): error TS1005: ';' expected.
|
||||
tests/cases/compiler/extension.ts(10,18): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/compiler/extension.ts(16,12): error TS2304: Cannot find name 'extension'.
|
||||
tests/cases/compiler/extension.ts(16,28): error TS2300: Duplicate identifier 'C'.
|
||||
tests/cases/compiler/extension.ts(22,3): error TS2339: Property 'pe' does not exist on type 'C'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/extension.ts (5 errors) ====
|
||||
==== tests/cases/compiler/extension.ts (6 errors) ====
|
||||
interface I {
|
||||
x;
|
||||
}
|
||||
@@ -16,6 +17,8 @@ tests/cases/compiler/extension.ts(22,3): error TS2339: Property 'pe' does not ex
|
||||
|
||||
declare module M {
|
||||
export class C {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'C'.
|
||||
public p:number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
tests/cases/compiler/fieldAndGetterWithSameName.ts(3,7): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/fieldAndGetterWithSameName.ts(2,5): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/compiler/fieldAndGetterWithSameName.ts(3,7): error TS2300: Duplicate identifier 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/fieldAndGetterWithSameName.ts (2 errors) ====
|
||||
==== tests/cases/compiler/fieldAndGetterWithSameName.ts (3 errors) ====
|
||||
export class C {
|
||||
x: number;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
get x(): number { return 1; }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user