diff --git a/lib/tsserver.js b/lib/tsserver.js index 82790d6aea1902d0cf661f07d0305317dd19c9de..e70005b00141fb86821f2a322234fa15753d6640 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -199013,33 +199013,11 @@ var ts; } } } - var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); - var rightOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsRhsExpr); - if (tsBinaryExpr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { - if (ArkTSLinter_1_1.Utils.isEnumMemberType(leftOperandType) && ArkTSLinter_1_1.Utils.isEnumMemberType(rightOperandType)) { - if (((leftOperandType.flags & (296 /* TypeFlags.NumberLike */)) && (rightOperandType.getFlags() & (296 /* TypeFlags.NumberLike */))) || - ((leftOperandType.flags & (402653316 /* TypeFlags.StringLike */)) && (rightOperandType.getFlags() & (402653316 /* TypeFlags.StringLike */)))) { - return; - } - } - else if (ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) { - return; - } - else if (ArkTSLinter_1_1.Utils.isStringLikeType(leftOperandType) || ArkTSLinter_1_1.Utils.isStringLikeType(rightOperandType)) { - return; - } - } - else if (tsBinaryExpr.operatorToken.kind === 50 /* SyntaxKind.AmpersandToken */ || - tsBinaryExpr.operatorToken.kind === 51 /* SyntaxKind.BarToken */ || - tsBinaryExpr.operatorToken.kind === 52 /* SyntaxKind.CaretToken */ || - tsBinaryExpr.operatorToken.kind === 47 /* SyntaxKind.LessThanLessThanToken */ || - tsBinaryExpr.operatorToken.kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ || - tsBinaryExpr.operatorToken.kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */) { - if (!(ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) || - (tsLhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsLhsExpr)) || - (tsRhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsRhsExpr))) { - return; //this.incrementCounters(node, FaultID.BitOpWithWrongType); - } + if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); + this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); + var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); } else if (tsBinaryExpr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // CommaOpertor is allowed in 'for' statement initalizer and incrementor @@ -199064,6 +199042,7 @@ var ts; if (tsLhsExpr.kind === 109 /* SyntaxKind.ThisKeyword */) { return; } + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); if (ArkTSLinter_1_1.Utils.isPrimitiveType(leftOperandType) || ts.isTypeNode(leftExpr) || ArkTSLinter_1_1.Utils.isTypeSymbol(leftSymbol)) { this.incrementCounters(node, FaultID.InstanceofUnsupported); } @@ -199071,11 +199050,6 @@ var ts; else if (tsBinaryExpr.operatorToken.kind === 102 /* SyntaxKind.InKeyword */) { this.incrementCounters(tsBinaryExpr.operatorToken, FaultID.InOperator); } - else if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { - this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); - var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); - } }; TypeScriptLinter.prototype.handleVariableDeclarationList = function (node) { var varDeclFlags = ts.getCombinedNodeFlags(node); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index b393f59cee060b2e491404e01be7f6209b6ec467..65f0f8592d77ed5b8180a1c2b3506b18e5e93e56 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -198758,33 +198758,11 @@ var ts; } } } - var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); - var rightOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsRhsExpr); - if (tsBinaryExpr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { - if (ArkTSLinter_1_1.Utils.isEnumMemberType(leftOperandType) && ArkTSLinter_1_1.Utils.isEnumMemberType(rightOperandType)) { - if (((leftOperandType.flags & (296 /* TypeFlags.NumberLike */)) && (rightOperandType.getFlags() & (296 /* TypeFlags.NumberLike */))) || - ((leftOperandType.flags & (402653316 /* TypeFlags.StringLike */)) && (rightOperandType.getFlags() & (402653316 /* TypeFlags.StringLike */)))) { - return; - } - } - else if (ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) { - return; - } - else if (ArkTSLinter_1_1.Utils.isStringLikeType(leftOperandType) || ArkTSLinter_1_1.Utils.isStringLikeType(rightOperandType)) { - return; - } - } - else if (tsBinaryExpr.operatorToken.kind === 50 /* SyntaxKind.AmpersandToken */ || - tsBinaryExpr.operatorToken.kind === 51 /* SyntaxKind.BarToken */ || - tsBinaryExpr.operatorToken.kind === 52 /* SyntaxKind.CaretToken */ || - tsBinaryExpr.operatorToken.kind === 47 /* SyntaxKind.LessThanLessThanToken */ || - tsBinaryExpr.operatorToken.kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ || - tsBinaryExpr.operatorToken.kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */) { - if (!(ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) || - (tsLhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsLhsExpr)) || - (tsRhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsRhsExpr))) { - return; //this.incrementCounters(node, FaultID.BitOpWithWrongType); - } + if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); + this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); + var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); } else if (tsBinaryExpr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // CommaOpertor is allowed in 'for' statement initalizer and incrementor @@ -198809,6 +198787,7 @@ var ts; if (tsLhsExpr.kind === 109 /* SyntaxKind.ThisKeyword */) { return; } + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); if (ArkTSLinter_1_1.Utils.isPrimitiveType(leftOperandType) || ts.isTypeNode(leftExpr) || ArkTSLinter_1_1.Utils.isTypeSymbol(leftSymbol)) { this.incrementCounters(node, FaultID.InstanceofUnsupported); } @@ -198816,11 +198795,6 @@ var ts; else if (tsBinaryExpr.operatorToken.kind === 102 /* SyntaxKind.InKeyword */) { this.incrementCounters(tsBinaryExpr.operatorToken, FaultID.InOperator); } - else if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { - this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); - var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); - } }; TypeScriptLinter.prototype.handleVariableDeclarationList = function (node) { var varDeclFlags = ts.getCombinedNodeFlags(node); diff --git a/lib/typescript.js b/lib/typescript.js index 62934649c3c6647d03c88da3455d3e2e800af773..4e6c7db03860d808e59c170fb6a2b218f0a86e73 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -187852,33 +187852,11 @@ var ts; } } } - var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); - var rightOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsRhsExpr); - if (tsBinaryExpr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { - if (ArkTSLinter_1_1.Utils.isEnumMemberType(leftOperandType) && ArkTSLinter_1_1.Utils.isEnumMemberType(rightOperandType)) { - if (((leftOperandType.flags & (296 /* TypeFlags.NumberLike */)) && (rightOperandType.getFlags() & (296 /* TypeFlags.NumberLike */))) || - ((leftOperandType.flags & (402653316 /* TypeFlags.StringLike */)) && (rightOperandType.getFlags() & (402653316 /* TypeFlags.StringLike */)))) { - return; - } - } - else if (ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) { - return; - } - else if (ArkTSLinter_1_1.Utils.isStringLikeType(leftOperandType) || ArkTSLinter_1_1.Utils.isStringLikeType(rightOperandType)) { - return; - } - } - else if (tsBinaryExpr.operatorToken.kind === 50 /* SyntaxKind.AmpersandToken */ || - tsBinaryExpr.operatorToken.kind === 51 /* SyntaxKind.BarToken */ || - tsBinaryExpr.operatorToken.kind === 52 /* SyntaxKind.CaretToken */ || - tsBinaryExpr.operatorToken.kind === 47 /* SyntaxKind.LessThanLessThanToken */ || - tsBinaryExpr.operatorToken.kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ || - tsBinaryExpr.operatorToken.kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */) { - if (!(ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) || - (tsLhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsLhsExpr)) || - (tsRhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsRhsExpr))) { - return; //this.incrementCounters(node, FaultID.BitOpWithWrongType); - } + if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); + this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); + var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); } else if (tsBinaryExpr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // CommaOpertor is allowed in 'for' statement initalizer and incrementor @@ -187903,6 +187881,7 @@ var ts; if (tsLhsExpr.kind === 109 /* SyntaxKind.ThisKeyword */) { return; } + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); if (ArkTSLinter_1_1.Utils.isPrimitiveType(leftOperandType) || ts.isTypeNode(leftExpr) || ArkTSLinter_1_1.Utils.isTypeSymbol(leftSymbol)) { this.incrementCounters(node, FaultID.InstanceofUnsupported); } @@ -187910,11 +187889,6 @@ var ts; else if (tsBinaryExpr.operatorToken.kind === 102 /* SyntaxKind.InKeyword */) { this.incrementCounters(tsBinaryExpr.operatorToken, FaultID.InOperator); } - else if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { - this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); - var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); - } }; TypeScriptLinter.prototype.handleVariableDeclarationList = function (node) { var varDeclFlags = ts.getCombinedNodeFlags(node); diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 19c9c5322b6d3481f040489cedc3c790ed927f27..b3943130b8ae1adce909038adec4ec12de5dd350 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -187852,33 +187852,11 @@ var ts; } } } - var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); - var rightOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsRhsExpr); - if (tsBinaryExpr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { - if (ArkTSLinter_1_1.Utils.isEnumMemberType(leftOperandType) && ArkTSLinter_1_1.Utils.isEnumMemberType(rightOperandType)) { - if (((leftOperandType.flags & (296 /* TypeFlags.NumberLike */)) && (rightOperandType.getFlags() & (296 /* TypeFlags.NumberLike */))) || - ((leftOperandType.flags & (402653316 /* TypeFlags.StringLike */)) && (rightOperandType.getFlags() & (402653316 /* TypeFlags.StringLike */)))) { - return; - } - } - else if (ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) { - return; - } - else if (ArkTSLinter_1_1.Utils.isStringLikeType(leftOperandType) || ArkTSLinter_1_1.Utils.isStringLikeType(rightOperandType)) { - return; - } - } - else if (tsBinaryExpr.operatorToken.kind === 50 /* SyntaxKind.AmpersandToken */ || - tsBinaryExpr.operatorToken.kind === 51 /* SyntaxKind.BarToken */ || - tsBinaryExpr.operatorToken.kind === 52 /* SyntaxKind.CaretToken */ || - tsBinaryExpr.operatorToken.kind === 47 /* SyntaxKind.LessThanLessThanToken */ || - tsBinaryExpr.operatorToken.kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ || - tsBinaryExpr.operatorToken.kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */) { - if (!(ArkTSLinter_1_1.Utils.isNumberLikeType(leftOperandType) && ArkTSLinter_1_1.Utils.isNumberLikeType(rightOperandType)) || - (tsLhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsLhsExpr)) || - (tsRhsExpr.kind === 8 /* SyntaxKind.NumericLiteral */ && !ArkTSLinter_1_1.Utils.isIntegerConstantValue(tsRhsExpr))) { - return; //this.incrementCounters(node, FaultID.BitOpWithWrongType); - } + if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); + this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); + var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); } else if (tsBinaryExpr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // CommaOpertor is allowed in 'for' statement initalizer and incrementor @@ -187903,6 +187881,7 @@ var ts; if (tsLhsExpr.kind === 109 /* SyntaxKind.ThisKeyword */) { return; } + var leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); if (ArkTSLinter_1_1.Utils.isPrimitiveType(leftOperandType) || ts.isTypeNode(leftExpr) || ArkTSLinter_1_1.Utils.isTypeSymbol(leftSymbol)) { this.incrementCounters(node, FaultID.InstanceofUnsupported); } @@ -187910,11 +187889,6 @@ var ts; else if (tsBinaryExpr.operatorToken.kind === 102 /* SyntaxKind.InKeyword */) { this.incrementCounters(tsBinaryExpr.operatorToken, FaultID.InOperator); } - else if (tsBinaryExpr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { - this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); - var typeNode = ArkTSLinter_1_1.Utils.getVariableDeclarationTypeNode(tsLhsExpr); - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); - } }; TypeScriptLinter.prototype.handleVariableDeclarationList = function (node) { var varDeclFlags = ts.getCombinedNodeFlags(node); diff --git a/src/linter/ArkTSLinter_1_1/TypeScriptLinter.ts b/src/linter/ArkTSLinter_1_1/TypeScriptLinter.ts index 8126f4375d60012a4a503b3293eb6ca1ff781d41..0a759b0b07026069c156a880e90e0045dce2ec48 100644 --- a/src/linter/ArkTSLinter_1_1/TypeScriptLinter.ts +++ b/src/linter/ArkTSLinter_1_1/TypeScriptLinter.ts @@ -1109,40 +1109,11 @@ export class TypeScriptLinter { } } } - - const leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); - const rightOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsRhsExpr); - - if (tsBinaryExpr.operatorToken.kind === SyntaxKind.PlusToken) { - if (Utils.isEnumMemberType(leftOperandType) && Utils.isEnumMemberType(rightOperandType)) { - if ( - ((leftOperandType.flags & (TypeFlags.NumberLike)) && (rightOperandType.getFlags() & (TypeFlags.NumberLike))) || - ((leftOperandType.flags & (TypeFlags.StringLike)) && (rightOperandType.getFlags() & (TypeFlags.StringLike))) - ) { - return; - } - } - else if (Utils.isNumberLikeType(leftOperandType) && Utils.isNumberLikeType(rightOperandType)) { - return; - } - else if (Utils.isStringLikeType(leftOperandType) || Utils.isStringLikeType(rightOperandType)) { - return; - } - } - else if ( - tsBinaryExpr.operatorToken.kind === SyntaxKind.AmpersandToken || - tsBinaryExpr.operatorToken.kind === SyntaxKind.BarToken || - tsBinaryExpr.operatorToken.kind === SyntaxKind.CaretToken || - tsBinaryExpr.operatorToken.kind === SyntaxKind.LessThanLessThanToken || - tsBinaryExpr.operatorToken.kind === SyntaxKind.GreaterThanGreaterThanToken || - tsBinaryExpr.operatorToken.kind === SyntaxKind.GreaterThanGreaterThanGreaterThanToken - ) { - if (!(Utils.isNumberLikeType(leftOperandType) && Utils.isNumberLikeType(rightOperandType))|| - (tsLhsExpr.kind === SyntaxKind.NumericLiteral && !Utils.isIntegerConstantValue(tsLhsExpr as NumericLiteral)) || - (tsRhsExpr.kind === SyntaxKind.NumericLiteral && !Utils.isIntegerConstantValue(tsRhsExpr as NumericLiteral)) - ) { - return; //this.incrementCounters(node, FaultID.BitOpWithWrongType); - } + if (tsBinaryExpr.operatorToken.kind === SyntaxKind.EqualsToken) { + const leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); + this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); + const typeNode = Utils.getVariableDeclarationTypeNode(tsLhsExpr); + this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); } else if (tsBinaryExpr.operatorToken.kind === SyntaxKind.CommaToken) { // CommaOpertor is allowed in 'for' statement initalizer and incrementor @@ -1167,15 +1138,12 @@ export class TypeScriptLinter { if (tsLhsExpr.kind === SyntaxKind.ThisKeyword) { return; } + const leftOperandType = TypeScriptLinter.tsTypeChecker.getTypeAtLocation(tsLhsExpr); if (Utils.isPrimitiveType(leftOperandType) || isTypeNode(leftExpr) || Utils.isTypeSymbol(leftSymbol)) { this.incrementCounters(node, FaultID.InstanceofUnsupported); } } else if (tsBinaryExpr.operatorToken.kind === SyntaxKind.InKeyword) { this.incrementCounters(tsBinaryExpr.operatorToken, FaultID.InOperator); - } else if (tsBinaryExpr.operatorToken.kind === SyntaxKind.EqualsToken) { - this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); - const typeNode = Utils.getVariableDeclarationTypeNode(tsLhsExpr); - this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); } }