mirror of
https://gitee.com/openharmony/third_party_typescript
synced 2024-11-27 00:51:12 +00:00
fix function isSendableTypeNode with warning
issue:#IARNAN testL: tsc test && arkts test Signed-off-by: yangrui <yangrui185@huawei.com> Change-Id: Id7504a887f12c82c71ecbddde08e57c6c99b7c8a
This commit is contained in:
parent
10d70bac8b
commit
06dcb87f34
@ -194983,7 +194983,8 @@ var ts;
|
||||
FaultID[FaultID["SendableClosureExport"] = 108] = "SendableClosureExport";
|
||||
FaultID[FaultID["SharedModuleExportsWarning"] = 109] = "SharedModuleExportsWarning";
|
||||
FaultID[FaultID["SendableBetaCompatible"] = 110] = "SendableBetaCompatible";
|
||||
FaultID[FaultID["LAST_ID"] = 111] = "LAST_ID";
|
||||
FaultID[FaultID["SendablePropTypeWarning"] = 111] = "SendablePropTypeWarning";
|
||||
FaultID[FaultID["LAST_ID"] = 112] = "LAST_ID";
|
||||
})(FaultID = Problems.FaultID || (Problems.FaultID = {}));
|
||||
var FaultAttributes = /** @class */ (function () {
|
||||
function FaultAttributes(cookBookRef, migratable, severity) {
|
||||
@ -195108,6 +195109,7 @@ var ts;
|
||||
Problems.faultsAttrs[FaultID.SendableClosureExport] = new FaultAttributes(181, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SharedModuleExportsWarning] = new FaultAttributes(163, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SendableBetaCompatible] = new FaultAttributes(182);
|
||||
Problems.faultsAttrs[FaultID.SendablePropTypeWarning] = new FaultAttributes(154, false, ProblemSeverity.WARNING);
|
||||
})(Problems = ArkTSLinter_1_1.Problems || (ArkTSLinter_1_1.Problems = {}));
|
||||
})(ArkTSLinter_1_1 = ts.ArkTSLinter_1_1 || (ts.ArkTSLinter_1_1 = {}));
|
||||
})(ts || (ts = {}));
|
||||
@ -196926,13 +196928,6 @@ var ts;
|
||||
if (sym && sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */) {
|
||||
var typeDecl = getDeclaration(sym);
|
||||
if (typeDecl && ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs &&
|
||||
!typeArgs.every(function (typeArg) {
|
||||
return isSendableTypeNode(typeArg);
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
return isSendableTypeNode(typeDecl.type, isShared);
|
||||
}
|
||||
}
|
||||
@ -198291,6 +198286,39 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.checkTypeAliasInSendableScope = function (node) {
|
||||
var _this = this;
|
||||
if (!node.type) {
|
||||
return;
|
||||
}
|
||||
var typeNode = ArkTSLinter_1_1.Utils.unwrapParenthesizedTypeNode(node.type);
|
||||
var needWarning = (ts.isUnionTypeNode(typeNode) && typeNode.types.some(function (elemType) { return _this.isNoneSendableTypeAlias(elemType); })) ||
|
||||
(ts.isTypeReferenceNode(typeNode) && this.isNoneSendableTypeAlias(typeNode));
|
||||
if (needWarning) {
|
||||
this.incrementCounters(node.type, FaultID.SendablePropTypeWarning);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.isNoneSendableTypeAlias = function (typeNode) {
|
||||
if (!ts.isTypeReferenceNode(typeNode)) {
|
||||
return false;
|
||||
}
|
||||
var sym = ArkTSLinter_1_1.Utils.trueSymbolAtLocation(typeNode.typeName);
|
||||
if (!sym || !(sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */)) {
|
||||
return false;
|
||||
}
|
||||
var typeDecl = ArkTSLinter_1_1.Utils.getDeclaration(sym);
|
||||
if (!typeDecl || !ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
return false;
|
||||
}
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs && !typeArgs.every(function (typeArg) { return ArkTSLinter_1_1.Utils.isSendableTypeNode(typeArg); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
TypeScriptLinter.prototype.handlePropertyAssignment = function (node) {
|
||||
var propName = node.name;
|
||||
@ -198345,6 +198373,9 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.filterOutDecoratorsDiagnostics = function (decorators, expectedDecorators, range, code, prop_type) {
|
||||
// Filter out non-initializable property decorators from strict diagnostics.
|
||||
|
5
lib/tsserverlibrary.d.ts
vendored
5
lib/tsserverlibrary.d.ts
vendored
@ -13239,7 +13239,8 @@ declare namespace ts {
|
||||
SendableClosureExport = 108,
|
||||
SharedModuleExportsWarning = 109,
|
||||
SendableBetaCompatible = 110,
|
||||
LAST_ID = 111
|
||||
SendablePropTypeWarning = 111,
|
||||
LAST_ID = 112
|
||||
}
|
||||
class FaultAttributes {
|
||||
cookBookRef: number;
|
||||
@ -13574,6 +13575,8 @@ declare namespace ts {
|
||||
private handlePropertyAccessExpression;
|
||||
private handlePropertyDeclaration;
|
||||
private handleSendableClassProperty;
|
||||
private checkTypeAliasInSendableScope;
|
||||
private isNoneSendableTypeAlias;
|
||||
private handlePropertyAssignment;
|
||||
private handlePropertySignature;
|
||||
private handleSendableInterfaceProperty;
|
||||
|
@ -194728,7 +194728,8 @@ var ts;
|
||||
FaultID[FaultID["SendableClosureExport"] = 108] = "SendableClosureExport";
|
||||
FaultID[FaultID["SharedModuleExportsWarning"] = 109] = "SharedModuleExportsWarning";
|
||||
FaultID[FaultID["SendableBetaCompatible"] = 110] = "SendableBetaCompatible";
|
||||
FaultID[FaultID["LAST_ID"] = 111] = "LAST_ID";
|
||||
FaultID[FaultID["SendablePropTypeWarning"] = 111] = "SendablePropTypeWarning";
|
||||
FaultID[FaultID["LAST_ID"] = 112] = "LAST_ID";
|
||||
})(FaultID = Problems.FaultID || (Problems.FaultID = {}));
|
||||
var FaultAttributes = /** @class */ (function () {
|
||||
function FaultAttributes(cookBookRef, migratable, severity) {
|
||||
@ -194853,6 +194854,7 @@ var ts;
|
||||
Problems.faultsAttrs[FaultID.SendableClosureExport] = new FaultAttributes(181, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SharedModuleExportsWarning] = new FaultAttributes(163, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SendableBetaCompatible] = new FaultAttributes(182);
|
||||
Problems.faultsAttrs[FaultID.SendablePropTypeWarning] = new FaultAttributes(154, false, ProblemSeverity.WARNING);
|
||||
})(Problems = ArkTSLinter_1_1.Problems || (ArkTSLinter_1_1.Problems = {}));
|
||||
})(ArkTSLinter_1_1 = ts.ArkTSLinter_1_1 || (ts.ArkTSLinter_1_1 = {}));
|
||||
})(ts || (ts = {}));
|
||||
@ -196671,13 +196673,6 @@ var ts;
|
||||
if (sym && sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */) {
|
||||
var typeDecl = getDeclaration(sym);
|
||||
if (typeDecl && ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs &&
|
||||
!typeArgs.every(function (typeArg) {
|
||||
return isSendableTypeNode(typeArg);
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
return isSendableTypeNode(typeDecl.type, isShared);
|
||||
}
|
||||
}
|
||||
@ -198036,6 +198031,39 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.checkTypeAliasInSendableScope = function (node) {
|
||||
var _this = this;
|
||||
if (!node.type) {
|
||||
return;
|
||||
}
|
||||
var typeNode = ArkTSLinter_1_1.Utils.unwrapParenthesizedTypeNode(node.type);
|
||||
var needWarning = (ts.isUnionTypeNode(typeNode) && typeNode.types.some(function (elemType) { return _this.isNoneSendableTypeAlias(elemType); })) ||
|
||||
(ts.isTypeReferenceNode(typeNode) && this.isNoneSendableTypeAlias(typeNode));
|
||||
if (needWarning) {
|
||||
this.incrementCounters(node.type, FaultID.SendablePropTypeWarning);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.isNoneSendableTypeAlias = function (typeNode) {
|
||||
if (!ts.isTypeReferenceNode(typeNode)) {
|
||||
return false;
|
||||
}
|
||||
var sym = ArkTSLinter_1_1.Utils.trueSymbolAtLocation(typeNode.typeName);
|
||||
if (!sym || !(sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */)) {
|
||||
return false;
|
||||
}
|
||||
var typeDecl = ArkTSLinter_1_1.Utils.getDeclaration(sym);
|
||||
if (!typeDecl || !ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
return false;
|
||||
}
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs && !typeArgs.every(function (typeArg) { return ArkTSLinter_1_1.Utils.isSendableTypeNode(typeArg); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
TypeScriptLinter.prototype.handlePropertyAssignment = function (node) {
|
||||
var propName = node.name;
|
||||
@ -198090,6 +198118,9 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.filterOutDecoratorsDiagnostics = function (decorators, expectedDecorators, range, code, prop_type) {
|
||||
// Filter out non-initializable property decorators from strict diagnostics.
|
||||
|
5
lib/typescript.d.ts
vendored
5
lib/typescript.d.ts
vendored
@ -9293,7 +9293,8 @@ declare namespace ts {
|
||||
SendableClosureExport = 108,
|
||||
SharedModuleExportsWarning = 109,
|
||||
SendableBetaCompatible = 110,
|
||||
LAST_ID = 111
|
||||
SendablePropTypeWarning = 111,
|
||||
LAST_ID = 112
|
||||
}
|
||||
class FaultAttributes {
|
||||
cookBookRef: number;
|
||||
@ -9628,6 +9629,8 @@ declare namespace ts {
|
||||
private handlePropertyAccessExpression;
|
||||
private handlePropertyDeclaration;
|
||||
private handleSendableClassProperty;
|
||||
private checkTypeAliasInSendableScope;
|
||||
private isNoneSendableTypeAlias;
|
||||
private handlePropertyAssignment;
|
||||
private handlePropertySignature;
|
||||
private handleSendableInterfaceProperty;
|
||||
|
@ -183822,7 +183822,8 @@ var ts;
|
||||
FaultID[FaultID["SendableClosureExport"] = 108] = "SendableClosureExport";
|
||||
FaultID[FaultID["SharedModuleExportsWarning"] = 109] = "SharedModuleExportsWarning";
|
||||
FaultID[FaultID["SendableBetaCompatible"] = 110] = "SendableBetaCompatible";
|
||||
FaultID[FaultID["LAST_ID"] = 111] = "LAST_ID";
|
||||
FaultID[FaultID["SendablePropTypeWarning"] = 111] = "SendablePropTypeWarning";
|
||||
FaultID[FaultID["LAST_ID"] = 112] = "LAST_ID";
|
||||
})(FaultID = Problems.FaultID || (Problems.FaultID = {}));
|
||||
var FaultAttributes = /** @class */ (function () {
|
||||
function FaultAttributes(cookBookRef, migratable, severity) {
|
||||
@ -183947,6 +183948,7 @@ var ts;
|
||||
Problems.faultsAttrs[FaultID.SendableClosureExport] = new FaultAttributes(181, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SharedModuleExportsWarning] = new FaultAttributes(163, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SendableBetaCompatible] = new FaultAttributes(182);
|
||||
Problems.faultsAttrs[FaultID.SendablePropTypeWarning] = new FaultAttributes(154, false, ProblemSeverity.WARNING);
|
||||
})(Problems = ArkTSLinter_1_1.Problems || (ArkTSLinter_1_1.Problems = {}));
|
||||
})(ArkTSLinter_1_1 = ts.ArkTSLinter_1_1 || (ts.ArkTSLinter_1_1 = {}));
|
||||
})(ts || (ts = {}));
|
||||
@ -185765,13 +185767,6 @@ var ts;
|
||||
if (sym && sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */) {
|
||||
var typeDecl = getDeclaration(sym);
|
||||
if (typeDecl && ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs &&
|
||||
!typeArgs.every(function (typeArg) {
|
||||
return isSendableTypeNode(typeArg);
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
return isSendableTypeNode(typeDecl.type, isShared);
|
||||
}
|
||||
}
|
||||
@ -187130,6 +187125,39 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.checkTypeAliasInSendableScope = function (node) {
|
||||
var _this = this;
|
||||
if (!node.type) {
|
||||
return;
|
||||
}
|
||||
var typeNode = ArkTSLinter_1_1.Utils.unwrapParenthesizedTypeNode(node.type);
|
||||
var needWarning = (ts.isUnionTypeNode(typeNode) && typeNode.types.some(function (elemType) { return _this.isNoneSendableTypeAlias(elemType); })) ||
|
||||
(ts.isTypeReferenceNode(typeNode) && this.isNoneSendableTypeAlias(typeNode));
|
||||
if (needWarning) {
|
||||
this.incrementCounters(node.type, FaultID.SendablePropTypeWarning);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.isNoneSendableTypeAlias = function (typeNode) {
|
||||
if (!ts.isTypeReferenceNode(typeNode)) {
|
||||
return false;
|
||||
}
|
||||
var sym = ArkTSLinter_1_1.Utils.trueSymbolAtLocation(typeNode.typeName);
|
||||
if (!sym || !(sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */)) {
|
||||
return false;
|
||||
}
|
||||
var typeDecl = ArkTSLinter_1_1.Utils.getDeclaration(sym);
|
||||
if (!typeDecl || !ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
return false;
|
||||
}
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs && !typeArgs.every(function (typeArg) { return ArkTSLinter_1_1.Utils.isSendableTypeNode(typeArg); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
TypeScriptLinter.prototype.handlePropertyAssignment = function (node) {
|
||||
var propName = node.name;
|
||||
@ -187184,6 +187212,9 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.filterOutDecoratorsDiagnostics = function (decorators, expectedDecorators, range, code, prop_type) {
|
||||
// Filter out non-initializable property decorators from strict diagnostics.
|
||||
|
5
lib/typescriptServices.d.ts
vendored
5
lib/typescriptServices.d.ts
vendored
@ -9293,7 +9293,8 @@ declare namespace ts {
|
||||
SendableClosureExport = 108,
|
||||
SharedModuleExportsWarning = 109,
|
||||
SendableBetaCompatible = 110,
|
||||
LAST_ID = 111
|
||||
SendablePropTypeWarning = 111,
|
||||
LAST_ID = 112
|
||||
}
|
||||
class FaultAttributes {
|
||||
cookBookRef: number;
|
||||
@ -9628,6 +9629,8 @@ declare namespace ts {
|
||||
private handlePropertyAccessExpression;
|
||||
private handlePropertyDeclaration;
|
||||
private handleSendableClassProperty;
|
||||
private checkTypeAliasInSendableScope;
|
||||
private isNoneSendableTypeAlias;
|
||||
private handlePropertyAssignment;
|
||||
private handlePropertySignature;
|
||||
private handleSendableInterfaceProperty;
|
||||
|
@ -183822,7 +183822,8 @@ var ts;
|
||||
FaultID[FaultID["SendableClosureExport"] = 108] = "SendableClosureExport";
|
||||
FaultID[FaultID["SharedModuleExportsWarning"] = 109] = "SharedModuleExportsWarning";
|
||||
FaultID[FaultID["SendableBetaCompatible"] = 110] = "SendableBetaCompatible";
|
||||
FaultID[FaultID["LAST_ID"] = 111] = "LAST_ID";
|
||||
FaultID[FaultID["SendablePropTypeWarning"] = 111] = "SendablePropTypeWarning";
|
||||
FaultID[FaultID["LAST_ID"] = 112] = "LAST_ID";
|
||||
})(FaultID = Problems.FaultID || (Problems.FaultID = {}));
|
||||
var FaultAttributes = /** @class */ (function () {
|
||||
function FaultAttributes(cookBookRef, migratable, severity) {
|
||||
@ -183947,6 +183948,7 @@ var ts;
|
||||
Problems.faultsAttrs[FaultID.SendableClosureExport] = new FaultAttributes(181, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SharedModuleExportsWarning] = new FaultAttributes(163, false, ProblemSeverity.WARNING);
|
||||
Problems.faultsAttrs[FaultID.SendableBetaCompatible] = new FaultAttributes(182);
|
||||
Problems.faultsAttrs[FaultID.SendablePropTypeWarning] = new FaultAttributes(154, false, ProblemSeverity.WARNING);
|
||||
})(Problems = ArkTSLinter_1_1.Problems || (ArkTSLinter_1_1.Problems = {}));
|
||||
})(ArkTSLinter_1_1 = ts.ArkTSLinter_1_1 || (ts.ArkTSLinter_1_1 = {}));
|
||||
})(ts || (ts = {}));
|
||||
@ -185765,13 +185767,6 @@ var ts;
|
||||
if (sym && sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */) {
|
||||
var typeDecl = getDeclaration(sym);
|
||||
if (typeDecl && ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs &&
|
||||
!typeArgs.every(function (typeArg) {
|
||||
return isSendableTypeNode(typeArg);
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
return isSendableTypeNode(typeDecl.type, isShared);
|
||||
}
|
||||
}
|
||||
@ -187130,6 +187125,39 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.checkTypeAliasInSendableScope = function (node) {
|
||||
var _this = this;
|
||||
if (!node.type) {
|
||||
return;
|
||||
}
|
||||
var typeNode = ArkTSLinter_1_1.Utils.unwrapParenthesizedTypeNode(node.type);
|
||||
var needWarning = (ts.isUnionTypeNode(typeNode) && typeNode.types.some(function (elemType) { return _this.isNoneSendableTypeAlias(elemType); })) ||
|
||||
(ts.isTypeReferenceNode(typeNode) && this.isNoneSendableTypeAlias(typeNode));
|
||||
if (needWarning) {
|
||||
this.incrementCounters(node.type, FaultID.SendablePropTypeWarning);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.isNoneSendableTypeAlias = function (typeNode) {
|
||||
if (!ts.isTypeReferenceNode(typeNode)) {
|
||||
return false;
|
||||
}
|
||||
var sym = ArkTSLinter_1_1.Utils.trueSymbolAtLocation(typeNode.typeName);
|
||||
if (!sym || !(sym.getFlags() & 524288 /* ts.SymbolFlags.TypeAlias */)) {
|
||||
return false;
|
||||
}
|
||||
var typeDecl = ArkTSLinter_1_1.Utils.getDeclaration(sym);
|
||||
if (!typeDecl || !ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
return false;
|
||||
}
|
||||
var typeArgs = typeNode.typeArguments;
|
||||
if (typeArgs && !typeArgs.every(function (typeArg) { return ArkTSLinter_1_1.Utils.isSendableTypeNode(typeArg); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
TypeScriptLinter.prototype.handlePropertyAssignment = function (node) {
|
||||
var propName = node.name;
|
||||
@ -187184,6 +187212,9 @@ var ts;
|
||||
if (!ArkTSLinter_1_1.Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
}
|
||||
else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
};
|
||||
TypeScriptLinter.prototype.filterOutDecoratorsDiagnostics = function (decorators, expectedDecorators, range, code, prop_type) {
|
||||
// Filter out non-initializable property decorators from strict diagnostics.
|
||||
|
@ -46,7 +46,7 @@ export enum FaultID {
|
||||
SendableExplicitFieldType,
|
||||
SendableFunctionImportedVariables, SendableFunctionDecorator, SendableTypeAliasDecorator, SendableTypeAliasDeclaration,
|
||||
SendableFunctionAssignment, SendableFunctionOverloadDecorator, SendableFunctionProperty, SendableFunctionAsExpr,
|
||||
SendableDecoratorLimited, SendableClosureExport, SharedModuleExportsWarning, SendableBetaCompatible,
|
||||
SendableDecoratorLimited, SendableClosureExport, SharedModuleExportsWarning, SendableBetaCompatible, SendablePropTypeWarning,
|
||||
LAST_ID, // this should always be last enum
|
||||
}
|
||||
|
||||
@ -171,6 +171,7 @@ faultsAttrs[FaultID.SendableDecoratorLimited] = new FaultAttributes(180);
|
||||
faultsAttrs[FaultID.SendableClosureExport] = new FaultAttributes(181, false, ProblemSeverity.WARNING);
|
||||
faultsAttrs[FaultID.SharedModuleExportsWarning] = new FaultAttributes(163, false, ProblemSeverity.WARNING);
|
||||
faultsAttrs[FaultID.SendableBetaCompatible] = new FaultAttributes(182);
|
||||
faultsAttrs[FaultID.SendablePropTypeWarning] = new FaultAttributes(154, false, ProblemSeverity.WARNING);
|
||||
}
|
||||
}
|
||||
}
|
@ -767,9 +767,49 @@ export class TypeScriptLinter {
|
||||
});
|
||||
if (!Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
} else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
}
|
||||
|
||||
private checkTypeAliasInSendableScope(node: ts.PropertyDeclaration | ts.PropertySignature): void {
|
||||
if (!node.type) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typeNode = Utils.unwrapParenthesizedTypeNode(node.type);
|
||||
const needWarning =
|
||||
(ts.isUnionTypeNode(typeNode) && typeNode.types.some((elemType) => this.isNoneSendableTypeAlias(elemType))) ||
|
||||
(ts.isTypeReferenceNode(typeNode) && this.isNoneSendableTypeAlias(typeNode));
|
||||
|
||||
if (needWarning) {
|
||||
this.incrementCounters(node.type, FaultID.SendablePropTypeWarning);
|
||||
}
|
||||
}
|
||||
|
||||
private isNoneSendableTypeAlias(typeNode: TypeNode): boolean {
|
||||
if (!ts.isTypeReferenceNode(typeNode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const sym = Utils.trueSymbolAtLocation(typeNode.typeName);
|
||||
if (!sym || !(sym.getFlags() & ts.SymbolFlags.TypeAlias)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const typeDecl = Utils.getDeclaration(sym);
|
||||
if (!typeDecl || !ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const typeArgs = typeNode.typeArguments;
|
||||
|
||||
if (typeArgs && !typeArgs.every((typeArg) => Utils.isSendableTypeNode(typeArg))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private handlePropertyAssignment(node: ts.PropertyAssignment) {
|
||||
const propName = node.name;
|
||||
if (!(!!propName && ts.isNumericLiteral(propName))) {
|
||||
@ -826,6 +866,8 @@ export class TypeScriptLinter {
|
||||
}
|
||||
if (!Utils.isSendableTypeNode(typeNode)) {
|
||||
this.incrementCounters(node, FaultID.SendablePropType);
|
||||
} else {
|
||||
this.checkTypeAliasInSendableScope(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1971,15 +1971,6 @@ export function isSendableTypeNode(typeNode: ts.TypeNode, isShared: boolean = fa
|
||||
if (sym && sym.getFlags() & ts.SymbolFlags.TypeAlias) {
|
||||
const typeDecl = getDeclaration(sym);
|
||||
if (typeDecl && ts.isTypeAliasDeclaration(typeDecl)) {
|
||||
const typeArgs = (typeNode as ts.TypeReferenceNode).typeArguments;
|
||||
if (
|
||||
typeArgs &&
|
||||
!typeArgs.every((typeArg) => {
|
||||
return isSendableTypeNode(typeArg);
|
||||
})
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return isSendableTypeNode(typeDecl.type, isShared);
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ function run(){
|
||||
}
|
||||
}
|
||||
|
||||
ignoreList = ignoreList.concat(ignoreCaseConfigList).map(x => path.normalize(x))
|
||||
ignoreList = ignoreList.concat(ignoreCaseConfigList).map(x => path.normalize(x));
|
||||
|
||||
let filePathStats = fs.lstatSync(filePath)
|
||||
if(!filePathStats.isDirectory()){
|
||||
|
@ -20,15 +20,16 @@ declare type Nullable<T> = T | undefined;
|
||||
type MyType<T> = B<T> | undefined;
|
||||
|
||||
class C {
|
||||
c: number;
|
||||
public c: number;
|
||||
}
|
||||
|
||||
@Sendable
|
||||
class D {
|
||||
a: Nullable<A>; // NOT OK
|
||||
b: Nullable<C> = new C(); // NOT OK
|
||||
c: Nullable<number> = 1; // OK
|
||||
d: MyType<number>; // NOT OK
|
||||
public a: Nullable<A>; // NOT OK
|
||||
public b: Nullable<C> = new C(); // NOT OK
|
||||
public c: Nullable<number> = 1; // OK
|
||||
public d: MyType<number>; // NOT OK
|
||||
public e: Nullable<A> || number; // NOT OK
|
||||
}
|
||||
|
||||
let d = new D();
|
@ -4,7 +4,7 @@
|
||||
"messageText": "Property 'c' has no initializer and is not definitely assigned in the constructor.",
|
||||
"expectLineAndCharacter": {
|
||||
"line": 23,
|
||||
"character": 3
|
||||
"character": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -20,28 +20,28 @@
|
||||
"messageText": "Property 'c' has no initializer and is not definitely assigned in the constructor.",
|
||||
"expectLineAndCharacter": {
|
||||
"line": 23,
|
||||
"character": 3
|
||||
"character": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"messageText": "Only imported variables can be captured by \"Sendable\" class (arkts-sendable-imported-variables)",
|
||||
"expectLineAndCharacter": {
|
||||
"line": 29,
|
||||
"character": 24
|
||||
"character": 31
|
||||
}
|
||||
},
|
||||
{
|
||||
"messageText": "Properties in \"Sendable\" classes and interfaces must have a Sendable data type (arkts-sendable-prop-types)",
|
||||
"expectLineAndCharacter": {
|
||||
"line": 28,
|
||||
"character": 3
|
||||
"character": 13
|
||||
}
|
||||
},
|
||||
{
|
||||
"messageText": "Properties in \"Sendable\" classes and interfaces must have a Sendable data type (arkts-sendable-prop-types)",
|
||||
"expectLineAndCharacter": {
|
||||
"line": 29,
|
||||
"character": 3
|
||||
"character": 13
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -50,6 +50,13 @@
|
||||
"line": 31,
|
||||
"character": 3
|
||||
}
|
||||
},
|
||||
{
|
||||
"messageText": "Properties in \"Sendable\" classes and interfaces must have a Sendable data type (arkts-sendable-prop-types)",
|
||||
"expectLineAndCharacter": {
|
||||
"line": 32,
|
||||
"character": 13
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -13239,7 +13239,8 @@ declare namespace ts {
|
||||
SendableClosureExport = 108,
|
||||
SharedModuleExportsWarning = 109,
|
||||
SendableBetaCompatible = 110,
|
||||
LAST_ID = 111
|
||||
SendablePropTypeWarning = 111,
|
||||
LAST_ID = 112
|
||||
}
|
||||
class FaultAttributes {
|
||||
cookBookRef: number;
|
||||
@ -13574,6 +13575,8 @@ declare namespace ts {
|
||||
private handlePropertyAccessExpression;
|
||||
private handlePropertyDeclaration;
|
||||
private handleSendableClassProperty;
|
||||
private checkTypeAliasInSendableScope;
|
||||
private isNoneSendableTypeAlias;
|
||||
private handlePropertyAssignment;
|
||||
private handlePropertySignature;
|
||||
private handleSendableInterfaceProperty;
|
||||
|
@ -9293,7 +9293,8 @@ declare namespace ts {
|
||||
SendableClosureExport = 108,
|
||||
SharedModuleExportsWarning = 109,
|
||||
SendableBetaCompatible = 110,
|
||||
LAST_ID = 111
|
||||
SendablePropTypeWarning = 111,
|
||||
LAST_ID = 112
|
||||
}
|
||||
class FaultAttributes {
|
||||
cookBookRef: number;
|
||||
@ -9628,6 +9629,8 @@ declare namespace ts {
|
||||
private handlePropertyAccessExpression;
|
||||
private handlePropertyDeclaration;
|
||||
private handleSendableClassProperty;
|
||||
private checkTypeAliasInSendableScope;
|
||||
private isNoneSendableTypeAlias;
|
||||
private handlePropertyAssignment;
|
||||
private handlePropertySignature;
|
||||
private handleSendableInterfaceProperty;
|
||||
|
Loading…
Reference in New Issue
Block a user