!298 Fix ArkTSLinter readonly array bug for 4.1release

Merge pull request !298 from ironrain/work_0304_None_Release_1
This commit is contained in:
openharmony_ci 2024-03-05 12:47:07 +00:00 committed by Gitee
commit 7b55431f35
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 41 additions and 5 deletions

View File

@ -193409,6 +193409,12 @@ var ts;
((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "Array");
}
Utils.isGenericArrayType = isGenericArrayType;
function isReadonlyArrayType(tsType) {
var _a, _b, _c;
return (isTypeReference(tsType) && ((_a = tsType.typeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1 && ((_b = tsType.target.typeParameters) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
(((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "ReadonlyArray"));
}
Utils.isReadonlyArrayType = isReadonlyArrayType;
function isTypedArray(tsType) {
var symbol = tsType.symbol;
if (!symbol) {
@ -193419,7 +193425,7 @@ var ts;
}
Utils.isTypedArray = isTypedArray;
function isArray(tsType) {
return isGenericArrayType(tsType) || isTypedArray(tsType);
return isGenericArrayType(tsType) || isReadonlyArrayType(tsType) || isTypedArray(tsType);
}
Utils.isArray = isArray;
function isTuple(tsType) {

View File

@ -13196,6 +13196,7 @@ declare namespace ts {
function isPrimitiveType(type: Type): boolean;
function isTypeSymbol(symbol: Symbol | undefined): boolean;
function isGenericArrayType(tsType: Type): tsType is TypeReference;
function isReadonlyArrayType(tsType: Type): boolean;
function isTypedArray(tsType: ts.Type): boolean;
function isArray(tsType: ts.Type): boolean;
function isTuple(tsType: ts.Type): boolean;

View File

@ -193154,6 +193154,12 @@ var ts;
((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "Array");
}
Utils.isGenericArrayType = isGenericArrayType;
function isReadonlyArrayType(tsType) {
var _a, _b, _c;
return (isTypeReference(tsType) && ((_a = tsType.typeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1 && ((_b = tsType.target.typeParameters) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
(((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "ReadonlyArray"));
}
Utils.isReadonlyArrayType = isReadonlyArrayType;
function isTypedArray(tsType) {
var symbol = tsType.symbol;
if (!symbol) {
@ -193164,7 +193170,7 @@ var ts;
}
Utils.isTypedArray = isTypedArray;
function isArray(tsType) {
return isGenericArrayType(tsType) || isTypedArray(tsType);
return isGenericArrayType(tsType) || isReadonlyArrayType(tsType) || isTypedArray(tsType);
}
Utils.isArray = isArray;
function isTuple(tsType) {

1
lib/typescript.d.ts vendored
View File

@ -9257,6 +9257,7 @@ declare namespace ts {
function isPrimitiveType(type: Type): boolean;
function isTypeSymbol(symbol: Symbol | undefined): boolean;
function isGenericArrayType(tsType: Type): tsType is TypeReference;
function isReadonlyArrayType(tsType: Type): boolean;
function isTypedArray(tsType: ts.Type): boolean;
function isArray(tsType: ts.Type): boolean;
function isTuple(tsType: ts.Type): boolean;

View File

@ -182248,6 +182248,12 @@ var ts;
((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "Array");
}
Utils.isGenericArrayType = isGenericArrayType;
function isReadonlyArrayType(tsType) {
var _a, _b, _c;
return (isTypeReference(tsType) && ((_a = tsType.typeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1 && ((_b = tsType.target.typeParameters) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
(((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "ReadonlyArray"));
}
Utils.isReadonlyArrayType = isReadonlyArrayType;
function isTypedArray(tsType) {
var symbol = tsType.symbol;
if (!symbol) {
@ -182258,7 +182264,7 @@ var ts;
}
Utils.isTypedArray = isTypedArray;
function isArray(tsType) {
return isGenericArrayType(tsType) || isTypedArray(tsType);
return isGenericArrayType(tsType) || isReadonlyArrayType(tsType) || isTypedArray(tsType);
}
Utils.isArray = isArray;
function isTuple(tsType) {

View File

@ -9257,6 +9257,7 @@ declare namespace ts {
function isPrimitiveType(type: Type): boolean;
function isTypeSymbol(symbol: Symbol | undefined): boolean;
function isGenericArrayType(tsType: Type): tsType is TypeReference;
function isReadonlyArrayType(tsType: Type): boolean;
function isTypedArray(tsType: ts.Type): boolean;
function isArray(tsType: ts.Type): boolean;
function isTuple(tsType: ts.Type): boolean;

View File

@ -182248,6 +182248,12 @@ var ts;
((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "Array");
}
Utils.isGenericArrayType = isGenericArrayType;
function isReadonlyArrayType(tsType) {
var _a, _b, _c;
return (isTypeReference(tsType) && ((_a = tsType.typeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1 && ((_b = tsType.target.typeParameters) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
(((_c = tsType.getSymbol()) === null || _c === void 0 ? void 0 : _c.getName()) === "ReadonlyArray"));
}
Utils.isReadonlyArrayType = isReadonlyArrayType;
function isTypedArray(tsType) {
var symbol = tsType.symbol;
if (!symbol) {
@ -182258,7 +182264,7 @@ var ts;
}
Utils.isTypedArray = isTypedArray;
function isArray(tsType) {
return isGenericArrayType(tsType) || isTypedArray(tsType);
return isGenericArrayType(tsType) || isReadonlyArrayType(tsType) || isTypedArray(tsType);
}
Utils.isArray = isArray;
function isTuple(tsType) {

View File

@ -444,6 +444,13 @@ export function isGenericArrayType(tsType: Type): tsType is TypeReference {
);
}
export function isReadonlyArrayType(tsType: Type): boolean {
return (
isTypeReference(tsType) && tsType.typeArguments?.length === 1 && tsType.target.typeParameters?.length === 1 &&
(tsType.getSymbol()?.getName() === "ReadonlyArray")
);
}
export function isTypedArray(tsType: ts.Type): boolean {
const symbol = tsType.symbol;
if (!symbol) {
@ -454,7 +461,7 @@ export function isTypedArray(tsType: ts.Type): boolean {
}
export function isArray(tsType: ts.Type): boolean {
return isGenericArrayType(tsType) || isTypedArray(tsType);
return isGenericArrayType(tsType) || isReadonlyArrayType(tsType) || isTypedArray(tsType);
}
export function isTuple(tsType: ts.Type): boolean {

View File

@ -13196,6 +13196,7 @@ declare namespace ts {
function isPrimitiveType(type: Type): boolean;
function isTypeSymbol(symbol: Symbol | undefined): boolean;
function isGenericArrayType(tsType: Type): tsType is TypeReference;
function isReadonlyArrayType(tsType: Type): boolean;
function isTypedArray(tsType: ts.Type): boolean;
function isArray(tsType: ts.Type): boolean;
function isTuple(tsType: ts.Type): boolean;

View File

@ -9257,6 +9257,7 @@ declare namespace ts {
function isPrimitiveType(type: Type): boolean;
function isTypeSymbol(symbol: Symbol | undefined): boolean;
function isGenericArrayType(tsType: Type): tsType is TypeReference;
function isReadonlyArrayType(tsType: Type): boolean;
function isTypedArray(tsType: ts.Type): boolean;
function isArray(tsType: ts.Type): boolean;
function isTuple(tsType: ts.Type): boolean;