From 876895290c701b176d40f0a620507c5918768ef0 Mon Sep 17 00:00:00 2001 From: bofeng Date: Fri, 20 Sep 2024 10:42:49 +0800 Subject: [PATCH] refine --- cocos/spine/lib/spine-define.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cocos/spine/lib/spine-define.ts b/cocos/spine/lib/spine-define.ts index f1f13d46382..c6592b79b23 100644 --- a/cocos/spine/lib/spine-define.ts +++ b/cocos/spine/lib/spine-define.ts @@ -28,10 +28,21 @@ import spine from './spine-core.js'; import { js } from '../../core'; function resizeArray (array, newSize): Array { - if (!array) return new Array(newSize); - if (newSize === array.length) return array; - if (newSize < array.length) return array.slice(0, newSize); - else return new Array(newSize); + if (!array) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return new Array(newSize); + } + if (newSize === array.length) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return array; + } + if (newSize < array.length) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return array.slice(0, newSize); + } else { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return new Array(newSize); + } } function overrideDefineArrayProp (prototype: any, getPropVector: any, name: string): void { @@ -44,6 +55,7 @@ function overrideDefineArrayProp (prototype: any, getPropVector: any, name: stri array = resizeArray(array, count); for (let i = 0; i < count; i++) array[i] = vectors.get(i); this[_name] = array; + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return array; }, }); @@ -82,6 +94,7 @@ function overrideDefineArrayFunction (prototype: any, getPropVector: any, name: array = resizeArray(array, count); for (let i = 0; i < count; i++) array[i] = vectors.get(i); this[_name] = array; + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return array; }, }); @@ -121,7 +134,6 @@ function overrideClass (wasm): void { spine.Event = wasm.Event; spine.EventData = wasm.EventData; spine.Attachment = wasm.Attachment; - spine.SpineAnimationState = wasm.SpineAnimationState; spine.VertexAttachment = wasm.VertexAttachment; spine.BoundingBoxAttachment = wasm.BoundingBoxAttachment; spine.ClippingAttachment = wasm.ClippingAttachment;