From fac20f8df1928d6b44ccc83c8a4d9fb5703a441e Mon Sep 17 00:00:00 2001 From: Leslie Leigh Date: Fri, 21 Jun 2019 09:35:20 +0800 Subject: [PATCH] bug fix; typing loadres (#4664) --- cocos/components/animation-component.ts | 11 +++++++---- cocos/load-pipeline/CCLoader.ts | 22 ++++++++++++++++++++++ cocos/load-pipeline/callback-params.ts | 8 ++++++-- rollup/src/build-engine.ts | 2 +- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/cocos/components/animation-component.ts b/cocos/components/animation-component.ts index 66f5186bd3..97e18d0d39 100644 --- a/cocos/components/animation-component.ts +++ b/cocos/components/animation-component.ts @@ -437,10 +437,13 @@ export class AnimationComponent extends Component implements IEventTarget { } private _removeStateOfAutomaticClip (clip: AnimationClip) { - const state = this._nameToState[name]; - if (state && equalClips(clip, state.clip)) { - state.stop(); - delete this._nameToState[name]; + // tslint:disable-next-line:forin + for (const name in this._nameToState) { + const state = this._nameToState[name]; + if (equalClips(clip, state.clip)) { + state.stop(); + delete this._nameToState[name]; + } } } diff --git a/cocos/load-pipeline/CCLoader.ts b/cocos/load-pipeline/CCLoader.ts index 351e9c6565..b1fe9f0663 100644 --- a/cocos/load-pipeline/CCLoader.ts +++ b/cocos/load-pipeline/CCLoader.ts @@ -38,6 +38,7 @@ import { callInNextTick } from '../core/utils/misc'; import AssetLoader from './asset-loader'; import AssetTable from './asset-table'; import { getDependsRecursively } from './auto-release-utils'; +import { LoadCompleteCallback, LoadProgressCallback } from './callback-params'; import Downloader from './downloader'; import Loader from './loader'; import LoadingItems from './loading-items'; @@ -401,6 +402,27 @@ class CCLoader extends Pipeline { return accepted; } + public loadRes ( + url: string, + type: Constructor, + mount: string, + progressCallback: LoadProgressCallback, + completeCallback: LoadCompleteCallback, + ); + + public loadRes ( + url: string, + type: Constructor, + progressCallback: LoadProgressCallback, + completeCallback: LoadCompleteCallback, + ); + + public loadRes ( + url: string, + type: Constructor, + completeCallback: LoadCompleteCallback, + ); + // @typescript // loadRes(url: string, type: typeof cc.Asset, progressCallback: (completedCount: number, totalCount: number, item: any) => void, completeCallback: ((error: Error, resource: any) => void)|null): void // loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void diff --git a/cocos/load-pipeline/callback-params.ts b/cocos/load-pipeline/callback-params.ts index dfe153e019..dec8c35ba1 100644 --- a/cocos/load-pipeline/callback-params.ts +++ b/cocos/load-pipeline/callback-params.ts @@ -1,5 +1,9 @@ -type LoadSuccessParams = Parameters<(error: null, asset: T) => void>; +type LoadSuccessParams = Parameters<(error: null | undefined, asset: T) => void>; -type LoadErrorParams = Parameters<(error?: Error) => void>; +type LoadErrorParams = Parameters<(error: Error) => void>; export type LoadCallbackParams = LoadSuccessParams | LoadErrorParams; + +export type LoadCompleteCallback = (...args: LoadCallbackParams) => void; + +export type LoadProgressCallback = (completedCount: number, totalCount: number, item: any) => void; diff --git a/rollup/src/build-engine.ts b/rollup/src/build-engine.ts index 499adb167d..7da08d6e86 100644 --- a/rollup/src/build-engine.ts +++ b/rollup/src/build-engine.ts @@ -54,7 +54,7 @@ async function _doBundle (options: IBuildOptions) { extensions: ['.js', '.ts'], highlightCode: true, ignore: [ - 'node_modules/**', + 'node_modules/cannon/**', ], plugins: [ ['@babel/plugin-proposal-decorators', {