diff --git a/cocos/animation/marionette/pose-graph/instantiation.ts b/cocos/animation/marionette/pose-graph/instantiation.ts index ff33b011e1f..0b1db72ed13 100644 --- a/cocos/animation/marionette/pose-graph/instantiation.ts +++ b/cocos/animation/marionette/pose-graph/instantiation.ts @@ -125,9 +125,9 @@ export interface PoseNodeDependencyEvaluation { evaluate(): void; } -function instantiateNode ( +function instantiateNode ( graph: PoseGraph, - node: TNode, + node: EvaluatableNode, instantiationMap: Map, linkContext: PureValueNodeLinkContext, ): RuntimeNodeEvaluation { diff --git a/cocos/animation/marionette/state-machine/state-machine-eval.ts b/cocos/animation/marionette/state-machine/state-machine-eval.ts index 7a794dd1e8d..56114bff2a1 100644 --- a/cocos/animation/marionette/state-machine/state-machine-eval.ts +++ b/cocos/animation/marionette/state-machine/state-machine-eval.ts @@ -196,7 +196,7 @@ class TopLevelStateMachineEvaluation { } } - public getCurrentClipStatuses (): Iterable { + public getCurrentClipStatuses (): Iterable> { const { _currentNode: currentNode } = this; if (currentNode.kind === NodeKind.animation) { return currentNode.getClipStatuses(currentNode.absoluteWeight); @@ -237,7 +237,7 @@ class TopLevelStateMachineEvaluation { return null; } - public getNextClipStatuses (): Iterable { + public getNextClipStatuses (): Iterable> { const { _activatedTransitions: activatedTransitions } = this; if (activatedTransitions.length === 0) { return emptyClipStatusesIterable; @@ -986,20 +986,21 @@ function createStateStatusCache (): MotionStateStatus { }; } -const emptyClipStatusesIterator: Readonly> = Object.freeze({ - next (..._args: [] | [undefined]): IteratorResult { +type ReadonlyClipStatus = Readonly; +const emptyClipStatusesIterator: Iterator = { + next (..._args: [] | [undefined]): IteratorResult { return { done: true, value: undefined, }; }, -}); +}; -const emptyClipStatusesIterable: Iterable = Object.freeze({ +const emptyClipStatusesIterable: Iterable = { [Symbol.iterator] () { return emptyClipStatusesIterator; }, -}); +}; enum NodeKind { entry, exit, any, animation, @@ -1286,7 +1287,7 @@ class VMSMEval { this._privateState.addTransition(transition); } - public getClipStatuses (baseWeight: number): Iterable { + public getClipStatuses (baseWeight: number): Iterable> { const { _source: source } = this; if (!source) { return emptyClipStatusesIterable; @@ -1357,7 +1358,7 @@ class VMSMInternalState extends EventifiedStateEval { return stateStatus; } - public getClipStatuses (baseWeight: number): Iterable { + public getClipStatuses (baseWeight: number): Iterable> { return this._container.getClipStatuses(baseWeight); } diff --git a/cocos/animation/marionette/variable/index.ts b/cocos/animation/marionette/variable/index.ts index bbe24f1e327..4a7647a7e43 100644 --- a/cocos/animation/marionette/variable/index.ts +++ b/cocos/animation/marionette/variable/index.ts @@ -23,7 +23,7 @@ */ import { VariableType, VariableTypeValueTypeMap, VarInstanceBase } from './basic'; -import { PlainVariable } from './primitive-variable'; +import { PlainVariable, PlainVariableType } from './primitive-variable'; import { TriggerVariable } from './trigger-variable'; import { Vec3Variable } from './vec3-variable'; import { QuatVariable } from './quat-variable'; @@ -50,7 +50,7 @@ export function createVariable ( case VariableType.FLOAT: case VariableType.INTEGER: case VariableType.BOOLEAN: - variable = new PlainVariable(type); + variable = new PlainVariable(type as PlainVariableType); break; case VariableType.TRIGGER: variable = new TriggerVariable(); diff --git a/cocos/animation/marionette/variable/primitive-variable.ts b/cocos/animation/marionette/variable/primitive-variable.ts index 8a166bc0077..7bf833388e3 100644 --- a/cocos/animation/marionette/variable/primitive-variable.ts +++ b/cocos/animation/marionette/variable/primitive-variable.ts @@ -3,7 +3,7 @@ import { assertIsTrue } from '../../../core'; import { ccclass, serializable } from '../../../core/data/decorators'; import { BasicVariableDescription, VariableType, createInstanceTag, VarInstanceBase, Value } from './basic'; -type PlainVariableType = VariableType.FLOAT | VariableType.INTEGER | VariableType.BOOLEAN; +export type PlainVariableType = VariableType.FLOAT | VariableType.INTEGER | VariableType.BOOLEAN; @ccclass('cc.animation.PlainVariable') export class PlainVariable { diff --git a/cocos/physics/framework/components/character-controllers/character-controller.ts b/cocos/physics/framework/components/character-controllers/character-controller.ts index eeb13cd5a8f..74a98241ca5 100644 --- a/cocos/physics/framework/components/character-controllers/character-controller.ts +++ b/cocos/physics/framework/components/character-controllers/character-controller.ts @@ -203,7 +203,7 @@ export class CharacterController extends Eventify(Component) { return this._center; } - public set center (value: Vec3) { + public set center (value: Readonly) { if (Vec3.equals(this._center, value)) return; Vec3.copy(this._center, value); // if (this._cct) { //update cct position @@ -312,7 +312,7 @@ export class CharacterController extends Eventify(Component) { * @zh * 设置中心的世界坐标。 */ - public set centerWorldPosition (value: Vec3) { + public set centerWorldPosition (value: Readonly) { if (this._isInitialized) this._cct!.setPosition(value); } diff --git a/cocos/serialization/deserialize-dynamic.ts b/cocos/serialization/deserialize-dynamic.ts index 19e1aeb5769..c8dcd8d27c6 100644 --- a/cocos/serialization/deserialize-dynamic.ts +++ b/cocos/serialization/deserialize-dynamic.ts @@ -85,12 +85,12 @@ type AttributeFormerlySerializedAs = `${AttributeName}${typeof POSTFIX_FORMERLY_ type AttributeDefault = `${AttributeName}${typeof POSTFIX_DEFAULT}`; type AttributeType = `${AttributeName}${typeof POSTFIX_TYPE}`; type AttributeEditorOnly = `${AttributeName}${typeof POSTFIX_EDITOR_ONLY}`; -type AttrResult = { +interface AttrResult { [K: string]: typeof K extends AttributeFormerlySerializedAs ? string : typeof K extends AttributeDefault ? unknown : typeof K extends AttributeType ? AnyFunction : typeof K extends AttributeEditorOnly ? boolean : never; -}; +} function compileDeserializeJIT (self: _Deserializer, klass: CCClassConstructor): CompiledDeserializeFn { const attrs: AttrResult = CCClass.Attr.getClassAttrs(klass); @@ -287,22 +287,22 @@ type TypedArrayViewConstructorName = | 'Uint32Array' | 'Int32Array' | 'Float32Array' | 'Float64Array'; -type SerializedTypedArray = { +interface SerializedTypedArray { __id__: never; __uuid__: never; __type__: 'TypedArray'; array: number[]; ctor: TypedArrayViewConstructorName; -}; +} -type SerializedTypedArrayRef = { +interface SerializedTypedArrayRef { __id__: never; __uuid__: never; __type__: 'TypedArrayRef'; ctor: TypedArrayViewConstructorName; offset: number; length: number; -}; +} type SerializedGeneralTypedObject = { __id__: never; @@ -310,18 +310,18 @@ type SerializedGeneralTypedObject = { __type__?: NotKnownTypeTag; } & Record; -type SerializedObjectReference = { +interface SerializedObjectReference { __type__: never; __uuid__: never; __id__: number; } -type SerializedUUIDReference = { +interface SerializedUUIDReference { __type__: never; __id__: never; __uuid__: string; __expectedType__: string; -}; +} type SerializedObject = SerializedTypedArray | SerializedTypedArrayRef | SerializedGeneralTypedObject; @@ -588,12 +588,10 @@ class _Deserializer { return; } - // cSpell:words Deserializable - - type ClassicCustomizedDeserializable = { _deserialize: (content: unknown, deserializer: _Deserializer) => void; }; + interface ClassicCustomizedDeserializable { _deserialize: (content: unknown, deserializer: _Deserializer) => void; } if ((object as Partial)._deserialize) { // TODO: content check? - (object as ClassicCustomizedDeserializable)._deserialize((value as unknown as { content: unknown }).content, this); + (object as Partial)._deserialize!((value as unknown as { content: unknown }).content, this); return; } @@ -767,18 +765,18 @@ class _Deserializer { klass: SerializableClassConstructor, ): void { if (klass === cclegacy.Vec2) { - type SerializedVec2 = { x?: number; y?: number; }; + interface SerializedVec2 { x?: number; y?: number; } instance.x = (serialized as SerializedVec2).x || 0; instance.y = (serialized as SerializedVec2).y || 0; return; } else if (klass === cclegacy.Vec3) { - type SerializedVec3 = { x?: number; y?: number; z?: number; }; + interface SerializedVec3 { x?: number; y?: number; z?: number; } instance.x = (serialized as SerializedVec3).x || 0; instance.y = (serialized as SerializedVec3).y || 0; instance.z = (serialized as SerializedVec3).z || 0; return; } else if (klass === cclegacy.Color) { - type SerializedColor = { r?: number; g?: number; b?: number; a?: number; }; + interface SerializedColor { r?: number; g?: number; b?: number; a?: number; } instance.r = (serialized as SerializedColor).r || 0; instance.g = (serialized as SerializedColor).g || 0; instance.b = (serialized as SerializedColor).b || 0; @@ -786,7 +784,7 @@ class _Deserializer { instance.a = (a === undefined ? 255 : a); return; } else if (klass === cclegacy.Size) { - type SerializedSize = { width?: number; height?: number; }; + interface SerializedSize { width?: number; height?: number; } instance.width = (serialized as SerializedSize).width || 0; instance.height = (serialized as SerializedSize).height || 0; return; @@ -865,8 +863,8 @@ export function deserializeDynamic (data: SerializedData | CCON, details: Detail return res; } -export function parseUuidDependenciesDynamic (serialized: unknown): never[] { - const depends = []; +export function parseUuidDependenciesDynamic (serialized: unknown): string[] { + const depends: string[] = []; const parseDependRecursively = (data: any, out: string[]): void => { if (!data || typeof data !== 'object' || typeof data.__id__ === 'number') { return; } const uuid = data.__uuid__;