mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into tupleConformance
This commit is contained in:
@@ -57,7 +57,8 @@ var servicesSources = [
|
||||
"services.ts",
|
||||
"shims.ts",
|
||||
"signatureHelp.ts",
|
||||
"utilities.ts"
|
||||
"utilities.ts",
|
||||
"navigationBar.ts"
|
||||
].map(function (f) {
|
||||
return path.join(servicesDirectory, f);
|
||||
}));
|
||||
|
||||
@@ -337,7 +337,7 @@ module ts {
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
if (isExternalModule(<SourceFile>node)) {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + getModuleNameFromFilename((<SourceFile>node).filename) + '"');
|
||||
bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((<SourceFile>node).filename) + '"');
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
+37
-92
@@ -2575,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;
|
||||
}
|
||||
|
||||
@@ -5050,10 +5050,21 @@ module ts {
|
||||
if (leftType.flags & (TypeFlags.Undefined | TypeFlags.Null)) leftType = rightType;
|
||||
if (rightType.flags & (TypeFlags.Undefined | TypeFlags.Null)) rightType = leftType;
|
||||
|
||||
var leftOk = checkArithmeticOperandType(node.left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
|
||||
var rightOk = checkArithmeticOperandType(node.right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
|
||||
if (leftOk && rightOk) {
|
||||
checkAssignmentOperator(numberType);
|
||||
var suggestedOperator: SyntaxKind;
|
||||
// if a user tries to apply a bitwise operator to 2 boolean operands
|
||||
// try and return them a helpful suggestion
|
||||
if ((leftType.flags & TypeFlags.Boolean) &&
|
||||
(rightType.flags & TypeFlags.Boolean) &&
|
||||
(suggestedOperator = getSuggestedBooleanOperator(node.operator)) !== undefined) {
|
||||
error(node, Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, tokenToString(node.operator), tokenToString(suggestedOperator));
|
||||
}
|
||||
else {
|
||||
// otherwise just check each operand separately and report errors as normal
|
||||
var leftOk = checkArithmeticOperandType(node.left, leftType, Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
|
||||
var rightOk = checkArithmeticOperandType(node.right, rightType, Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type);
|
||||
if (leftOk && rightOk) {
|
||||
checkAssignmentOperator(numberType);
|
||||
}
|
||||
}
|
||||
|
||||
return numberType;
|
||||
@@ -5118,6 +5129,22 @@ module ts {
|
||||
case SyntaxKind.CommaToken:
|
||||
return rightType;
|
||||
}
|
||||
|
||||
function getSuggestedBooleanOperator(operator: SyntaxKind): SyntaxKind {
|
||||
switch (operator) {
|
||||
case SyntaxKind.BarToken:
|
||||
case SyntaxKind.BarEqualsToken:
|
||||
return SyntaxKind.BarBarToken;
|
||||
case SyntaxKind.CaretToken:
|
||||
case SyntaxKind.CaretEqualsToken:
|
||||
return SyntaxKind.ExclamationEqualsEqualsToken;
|
||||
case SyntaxKind.AmpersandToken:
|
||||
case SyntaxKind.AmpersandEqualsToken:
|
||||
return SyntaxKind.AmpersandAmpersandToken;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function checkAssignmentOperator(valueType: Type): void {
|
||||
if (fullTypeCheck && operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment) {
|
||||
@@ -5658,6 +5685,10 @@ module ts {
|
||||
var isConstructor = (symbol.flags & SymbolFlags.Constructor) !== 0;
|
||||
|
||||
function reportImplementationExpectedError(node: FunctionDeclaration): void {
|
||||
if (node.name && node.name.kind === SyntaxKind.Missing) {
|
||||
return;
|
||||
}
|
||||
|
||||
var seen = false;
|
||||
var subsequentNode = forEachChild(node.parent, c => {
|
||||
if (seen) {
|
||||
@@ -7099,23 +7130,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;
|
||||
@@ -7194,75 +7208,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;
|
||||
@@ -7516,7 +7461,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;
|
||||
}
|
||||
|
||||
+40
-5
@@ -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;
|
||||
@@ -535,6 +533,43 @@ module ts {
|
||||
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
|
||||
}
|
||||
|
||||
var supportedExtensions = [".d.ts", ".ts", ".js"];
|
||||
|
||||
export function removeFileExtension(path: string): string {
|
||||
for (var i = 0; i < supportedExtensions.length; i++) {
|
||||
var ext = supportedExtensions[i];
|
||||
|
||||
if (fileExtensionIs(path, ext)) {
|
||||
return path.substr(0, path.length - ext.length);
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\\\u2028\u2029\u0085]/g;
|
||||
var escapedCharsMap: Map<string> = {
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
"\f": "\\f",
|
||||
"\b": "\\b",
|
||||
"\0": "\\0",
|
||||
"\r": "\\r",
|
||||
"\n": "\\n",
|
||||
"\"": "\\\"",
|
||||
"\u2028": "\\u2028", // lineSeparator
|
||||
"\u2029": "\\u2029", // paragraphSeparator
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
};
|
||||
|
||||
/** NOTE: This *does not* support the full escape characters, it only supports the subset that can be used in file names
|
||||
* or string literals. If the information encoded in the map changes, this needs to be revisited. */
|
||||
export function escapeString(s: string): string {
|
||||
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, c => {
|
||||
return escapedCharsMap[c] || c;
|
||||
}) : s;
|
||||
}
|
||||
|
||||
export interface ObjectAllocator {
|
||||
getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
|
||||
|
||||
@@ -261,6 +261,7 @@ module ts {
|
||||
Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." },
|
||||
Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." },
|
||||
Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." },
|
||||
The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
|
||||
@@ -1036,6 +1036,10 @@
|
||||
"category": "Error",
|
||||
"code": 2446
|
||||
},
|
||||
"The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead.": {
|
||||
"category": "Error",
|
||||
"code": 2447
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
+4
-27
@@ -56,10 +56,10 @@ module ts {
|
||||
|
||||
function getOwnEmitOutputFilePath(sourceFile: SourceFile, extension: string) {
|
||||
if (compilerOptions.outDir) {
|
||||
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
|
||||
var emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
|
||||
}
|
||||
else {
|
||||
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(sourceFile.filename);
|
||||
var emitOutputFilePathWithoutExtension = removeFileExtension(sourceFile.filename);
|
||||
}
|
||||
|
||||
return emitOutputFilePathWithoutExtension + extension;
|
||||
@@ -591,21 +591,6 @@ module ts {
|
||||
recordSourceMapSpan(comment.end);
|
||||
}
|
||||
|
||||
var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g;
|
||||
var escapedCharsMap: Map<string> = {
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
"\f": "\\f",
|
||||
"\b": "\\b",
|
||||
"\0": "\\0",
|
||||
"\r": "\\r",
|
||||
"\n": "\\n",
|
||||
"\"": "\\\"",
|
||||
"\u2028": "\\u2028", // lineSeparator
|
||||
"\u2029": "\\u2029", // paragraphSeparator
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
};
|
||||
|
||||
function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string) {
|
||||
if (typeof JSON !== "undefined") {
|
||||
return JSON.stringify({
|
||||
@@ -620,14 +605,6 @@ module ts {
|
||||
|
||||
return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}";
|
||||
|
||||
/** This does not support the full escape characters, it only supports the subset that can be used in file names
|
||||
* or string literals. If the information encoded in the map changes, this needs to be revisited. */
|
||||
function escapeString(s: string): string {
|
||||
return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, c => {
|
||||
return escapedCharsMap[c] || c;
|
||||
}) : s;
|
||||
}
|
||||
|
||||
function serializeStringArray(list: string[]): string {
|
||||
var output = "";
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
@@ -3164,7 +3141,7 @@ module ts {
|
||||
? referencedFile.filename // Declaration file, use declaration file name
|
||||
: shouldEmitToOwnFile(referencedFile, compilerOptions)
|
||||
? getOwnEmitOutputFilePath(referencedFile, ".d.ts") // Own output file so get the .d.ts file
|
||||
: getModuleNameFromFilename(compilerOptions.out) + ".d.ts";// Global out file
|
||||
: removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file
|
||||
|
||||
declFileName = getRelativePathToDirectoryOrUrl(
|
||||
getDirectoryPath(normalizeSlashes(jsFilePath)),
|
||||
@@ -3237,7 +3214,7 @@ module ts {
|
||||
}
|
||||
});
|
||||
declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos);
|
||||
writeFile(getModuleNameFromFilename(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
|
||||
writeFile(removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+102
-16
@@ -17,22 +17,11 @@ module ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
var moduleExtensions = [".d.ts", ".ts", ".js"];
|
||||
|
||||
interface ReferenceComments {
|
||||
referencedFiles: FileReference[];
|
||||
amdDependencies: string[];
|
||||
}
|
||||
|
||||
export function getModuleNameFromFilename(filename: string) {
|
||||
for (var i = 0; i < moduleExtensions.length; i++) {
|
||||
var ext = moduleExtensions[i];
|
||||
var len = filename.length - ext.length;
|
||||
if (len > 0 && filename.substr(len) === ext) return filename.substr(0, len);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
export function getSourceFileOfNode(node: Node): SourceFile {
|
||||
while (node && node.kind !== SyntaxKind.SourceFile) node = node.parent;
|
||||
return <SourceFile>node;
|
||||
@@ -54,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);
|
||||
}
|
||||
@@ -75,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 {
|
||||
@@ -402,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;
|
||||
@@ -1013,7 +1096,10 @@ module ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
error(Diagnostics.Identifier_expected);
|
||||
return <Identifier>createMissingNode();
|
||||
|
||||
var node = <Identifier>createMissingNode();
|
||||
node.text = "";
|
||||
return node;
|
||||
}
|
||||
|
||||
function parseIdentifier(): Identifier {
|
||||
@@ -2951,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);
|
||||
|
||||
|
||||
+48
-16
@@ -758,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) {
|
||||
@@ -772,40 +776,68 @@ 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);
|
||||
@@ -1576,7 +1608,7 @@ module FourSlash {
|
||||
|
||||
private verifyClassifications(expected: { classificationType: string; text: string }[], actual: ts.ClassifiedSpan[]) {
|
||||
if (actual.length !== expected.length) {
|
||||
this.raiseError('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++) {
|
||||
@@ -1585,7 +1617,7 @@ module FourSlash {
|
||||
|
||||
var expectedType: string = (<any>ts.ClassificationTypeNames)[expectedClassification.classificationType];
|
||||
if (expectedType !== actualClassification.classificationType) {
|
||||
this.raiseError('verifySyntacticClassification failed - expected classifications type to be ' +
|
||||
this.raiseError('verifyClassifications failed - expected classifications type to be ' +
|
||||
expectedType + ', but was ' +
|
||||
actualClassification.classificationType);
|
||||
}
|
||||
@@ -1593,7 +1625,7 @@ module FourSlash {
|
||||
var actualSpan = actualClassification.textSpan;
|
||||
var actualText = this.activeFile.content.substr(actualSpan.start(), actualSpan.length());
|
||||
if (expectedClassification.text !== actualText) {
|
||||
this.raiseError('verifySyntacticClassification failed - expected classificatied text to be ' +
|
||||
this.raiseError('verifyClassifications failed - expected classificatied text to be ' +
|
||||
expectedClassification.text + ', but was ' +
|
||||
actualText);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,363 +0,0 @@
|
||||
|
||||
module TypeScript.Services {
|
||||
export class NavigationBarItemGetter {
|
||||
private hasGlobalNode = false;
|
||||
|
||||
private getIndent(node: ISyntaxNode): number {
|
||||
var indent = this.hasGlobalNode ? 1 : 0;
|
||||
|
||||
var current = node.parent;
|
||||
while (current != null) {
|
||||
if (current.kind() == SyntaxKind.ModuleDeclaration || current.kind() === SyntaxKind.FunctionDeclaration) {
|
||||
indent++;
|
||||
}
|
||||
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
return indent;
|
||||
}
|
||||
|
||||
private getKindModifiers(modifiers: TypeScript.ISyntaxToken[]): string {
|
||||
var result: string[] = [];
|
||||
|
||||
for (var i = 0, n = modifiers.length; i < n; i++) {
|
||||
result.push(modifiers[i].text());
|
||||
}
|
||||
|
||||
return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
public getItems(node: TypeScript.SourceUnitSyntax): ts.NavigationBarItem[] {
|
||||
return this.getItemsWorker(() => this.getTopLevelNodes(node), n => this.createTopLevelItem(n));
|
||||
}
|
||||
|
||||
private getChildNodes(nodes: IModuleElementSyntax[]): ISyntaxNode[] {
|
||||
var childNodes: ISyntaxNode[] = [];
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var node = <ISyntaxNode>nodes[i];
|
||||
|
||||
if (node.kind() === SyntaxKind.FunctionDeclaration) {
|
||||
childNodes.push(node);
|
||||
}
|
||||
else if (node.kind() === SyntaxKind.VariableStatement) {
|
||||
var variableDeclaration = (<VariableStatementSyntax>node).variableDeclaration;
|
||||
childNodes.push.apply(childNodes, variableDeclaration.variableDeclarators);
|
||||
}
|
||||
}
|
||||
|
||||
return childNodes;
|
||||
}
|
||||
|
||||
private getTopLevelNodes(node: SourceUnitSyntax): ISyntaxNode[] {
|
||||
var topLevelNodes: ISyntaxNode[] = [];
|
||||
topLevelNodes.push(node);
|
||||
|
||||
this.addTopLevelNodes(node.moduleElements, topLevelNodes);
|
||||
|
||||
return topLevelNodes;
|
||||
}
|
||||
|
||||
private addTopLevelNodes(nodes: IModuleElementSyntax[], topLevelNodes: ISyntaxNode[]): void {
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var node = nodes[i];
|
||||
switch (node.kind()) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
topLevelNodes.push(node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
var moduleDeclaration = <ModuleDeclarationSyntax>node;
|
||||
topLevelNodes.push(node);
|
||||
this.addTopLevelNodes(moduleDeclaration.moduleElements, topLevelNodes);
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionDeclarationSyntax>node;
|
||||
if (this.isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
topLevelNodes.push(node);
|
||||
this.addTopLevelNodes(functionDeclaration.block.statements, topLevelNodes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public isTopLevelFunctionDeclaration(functionDeclaration: FunctionDeclarationSyntax) {
|
||||
// A function declaration is 'top level' if it contains any function declarations
|
||||
// within it.
|
||||
return functionDeclaration.block && ArrayUtilities.any(functionDeclaration.block.statements, s => s.kind() === SyntaxKind.FunctionDeclaration);
|
||||
}
|
||||
|
||||
private getItemsWorker(getNodes: () => ISyntaxNode[], createItem: (n: ISyntaxNode) => ts.NavigationBarItem): ts.NavigationBarItem[] {
|
||||
var items: ts.NavigationBarItem[] = [];
|
||||
|
||||
var keyToItem = createIntrinsicsObject<ts.NavigationBarItem>();
|
||||
|
||||
var nodes = getNodes();
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var child = nodes[i];
|
||||
var item = createItem(child);
|
||||
if (item != null) {
|
||||
if (item.text.length > 0) {
|
||||
var key = item.text + "-" + item.kind;
|
||||
|
||||
var itemWithSameName = keyToItem[key];
|
||||
if (itemWithSameName) {
|
||||
// We had an item with the same name. Merge these items together.
|
||||
this.merge(itemWithSameName, item);
|
||||
}
|
||||
else {
|
||||
keyToItem[key] = item;
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private merge(target: ts.NavigationBarItem, source: ts.NavigationBarItem) {
|
||||
// First, add any spans in the source to the target.
|
||||
target.spans.push.apply(target.spans, source.spans);
|
||||
|
||||
if (source.childItems) {
|
||||
if (!target.childItems) {
|
||||
target.childItems = [];
|
||||
}
|
||||
|
||||
// Next, recursively merge or add any children in the source as appropriate.
|
||||
outer:
|
||||
for (var i = 0, n = source.childItems.length; i < n; i++) {
|
||||
var sourceChild = source.childItems[i];
|
||||
|
||||
for (var j = 0, m = target.childItems.length; j < m; j++) {
|
||||
var targetChild = target.childItems[j];
|
||||
|
||||
if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) {
|
||||
// Found a match. merge them.
|
||||
this.merge(targetChild, sourceChild);
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't find a match, just add this child to the list.
|
||||
target.childItems.push(sourceChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getNavigationBarItem(text: string, kind: string, kindModifiers: string, spans: TypeScript.TextSpan[], childItems: ts.NavigationBarItem[]= [], indent: number = 0): ts.NavigationBarItem {
|
||||
return {
|
||||
text: text,
|
||||
kind: kind,
|
||||
kindModifiers: kindModifiers,
|
||||
spans: spans,
|
||||
childItems: childItems,
|
||||
indent: indent,
|
||||
bolded: false,
|
||||
grayed: false
|
||||
};
|
||||
}
|
||||
|
||||
private createChildItem(node: ISyntaxNode): ts.NavigationBarItem {
|
||||
switch (node.kind()) {
|
||||
case SyntaxKind.Parameter:
|
||||
var parameter = <ParameterSyntax>node;
|
||||
if (parameter.modifiers.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return this.getNavigationBarItem(parameter.identifier.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(parameter.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.MemberFunctionDeclaration:
|
||||
var memberFunction = <MemberFunctionDeclarationSyntax>node;
|
||||
return this.getNavigationBarItem(memberFunction.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, this.getKindModifiers(memberFunction.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
var getAccessor = <GetAccessorSyntax>node;
|
||||
return this.getNavigationBarItem(getAccessor.propertyName.text(), ts.ScriptElementKind.memberGetAccessorElement, this.getKindModifiers(getAccessor.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
var setAccessor = <SetAccessorSyntax>node;
|
||||
return this.getNavigationBarItem(setAccessor.propertyName.text(), ts.ScriptElementKind.memberSetAccessorElement, this.getKindModifiers(setAccessor.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
var indexSignature = <IndexSignatureSyntax>node;
|
||||
return this.getNavigationBarItem("[]", ts.ScriptElementKind.indexSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.EnumElement:
|
||||
var enumElement = <EnumElementSyntax>node;
|
||||
return this.getNavigationBarItem(enumElement.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
var callSignature = <CallSignatureSyntax>node;
|
||||
return this.getNavigationBarItem("()", ts.ScriptElementKind.callSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.ConstructSignature:
|
||||
var constructSignature = <ConstructSignatureSyntax>node;
|
||||
return this.getNavigationBarItem("new()", ts.ScriptElementKind.constructSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.MethodSignature:
|
||||
var methodSignature = <MethodSignatureSyntax>node;
|
||||
return this.getNavigationBarItem(methodSignature.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.PropertySignature:
|
||||
var propertySignature = <PropertySignatureSyntax>node;
|
||||
return this.getNavigationBarItem(propertySignature.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionDeclarationSyntax>node;
|
||||
if (!this.isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
return this.getNavigationBarItem(functionDeclaration.identifier.text(), ts.ScriptElementKind.functionElement, this.getKindModifiers(functionDeclaration.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.MemberVariableDeclaration:
|
||||
var memberVariableDeclaration = <MemberVariableDeclarationSyntax>node;
|
||||
return this.getNavigationBarItem(memberVariableDeclaration.variableDeclarator.propertyName.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(memberVariableDeclaration.modifiers), [TextSpan.fromBounds(start(memberVariableDeclaration.variableDeclarator), end(memberVariableDeclaration.variableDeclarator))]);
|
||||
|
||||
case SyntaxKind.VariableDeclarator:
|
||||
var variableDeclarator = <VariableDeclaratorSyntax>node;
|
||||
return this.getNavigationBarItem(variableDeclarator.propertyName.text(), ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(variableDeclarator), end(variableDeclarator))]);
|
||||
|
||||
case SyntaxKind.ConstructorDeclaration:
|
||||
var constructorDeclaration = <ConstructorDeclarationSyntax>node;
|
||||
return this.getNavigationBarItem("constructor", ts.ScriptElementKind.constructorImplementationElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private createTopLevelItem(node: ISyntaxNode): ts.NavigationBarItem {
|
||||
switch (node.kind()) {
|
||||
case SyntaxKind.SourceUnit:
|
||||
return this.createSourceUnitItem(<SourceUnitSyntax>node);
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return this.createClassItem(<ClassDeclarationSyntax>node);
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return this.createEnumItem(<EnumDeclarationSyntax>node);
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return this.createIterfaceItem(<InterfaceDeclarationSyntax>node);
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return this.createModuleItem(<ModuleDeclarationSyntax>node);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return this.createFunctionItem(<FunctionDeclarationSyntax>node);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private getModuleNames(node: TypeScript.ModuleDeclarationSyntax): string[] {
|
||||
var result: string[] = [];
|
||||
|
||||
if (node.stringLiteral) {
|
||||
result.push(node.stringLiteral.text());
|
||||
}
|
||||
else {
|
||||
this.getModuleNamesHelper(node.name, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private getModuleNamesHelper(name: TypeScript.INameSyntax, result: string[]): void {
|
||||
if (name.kind() === TypeScript.SyntaxKind.QualifiedName) {
|
||||
var qualifiedName = <TypeScript.QualifiedNameSyntax>name;
|
||||
this.getModuleNamesHelper(qualifiedName.left, result);
|
||||
result.push(qualifiedName.right.text());
|
||||
}
|
||||
else {
|
||||
result.push((<TypeScript.ISyntaxToken>name).text());
|
||||
}
|
||||
}
|
||||
|
||||
private createModuleItem(node: ModuleDeclarationSyntax): ts.NavigationBarItem {
|
||||
var moduleNames = this.getModuleNames(node);
|
||||
|
||||
var childItems = this.getItemsWorker(() => this.getChildNodes(node.moduleElements), n => this.createChildItem(n));
|
||||
|
||||
return this.getNavigationBarItem(moduleNames.join("."),
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
childItems,
|
||||
this.getIndent(node));
|
||||
}
|
||||
|
||||
private createFunctionItem(node: FunctionDeclarationSyntax) {
|
||||
var childItems = this.getItemsWorker(() => node.block.statements, n => this.createChildItem(n));
|
||||
|
||||
return this.getNavigationBarItem(node.identifier.text(),
|
||||
ts.ScriptElementKind.functionElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
childItems,
|
||||
this.getIndent(node));
|
||||
}
|
||||
|
||||
private createSourceUnitItem(node: SourceUnitSyntax): ts.NavigationBarItem {
|
||||
var childItems = this.getItemsWorker(() => this.getChildNodes(node.moduleElements), n => this.createChildItem(n));
|
||||
|
||||
if (childItems === null || childItems.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
this.hasGlobalNode = true;
|
||||
return this.getNavigationBarItem("<global>",
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
ts.ScriptElementKindModifier.none,
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
childItems);
|
||||
}
|
||||
|
||||
private createClassItem(node: ClassDeclarationSyntax): ts.NavigationBarItem {
|
||||
var constructor = <ConstructorDeclarationSyntax>ArrayUtilities.firstOrDefault(
|
||||
node.classElements, n => n.kind() === SyntaxKind.ConstructorDeclaration);
|
||||
|
||||
// Add the constructor parameters in as children of hte class (for property parameters).
|
||||
var nodes: ISyntaxNode[] = constructor
|
||||
? (<ISyntaxNode[]>constructor.callSignature.parameterList.parameters).concat(node.classElements)
|
||||
: node.classElements;
|
||||
|
||||
var childItems = this.getItemsWorker(() => nodes, n => this.createChildItem(n));
|
||||
return this.getNavigationBarItem(
|
||||
node.identifier.text(),
|
||||
ts.ScriptElementKind.classElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
childItems,
|
||||
this.getIndent(node));
|
||||
}
|
||||
|
||||
private createEnumItem(node: TypeScript.EnumDeclarationSyntax): ts.NavigationBarItem {
|
||||
var childItems = this.getItemsWorker(() => node.enumElements, n => this.createChildItem(n));
|
||||
return this.getNavigationBarItem(
|
||||
node.identifier.text(),
|
||||
ts.ScriptElementKind.enumElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
childItems,
|
||||
this.getIndent(node));
|
||||
}
|
||||
|
||||
private createIterfaceItem(node: TypeScript.InterfaceDeclarationSyntax): ts.NavigationBarItem {
|
||||
var childItems = this.getItemsWorker(() => node.body.typeMembers, n => this.createChildItem(n));
|
||||
return this.getNavigationBarItem(
|
||||
node.identifier.text(),
|
||||
ts.ScriptElementKind.interfaceElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
childItems,
|
||||
this.getIndent(node));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
/// <reference path='services.ts' />
|
||||
/// <reference path="text/textSpan.ts" />
|
||||
|
||||
module ts.NavigationBar {
|
||||
export function getNavigationBarItems(sourceFile: SourceFile): ts.NavigationBarItem[] {
|
||||
// If the source file has any child items, then it included in the tree
|
||||
// and takes lexical ownership of all other top-level items.
|
||||
var hasGlobalNode = false;
|
||||
|
||||
return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem);
|
||||
|
||||
function getIndent(node: Node): number {
|
||||
// If we have a global node in the tree,
|
||||
// then it adds an extra layer of depth to all subnodes.
|
||||
var indent = hasGlobalNode ? 1 : 0;
|
||||
|
||||
var current = node.parent;
|
||||
while (current) {
|
||||
switch (current.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
// If we have a module declared as A.B.C, it is more "intuitive"
|
||||
// to say it only has a single layer of depth
|
||||
do {
|
||||
current = current.parent;
|
||||
} while (current.kind === SyntaxKind.ModuleDeclaration);
|
||||
|
||||
// fall through
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
indent++;
|
||||
}
|
||||
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
return indent;
|
||||
}
|
||||
|
||||
function getChildNodes(nodes: Node[]): Node[] {
|
||||
var childNodes: Node[] = [];
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var node = nodes[i];
|
||||
|
||||
if (node.kind === SyntaxKind.FunctionDeclaration) {
|
||||
childNodes.push(node);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.VariableStatement) {
|
||||
childNodes.push.apply(childNodes, (<VariableStatement>node).declarations);
|
||||
}
|
||||
}
|
||||
|
||||
return childNodes;
|
||||
}
|
||||
|
||||
function getTopLevelNodes(node: SourceFile): Node[] {
|
||||
var topLevelNodes: Node[] = [];
|
||||
topLevelNodes.push(node);
|
||||
|
||||
addTopLevelNodes(node.statements, topLevelNodes);
|
||||
|
||||
return topLevelNodes;
|
||||
}
|
||||
|
||||
function addTopLevelNodes(nodes: Node[], topLevelNodes: Node[]): void {
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var node = nodes[i];
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
topLevelNodes.push(node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
var moduleDeclaration = <ModuleDeclaration>node;
|
||||
topLevelNodes.push(node);
|
||||
addTopLevelNodes((<Block>getInnermostModule(moduleDeclaration).body).statements, topLevelNodes);
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionDeclaration>node;
|
||||
if (isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
topLevelNodes.push(node);
|
||||
addTopLevelNodes((<Block>functionDeclaration.body).statements, topLevelNodes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isTopLevelFunctionDeclaration(functionDeclaration: FunctionDeclaration) {
|
||||
// A function declaration is 'top level' if it contains any function declarations
|
||||
// within it.
|
||||
return functionDeclaration.kind === SyntaxKind.FunctionDeclaration &&
|
||||
functionDeclaration.body &&
|
||||
functionDeclaration.body.kind === SyntaxKind.FunctionBlock &&
|
||||
forEach((<Block>functionDeclaration.body).statements, s => s.kind === SyntaxKind.FunctionDeclaration);
|
||||
}
|
||||
|
||||
function getItemsWorker(nodes: Node[], createItem: (n: Node) => ts.NavigationBarItem): ts.NavigationBarItem[] {
|
||||
var items: ts.NavigationBarItem[] = [];
|
||||
|
||||
var keyToItem: Map<NavigationBarItem> = {};
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var child = nodes[i];
|
||||
var item = createItem(child);
|
||||
if (item !== undefined) {
|
||||
if (item.text.length > 0) {
|
||||
var key = item.text + "-" + item.kind;
|
||||
|
||||
var itemWithSameName = keyToItem[key];
|
||||
if (itemWithSameName) {
|
||||
// We had an item with the same name. Merge these items together.
|
||||
merge(itemWithSameName, item);
|
||||
}
|
||||
else {
|
||||
keyToItem[key] = item;
|
||||
items.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function merge(target: ts.NavigationBarItem, source: ts.NavigationBarItem) {
|
||||
// First, add any spans in the source to the target.
|
||||
target.spans.push.apply(target.spans, source.spans);
|
||||
|
||||
if (source.childItems) {
|
||||
if (!target.childItems) {
|
||||
target.childItems = [];
|
||||
}
|
||||
|
||||
// Next, recursively merge or add any children in the source as appropriate.
|
||||
outer:
|
||||
for (var i = 0, n = source.childItems.length; i < n; i++) {
|
||||
var sourceChild = source.childItems[i];
|
||||
|
||||
for (var j = 0, m = target.childItems.length; j < m; j++) {
|
||||
var targetChild = target.childItems[j];
|
||||
|
||||
if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) {
|
||||
// Found a match. merge them.
|
||||
merge(targetChild, sourceChild);
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't find a match, just add this child to the list.
|
||||
target.childItems.push(sourceChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createChildItem(node: Node): ts.NavigationBarItem {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Parameter:
|
||||
var parameter = <ParameterDeclaration>node;
|
||||
if ((node.flags & NodeFlags.Modifier) === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return createItem(node, getTextOfNode(parameter.name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.Method:
|
||||
var method = <MethodDeclaration>node;
|
||||
return createItem(node, getTextOfNode(method.name), ts.ScriptElementKind.memberFunctionElement);
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
var getAccessor = <AccessorDeclaration>node;
|
||||
return createItem(node, getTextOfNode(getAccessor.name), ts.ScriptElementKind.memberGetAccessorElement);
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
var setAccessor = <AccessorDeclaration>node;
|
||||
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, getTextOfNode(enumMember.name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
return createItem(node, "()", ts.ScriptElementKind.callSignatureElement);
|
||||
|
||||
case SyntaxKind.ConstructSignature:
|
||||
return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement);
|
||||
|
||||
case SyntaxKind.Property:
|
||||
var property = <PropertyDeclaration>node;
|
||||
return createItem(node, getTextOfNode(property.name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionDeclaration>node;
|
||||
if (!isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
return createItem(node, getTextOfNode(functionDeclaration.name), ts.ScriptElementKind.functionElement);
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
var variableDeclaration = <VariableDeclaration>node;
|
||||
return createItem(node, getTextOfNode(variableDeclaration.name), ts.ScriptElementKind.variableElement);
|
||||
|
||||
case SyntaxKind.Constructor:
|
||||
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
function createItem(node: Node, name: string, scriptElementKind: string): NavigationBarItem {
|
||||
return getNavigationBarItem(name, scriptElementKind, getNodeModifiers(node), [getNodeSpan(node)]);
|
||||
}
|
||||
}
|
||||
|
||||
function getNavigationBarItem(text: string, kind: string, kindModifiers: string, spans: TypeScript.TextSpan[], childItems: ts.NavigationBarItem[] = [], indent: number = 0): ts.NavigationBarItem {
|
||||
return {
|
||||
text: text,
|
||||
kind: kind,
|
||||
kindModifiers: kindModifiers,
|
||||
spans: spans,
|
||||
childItems: childItems,
|
||||
indent: indent,
|
||||
bolded: false,
|
||||
grayed: false
|
||||
};
|
||||
}
|
||||
|
||||
function createTopLevelItem(node: Node): ts.NavigationBarItem {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.SourceFile:
|
||||
return createSourceFileItem(<SourceFile>node);
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return createClassItem(<ClassDeclaration>node);
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return createEnumItem(<EnumDeclaration>node);
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return createIterfaceItem(<InterfaceDeclaration>node);
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return createModuleItem(<ModuleDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return createFunctionItem(<FunctionDeclaration>node);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
function getModuleName(moduleDeclaration: ModuleDeclaration): string {
|
||||
// We want to maintain quotation marks.
|
||||
if (moduleDeclaration.name.kind === SyntaxKind.StringLiteral) {
|
||||
return getTextOfNode(moduleDeclaration.name);
|
||||
}
|
||||
|
||||
// Otherwise, we need to aggregate each identifier to build up the qualified name.
|
||||
var result: string[] = [];
|
||||
|
||||
result.push(moduleDeclaration.name.text);
|
||||
|
||||
while (moduleDeclaration.body && moduleDeclaration.body.kind === SyntaxKind.ModuleDeclaration) {
|
||||
moduleDeclaration = <ModuleDeclaration>moduleDeclaration.body;
|
||||
|
||||
result.push(moduleDeclaration.name.text);
|
||||
}
|
||||
|
||||
return result.join(".");
|
||||
}
|
||||
|
||||
function createModuleItem(node: ModuleDeclaration): NavigationBarItem {
|
||||
var moduleName = getModuleName(node);
|
||||
|
||||
var childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
|
||||
|
||||
return getNavigationBarItem(moduleName,
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
childItems,
|
||||
getIndent(node));
|
||||
}
|
||||
|
||||
function createFunctionItem(node: FunctionDeclaration) {
|
||||
if (node.name && node.body && node.body.kind === SyntaxKind.FunctionBlock) {
|
||||
var childItems = getItemsWorker((<Block>node.body).statements, createChildItem);
|
||||
|
||||
return getNavigationBarItem(node.name.text,
|
||||
ts.ScriptElementKind.functionElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
childItems,
|
||||
getIndent(node));
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createSourceFileItem(node: SourceFile): ts.NavigationBarItem {
|
||||
var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
|
||||
|
||||
if (childItems === undefined || childItems.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
hasGlobalNode = true;
|
||||
var rootName = isExternalModule(node) ?
|
||||
"\"" + escapeString(getBaseFilename(removeFileExtension(normalizePath(node.filename)))) + "\"" :
|
||||
"<global>"
|
||||
|
||||
return getNavigationBarItem(rootName,
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
ts.ScriptElementKindModifier.none,
|
||||
[getNodeSpan(node)],
|
||||
childItems);
|
||||
}
|
||||
|
||||
function createClassItem(node: ClassDeclaration): ts.NavigationBarItem {
|
||||
var childItems: NavigationBarItem[];
|
||||
|
||||
if (node.members) {
|
||||
var constructor = <ConstructorDeclaration>forEach(node.members, member => {
|
||||
return member.kind === SyntaxKind.Constructor && member;
|
||||
});
|
||||
|
||||
// Add the constructor parameters in as children of the class (for property parameters).
|
||||
var nodes: Node[] = constructor
|
||||
? constructor.parameters.concat(node.members)
|
||||
: node.members;
|
||||
|
||||
var childItems = getItemsWorker(nodes, createChildItem);
|
||||
}
|
||||
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.classElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
childItems,
|
||||
getIndent(node));
|
||||
}
|
||||
|
||||
function createEnumItem(node: EnumDeclaration): ts.NavigationBarItem {
|
||||
var childItems = getItemsWorker(node.members, createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.enumElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
childItems,
|
||||
getIndent(node));
|
||||
}
|
||||
|
||||
function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
|
||||
var childItems = getItemsWorker(node.members, createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.interfaceElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
childItems,
|
||||
getIndent(node));
|
||||
}
|
||||
}
|
||||
|
||||
function getInnermostModule(node: ModuleDeclaration): ModuleDeclaration {
|
||||
while (node.body.kind === SyntaxKind.ModuleDeclaration) {
|
||||
node = <ModuleDeclaration>node.body;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function getNodeSpan(node: Node) {
|
||||
return TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd());
|
||||
}
|
||||
|
||||
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++;
|
||||
|
||||
+143
-36
@@ -6,7 +6,7 @@
|
||||
|
||||
/// <reference path='syntax\incrementalParser.ts' />
|
||||
/// <reference path='outliningElementsCollector.ts' />
|
||||
/// <reference path='getScriptLexicalStructureWalker.ts' />
|
||||
/// <reference path='navigationBar.ts' />
|
||||
/// <reference path='breakpoints.ts' />
|
||||
/// <reference path='indentation.ts' />
|
||||
/// <reference path='signatureHelp.ts' />
|
||||
@@ -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;
|
||||
@@ -1512,6 +1519,20 @@ module ts {
|
||||
}
|
||||
|
||||
/// Helpers
|
||||
export function getNodeModifiers(node: Node): string {
|
||||
var flags = node.flags;
|
||||
var result: string[] = [];
|
||||
|
||||
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||
if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
|
||||
if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier);
|
||||
if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
|
||||
if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
|
||||
return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
function getTargetLabel(referenceNode: Node, labelName: string): Identifier {
|
||||
while (referenceNode) {
|
||||
if (referenceNode.kind === SyntaxKind.LabeledStatement && (<LabeledStatement>referenceNode).label.text === labelName) {
|
||||
@@ -1650,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 {
|
||||
@@ -2348,20 +2369,6 @@ module ts {
|
||||
: ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
function getNodeModifiers(node: Node): string {
|
||||
var flags = node.flags;
|
||||
var result: string[] = [];
|
||||
|
||||
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||
if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
|
||||
if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier);
|
||||
if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier);
|
||||
if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier);
|
||||
if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier);
|
||||
|
||||
return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none;
|
||||
}
|
||||
|
||||
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
@@ -2630,7 +2637,7 @@ module ts {
|
||||
|
||||
if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword || node.kind === SyntaxKind.SuperKeyword ||
|
||||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) {
|
||||
return getReferencesForNode(node, [sourceFile]);
|
||||
return getReferencesForNode(node, [sourceFile], /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
@@ -3062,11 +3069,19 @@ 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 = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -3082,10 +3097,11 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return getReferencesForNode(node, program.getSourceFiles());
|
||||
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral);
|
||||
return getReferencesForNode(node, program.getSourceFiles(), findInStrings, findInComments);
|
||||
}
|
||||
|
||||
function getReferencesForNode(node: Node, sourceFiles: SourceFile[]): ReferenceEntry[] {
|
||||
function getReferencesForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
|
||||
// Labels
|
||||
if (isLabelName(node)) {
|
||||
if (isJumpStatementTarget(node)) {
|
||||
@@ -3135,7 +3151,7 @@ module ts {
|
||||
|
||||
if (scope) {
|
||||
result = [];
|
||||
getReferencesInNode(scope, symbol, symbolName, node, searchMeaning, result);
|
||||
getReferencesInNode(scope, symbol, symbolName, node, searchMeaning, findInStrings, findInComments, result);
|
||||
}
|
||||
else {
|
||||
forEach(sourceFiles, sourceFile => {
|
||||
@@ -3143,7 +3159,7 @@ module ts {
|
||||
|
||||
if (lookUp(sourceFile.identifiers, symbolName)) {
|
||||
result = result || [];
|
||||
getReferencesInNode(sourceFile, symbol, symbolName, node, searchMeaning, result);
|
||||
getReferencesInNode(sourceFile, symbol, symbolName, node, searchMeaning, findInStrings, findInComments, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -3295,8 +3311,16 @@ module ts {
|
||||
* tuple of(searchSymbol, searchText, searchLocation, and searchMeaning).
|
||||
* searchLocation: a node where the search value
|
||||
*/
|
||||
function getReferencesInNode(container: Node, searchSymbol: Symbol, searchText: string, searchLocation: Node, searchMeaning: SearchMeaning, result: ReferenceEntry[]): void {
|
||||
function getReferencesInNode(container: Node,
|
||||
searchSymbol: Symbol,
|
||||
searchText: string,
|
||||
searchLocation: Node,
|
||||
searchMeaning: SearchMeaning,
|
||||
findInStrings: boolean,
|
||||
findInComments: boolean,
|
||||
result: ReferenceEntry[]): void {
|
||||
var sourceFile = container.getSourceFile();
|
||||
var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*</
|
||||
|
||||
var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, container.getStart(), container.getEnd());
|
||||
|
||||
@@ -3309,6 +3333,17 @@ module ts {
|
||||
|
||||
var referenceLocation = getTouchingPropertyName(sourceFile, position);
|
||||
if (!isValidReferencePosition(referenceLocation, searchText)) {
|
||||
// This wasn't the start of a token. Check to see if it might be a
|
||||
// match in a comment or string if that's what the caller is asking
|
||||
// for.
|
||||
if ((findInStrings && isInString(position)) ||
|
||||
(findInComments && isInComment(position))) {
|
||||
result.push({
|
||||
fileName: sourceFile.filename,
|
||||
textSpan: new TypeScript.TextSpan(position, searchText.length),
|
||||
isWriteAccess: false
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3329,6 +3364,32 @@ module ts {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isInString(position: number) {
|
||||
var token = getTokenAtPosition(sourceFile, position);
|
||||
return token && token.kind === SyntaxKind.StringLiteral && position > token.getStart();
|
||||
}
|
||||
|
||||
function isInComment(position: number) {
|
||||
var token = getTokenAtPosition(sourceFile, position);
|
||||
if (token && position < token.getStart()) {
|
||||
// First, we have to see if this position actually landed in a comment.
|
||||
var commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
||||
|
||||
// Then we want to make sure that it wasn't in a "///<" directive comment
|
||||
// We don't want to unintentionally update a file name.
|
||||
return forEach(commentRanges, c => {
|
||||
if (c.pos < position && position < c.end) {
|
||||
var commentText = sourceFile.text.substring(c.pos, c.end);
|
||||
if (!tripleSlashDirectivePrefixRegex.test(commentText)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getReferencesForSuperKeyword(superKeyword: Node): ReferenceEntry[]{
|
||||
@@ -4027,10 +4088,10 @@ module ts {
|
||||
return TypeScript.Services.Breakpoints.getBreakpointLocation(syntaxtree, position);
|
||||
}
|
||||
|
||||
function getNavigationBarItems(filename: string) {
|
||||
function getNavigationBarItems(filename: string): NavigationBarItem[] {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
var syntaxTree = getSyntaxTree(filename);
|
||||
return new TypeScript.Services.NavigationBarItemGetter().getItems(syntaxTree.sourceUnit());
|
||||
|
||||
return NavigationBar.getNavigationBarItems(getCurrentSourceFile(filename));
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TypeScript.TextSpan): ClassifiedSpan[] {
|
||||
@@ -4044,7 +4105,7 @@ module ts {
|
||||
|
||||
return result;
|
||||
|
||||
function classifySymbol(symbol: Symbol) {
|
||||
function classifySymbol(symbol: Symbol, isInTypePosition: boolean) {
|
||||
var flags = symbol.getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Class) {
|
||||
@@ -4053,14 +4114,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4070,7 +4133,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()),
|
||||
@@ -4588,6 +4651,7 @@ module ts {
|
||||
getBreakpointStatementAtPosition: getBreakpointStatementAtPosition,
|
||||
getNavigateToItems: getNavigateToItems,
|
||||
getRenameInfo: getRenameInfo,
|
||||
findRenameLocations: findRenameLocations,
|
||||
getNavigationBarItems: getNavigationBarItems,
|
||||
getOutliningSpans: getOutliningSpans,
|
||||
getTodoComments: getTodoComments,
|
||||
@@ -4690,6 +4754,27 @@ module ts {
|
||||
entries: []
|
||||
};
|
||||
|
||||
// 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();
|
||||
|
||||
@@ -4709,6 +4794,28 @@ module ts {
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
@@ -369,6 +375,7 @@ module ts {
|
||||
if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(diagnosticMessagesJson);
|
||||
}
|
||||
@@ -649,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(
|
||||
|
||||
@@ -222,7 +222,7 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,8 +395,7 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(417,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(418,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(420,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(421,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(421,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(421,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(422,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(423,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(423,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -451,8 +450,7 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(474,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(475,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(477,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(478,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(478,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(478,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(479,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(480,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(480,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -507,8 +505,7 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(531,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(532,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(534,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(535,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(535,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(535,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(536,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(537,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(537,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -560,7 +557,7 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts(581,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts (560 errors) ====
|
||||
==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts (557 errors) ====
|
||||
// these operators require their operands to be of type Any, the Number primitive type, or
|
||||
// an enum type
|
||||
enum E { a, b, c }
|
||||
@@ -1776,10 +1773,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
var r8b2 = b & b;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8b3 = b & c;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -1945,10 +1940,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
var r9b2 = b ^ b;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9b3 = b ^ c;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -2114,10 +2107,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
var r10b2 = b | b;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10b3 = b | c;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
+37
-73
@@ -166,81 +166,69 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(129,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(130,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(137,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(138,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(146,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(147,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(154,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(155,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(163,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(164,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(171,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(172,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (240 errors) ====
|
||||
==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts (228 errors) ====
|
||||
// If one operand is the null or undefined value, it is treated as having the type of the
|
||||
// other operand.
|
||||
|
||||
@@ -705,10 +693,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
|
||||
// operator &
|
||||
var r8a1 = null & a;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8a2 = null & b;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -721,10 +707,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r8b1 = a & null;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8b2 = b & null;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -737,10 +721,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r8c1 = null & true;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8c2 = null & '';
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -753,10 +735,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r8d1 = true & null;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8d2 = '' & null;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -770,10 +750,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
|
||||
// operator ^
|
||||
var r9a1 = null ^ a;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9a2 = null ^ b;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -786,10 +764,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r9b1 = a ^ null;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9b2 = b ^ null;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -802,10 +778,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r9c1 = null ^ true;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9c2 = null ^ '';
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -818,10 +792,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r9d1 = true ^ null;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9d2 = '' ^ null;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -835,10 +807,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
|
||||
// operator |
|
||||
var r10a1 = null | a;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10a2 = null | b;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -851,10 +821,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r10b1 = a | null;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10b2 = b | null;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -867,10 +835,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r10c1 = null | true;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10c2 = null | '';
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -883,10 +849,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r10d1 = true | null;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10d2 = '' | null;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
+37
-73
@@ -166,81 +166,69 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(124,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(125,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(128,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(129,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(130,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(132,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(133,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(134,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(136,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(137,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(138,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(140,12): error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(141,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(142,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(145,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(146,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(147,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(149,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(150,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(151,16): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(153,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(154,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(155,24): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,19): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(157,12): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(158,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,12): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(159,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(162,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(163,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(164,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(166,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(167,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(168,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(170,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(171,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(172,25): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,20): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(174,13): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(175,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,13): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts(176,18): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (240 errors) ====
|
||||
==== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts (228 errors) ====
|
||||
// If one operand is the undefined or undefined value, it is treated as having the type of the
|
||||
// other operand.
|
||||
|
||||
@@ -705,10 +693,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
|
||||
// operator &
|
||||
var r8a1 = undefined & a;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8a2 = undefined & b;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -721,10 +707,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r8b1 = a & undefined;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8b2 = b & undefined;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -737,10 +721,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r8c1 = undefined & true;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8c2 = undefined & '';
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -753,10 +735,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r8d1 = true & undefined;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '&' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
var r8d2 = '' & undefined;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -770,10 +750,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
|
||||
// operator ^
|
||||
var r9a1 = undefined ^ a;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9a2 = undefined ^ b;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -786,10 +764,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r9b1 = a ^ undefined;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9b2 = b ^ undefined;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -802,10 +778,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r9c1 = undefined ^ true;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9c2 = undefined ^ '';
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -818,10 +792,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r9d1 = true ^ undefined;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
var r9d2 = '' ^ undefined;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -835,10 +807,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
|
||||
// operator |
|
||||
var r10a1 = undefined | a;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10a2 = undefined | b;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -851,10 +821,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r10b1 = a | undefined;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10b2 = b | undefined;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -867,10 +835,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r10c1 = undefined | true;
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10c2 = undefined | '';
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
@@ -883,10 +849,8 @@ tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeti
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var r10d1 = true | undefined;
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
var r10d2 = '' | undefined;
|
||||
~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(3,1): error TS2447: The '^=' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(9,6): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(14,1): error TS2447: The '&=' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(18,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(20,6): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(24,1): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts(28,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts (8 errors) ====
|
||||
var a = true;
|
||||
var b = 1;
|
||||
a ^= a;
|
||||
~~~~~~
|
||||
!!! error TS2447: The '^=' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
a = true;
|
||||
b ^= b;
|
||||
b = 1;
|
||||
a ^= b;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
a = true;
|
||||
b ^= a;
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
b = 1;
|
||||
|
||||
var c = false;
|
||||
var d = 2;
|
||||
c &= c;
|
||||
~~~~~~
|
||||
!!! error TS2447: The '&=' operator is not allowed for boolean types. Consider using '&&' instead.
|
||||
c = false;
|
||||
d &= d;
|
||||
d = 2;
|
||||
c &= d;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
c = false;
|
||||
d &= c;
|
||||
~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
|
||||
var e = true;
|
||||
var f = 0;
|
||||
e |= e;
|
||||
~~~~~~
|
||||
!!! error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead.
|
||||
e = true;
|
||||
f |= f;
|
||||
f = 0;
|
||||
e |= f;
|
||||
~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
e = true;
|
||||
f |= f;
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//// [bitwiseCompoundAssignmentOperators.ts]
|
||||
var a = true;
|
||||
var b = 1;
|
||||
a ^= a;
|
||||
a = true;
|
||||
b ^= b;
|
||||
b = 1;
|
||||
a ^= b;
|
||||
a = true;
|
||||
b ^= a;
|
||||
b = 1;
|
||||
|
||||
var c = false;
|
||||
var d = 2;
|
||||
c &= c;
|
||||
c = false;
|
||||
d &= d;
|
||||
d = 2;
|
||||
c &= d;
|
||||
c = false;
|
||||
d &= c;
|
||||
|
||||
var e = true;
|
||||
var f = 0;
|
||||
e |= e;
|
||||
e = true;
|
||||
f |= f;
|
||||
f = 0;
|
||||
e |= f;
|
||||
e = true;
|
||||
f |= f;
|
||||
|
||||
|
||||
|
||||
//// [bitwiseCompoundAssignmentOperators.js]
|
||||
var a = true;
|
||||
var b = 1;
|
||||
a ^= a;
|
||||
a = true;
|
||||
b ^= b;
|
||||
b = 1;
|
||||
a ^= b;
|
||||
a = true;
|
||||
b ^= a;
|
||||
b = 1;
|
||||
var c = false;
|
||||
var d = 2;
|
||||
c &= c;
|
||||
c = false;
|
||||
d &= d;
|
||||
d = 2;
|
||||
c &= d;
|
||||
c = false;
|
||||
d &= c;
|
||||
var e = true;
|
||||
var f = 0;
|
||||
e |= e;
|
||||
e = true;
|
||||
f |= f;
|
||||
f = 0;
|
||||
e |= f;
|
||||
e = true;
|
||||
f |= f;
|
||||
@@ -72,8 +72,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(89,23): error TS
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(108,24): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,31): error TS2304: Cannot find name 'Property'.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(166,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,40): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,47): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(213,16): error TS2304: Cannot find name 'bool'.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(218,29): error TS2304: Cannot find name 'yield'.
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(223,23): error TS2304: Cannot find name 'bool'.
|
||||
@@ -96,7 +95,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error T
|
||||
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (96 errors) ====
|
||||
==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (95 errors) ====
|
||||
declare module "fs" {
|
||||
export class File {
|
||||
constructor(filename: string);
|
||||
@@ -370,10 +369,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error T
|
||||
var i = a[1];/*[]*/
|
||||
i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/
|
||||
var b = true && false || true ^ false;/*& | ^*/
|
||||
~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~
|
||||
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
|
||||
b = !b;/*!*/
|
||||
i = ~i;/*~i*/
|
||||
b = i < (i - 1) && (i + 1) > i;/*< && >*/
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction1.ts(1,10): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction1.ts(1,9): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction1.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction1.ts (1 errors) ====
|
||||
function =>
|
||||
~~
|
||||
!!! error TS1003: Identifier expected.
|
||||
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
!!! error TS1003: Identifier expected.
|
||||
@@ -2,10 +2,9 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThan
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts(1,13): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts(1,17): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts(1,18): error TS1005: ')' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts(1,9): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts (5 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThanAfterFunction2.ts (4 errors) ====
|
||||
function (a => b;
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
@@ -14,6 +13,4 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserEqualsGreaterThan
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
|
||||
!!! error TS1005: ')' expected.
|
||||
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
!!! error TS1005: ')' expected.
|
||||
@@ -0,0 +1,31 @@
|
||||
var a = true;
|
||||
var b = 1;
|
||||
a ^= a;
|
||||
a = true;
|
||||
b ^= b;
|
||||
b = 1;
|
||||
a ^= b;
|
||||
a = true;
|
||||
b ^= a;
|
||||
b = 1;
|
||||
|
||||
var c = false;
|
||||
var d = 2;
|
||||
c &= c;
|
||||
c = false;
|
||||
d &= d;
|
||||
d = 2;
|
||||
c &= d;
|
||||
c = false;
|
||||
d &= c;
|
||||
|
||||
var e = true;
|
||||
var f = 0;
|
||||
e |= e;
|
||||
e = true;
|
||||
f |= f;
|
||||
f = 0;
|
||||
e |= f;
|
||||
e = true;
|
||||
f |= f;
|
||||
|
||||
@@ -240,7 +240,6 @@ module FourSlashInterface {
|
||||
}
|
||||
|
||||
export class verify extends verifyNegatable {
|
||||
|
||||
public caretAtMarker(markerName?: string) {
|
||||
FourSlash.currentTestState.verifyCaretAtMarker(markerName);
|
||||
}
|
||||
@@ -417,6 +416,10 @@ module FourSlashInterface {
|
||||
public renameInfoFailed(message?: string) {
|
||||
FourSlash.currentTestState.verifyRenameInfoFailed(message)
|
||||
}
|
||||
|
||||
public renameLocations(findInStrings: boolean, findInComments: boolean) {
|
||||
FourSlash.currentTestState.verifyRenameLocations(findInStrings, findInComments);
|
||||
}
|
||||
}
|
||||
|
||||
export class edit {
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
//// export var {| "itemName": "x", "kind": "var" |}x = 3;
|
||||
//// }
|
||||
|
||||
verify.getScriptLexicalStructureListCount(12);
|
||||
test.markers().forEach(marker => {
|
||||
if (marker.data) {
|
||||
verify.getScriptLexicalStructureListContains(
|
||||
@@ -39,3 +38,4 @@ test.markers().forEach(marker => {
|
||||
marker.position);
|
||||
}
|
||||
});
|
||||
verify.getScriptLexicalStructureListCount(12);
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
///////<reference path="./Bar.ts" />
|
||||
|
||||
////function /**/[|Bar|]() {
|
||||
//// // This is a reference to Bar in a comment.
|
||||
//// "this is a reference to Bar in a string"
|
||||
////}
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations(/*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
///////<reference path="./Bar.ts" />
|
||||
|
||||
////function /**/[|Bar|]() {
|
||||
//// // This is a reference to Bar in a comment.
|
||||
//// "this is a reference to [|Bar|] in a string"
|
||||
////}
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations(/*findInStrings:*/ true, /*findInComments:*/ false);
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
///////<reference path="./Bar.ts" />
|
||||
|
||||
////function /**/[|Bar|]() {
|
||||
//// // This is a reference to [|Bar|] in a comment.
|
||||
//// "this is a reference to Bar in a string"
|
||||
////}
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations(/*findInStrings:*/ false, /*findInComments:*/ true);
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
///////<reference path="./Bar.ts" />
|
||||
|
||||
////function /**/[|Bar|]() {
|
||||
//// // This is a reference to [|Bar|] in a comment.
|
||||
//// "this is a reference to [|Bar|] in a string"
|
||||
////}
|
||||
|
||||
goTo.marker();
|
||||
verify.renameLocations(/*findInStrings:*/ true, /*findInComments:*/ true);
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////{| "itemName": "<global>", "kind": "module" |}
|
||||
////
|
||||
////{| "itemName": "foo", "kind": "function" |}function foo() {
|
||||
//// var x = 10;
|
||||
//// {| "itemName": "bar", "kind": "function", "parentName": "foo" |}function bar() {
|
||||
//// var y = 10;
|
||||
//// {| "itemName": "biz", "kind": "function", "parentName": "bar" |}function biz() {
|
||||
//// var z = 10;
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "baz", "kind": "function", "parentName": "<global>" |}function baz() {
|
||||
//// var v = 10;
|
||||
////}
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(5); // 4 functions + global
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////{| "itemName": "f", "kind": "function" |}
|
||||
////function f() {
|
||||
//// function;
|
||||
////}
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(1); // 1 function - no global since the inner function thinks it has a declaration.
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////function;
|
||||
////{| "itemName": "f", "kind": "function" |}
|
||||
////function f() {
|
||||
//// function;
|
||||
////}
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(1); // 1 function with no global - the broken declaration adds nothing for us at the global scope.
|
||||
@@ -49,3 +49,4 @@ test.markers().forEach((marker) => {
|
||||
}
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(23);
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
////}
|
||||
////function bar() {
|
||||
////}
|
||||
debugger;
|
||||
|
||||
goTo.marker("file1");
|
||||
verify.getScriptLexicalStructureListCount(0);
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
|
||||
////}
|
||||
|
||||
verify.getScriptLexicalStructureListCount(2); // external module node + class + property
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(2); // external module node + class + property
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// @Filename: test/file.ts
|
||||
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
|
||||
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
|
||||
////}
|
||||
////{| "itemName": "\"file\"", "kind": "module" |}
|
||||
////{| "itemName": "x", "kind": "var", "parentName": "\"file\"" |}
|
||||
////export var x: number;
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(4); // external module node + variable in module + class + property
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// @Filename: test/my fil"e.ts
|
||||
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
|
||||
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
|
||||
////}
|
||||
////{| "itemName": "\"my fil\\\"e\"", "kind": "module" |}
|
||||
////{| "itemName": "x", "kind": "var", "parentName": "\"file\"" |}
|
||||
////export var x: number;
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(4); // external module node + variable in module + class + property
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
////{| "itemName": "\"X.Y.Z\"", "kind": "module" |}
|
||||
////declare module "X.Y.Z" {
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "'X2.Y2.Z2'", "kind": "module" |}
|
||||
////declare module 'X2.Y2.Z2' {
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "A.B.C", "kind": "module" |}
|
||||
////module A.B.C {
|
||||
//// {| "itemName": "x", "kind": "var", "parentName": "A.B.C" |}
|
||||
//// export var x;
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "A.B", "kind": "module" |}
|
||||
////module A.B {
|
||||
//// {| "itemName": "y", "kind": "var", "parentName": "A.B" |}
|
||||
//// export var y;
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "A", "kind": "module" |}
|
||||
////module A {
|
||||
//// {| "itemName": "z", "kind": "var", "parentName": "A" |}
|
||||
//// export var z;
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "A", "kind": "module" |}
|
||||
////module A {
|
||||
//// {| "itemName": "B", "kind": "module", "parentName": "E" |}
|
||||
//// module B {
|
||||
//// {| "itemName": "C", "kind": "module", "parentName": "F" |}
|
||||
//// module C {
|
||||
//// {| "itemName": "x", "kind": "var", "parentName": "C" |}
|
||||
//// declare var x;
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
/// We have 8 module keywords, and 4 var keywords.
|
||||
/// The declarations of A.B.C.x do not get merged, so the 4 vars are independent.
|
||||
/// The two 'A' modules, however, do get merged, so in reality we have 7 modules.
|
||||
verify.getScriptLexicalStructureListCount(11);
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
////{| "itemName": "\"Multiline\\r\\nMadness\"", "kind": "module" |}
|
||||
////declare module "Multiline\r\nMadness" {
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "\"Multiline\\\nMadness\"", "kind": "module" |}
|
||||
////declare module "Multiline\
|
||||
////Madness" {
|
||||
////}
|
||||
////{| "itemName": "\"MultilineMadness\"", "kind": "module" |}
|
||||
////declare module "MultilineMadness" {}
|
||||
////
|
||||
////{| "itemName": "Foo", "kind": "interface" |}
|
||||
////interface Foo {
|
||||
//// {| "itemName": "\"a1\\\\\\r\\nb\"", "kind": "property", "parentName": "Foo" |}
|
||||
//// "a1\\\r\nb";
|
||||
//// {| "itemName": "\"a2\\\n \\\n b\"", "kind": "method", "parentName": "Foo" |}
|
||||
//// "a2\
|
||||
//// \
|
||||
//// b"(): Foo;
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "Bar", "kind": "class" |}
|
||||
////class Bar implements Foo {
|
||||
//// {| "itemName": "'a1\\\\\\r\\nb'", "kind": "property", "parentName": "Bar" |}
|
||||
//// 'a1\\\r\nb': Foo;
|
||||
////
|
||||
//// {| "itemName": "'a2\\\n \\\n b'", "kind": "method", "parentName": "Bar" |}
|
||||
//// 'a2\
|
||||
//// \
|
||||
//// b'(): Foo {
|
||||
//// return this;
|
||||
//// }
|
||||
////}
|
||||
|
||||
|
||||
test.markers().forEach((marker) => {
|
||||
verify.getScriptLexicalStructureListContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.getScriptLexicalStructureListCount(9); // interface w/ 2 properties, class w/ 2 properties, 3 modules
|
||||
@@ -6,7 +6,6 @@
|
||||
//// }
|
||||
//// interface X extends M.I { }
|
||||
|
||||
debugger;
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
c.moduleName("M"), c.interfaceName("I"), c.interfaceName("X"), c.moduleName("M"), c.interfaceName("I"));
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
//// interface Thing {
|
||||
//// toExponential(): number;
|
||||
//// }
|
||||
////
|
||||
//// var Thing = 0;
|
||||
//// Thing.toExponential();
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(c.interfaceName("Thing"));
|
||||
@@ -231,5 +231,43 @@ describe('Colorization', function () {
|
||||
identifier("var"),
|
||||
finalEndOfLineState(ts.EndOfLineState.Start));
|
||||
});
|
||||
|
||||
it("classifies partially written generics correctly.", function () {
|
||||
test("Foo<number",
|
||||
ts.EndOfLineState.Start,
|
||||
identifier("Foo"),
|
||||
operator("<"),
|
||||
identifier("number"),
|
||||
finalEndOfLineState(ts.EndOfLineState.Start));
|
||||
|
||||
// Looks like a cast, should get classified as a keyword.
|
||||
test("<number",
|
||||
ts.EndOfLineState.Start,
|
||||
operator("<"),
|
||||
keyword("number"),
|
||||
finalEndOfLineState(ts.EndOfLineState.Start));
|
||||
|
||||
// handle nesting properly.
|
||||
test("Foo<Foo,Foo<number",
|
||||
ts.EndOfLineState.Start,
|
||||
identifier("Foo"),
|
||||
operator("<"),
|
||||
identifier("Foo"),
|
||||
punctuation(","),
|
||||
identifier("Foo"),
|
||||
operator("<"),
|
||||
identifier("number"),
|
||||
finalEndOfLineState(ts.EndOfLineState.Start));
|
||||
|
||||
// no longer in something that looks generic.
|
||||
test("Foo<Foo> number",
|
||||
ts.EndOfLineState.Start,
|
||||
identifier("Foo"),
|
||||
operator("<"),
|
||||
identifier("Foo"),
|
||||
operator(">"
|
||||
identifier("keyword"),
|
||||
finalEndOfLineState(ts.EndOfLineState.Start));
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user