From 4393080acf4bee91b41177cc6081d1e66a7a4d06 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Wed, 17 May 2017 10:54:30 +0800 Subject: [PATCH] refine creator.d.ts --- cocos2d/core/components/CCComponent.js | 10 +++++----- cocos2d/core/load-pipeline/CCLoader.js | 18 +++++++++--------- cocos2d/core/platform/CCClass.js | 2 +- cocos2d/core/platform/CCClassDecorator.js | 8 ++++---- cocos2d/core/utils/base-node.js | 10 +++++----- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index a871271a34..2ad0d3890e 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -333,7 +333,7 @@ var Component = cc.Class({ * var sprite = node.addComponent(cc.Sprite); * var test = node.addComponent("Test"); * @typescript - * addComponent(type: {new(): T; }): T + * addComponent(type: typeof T): T * addComponent(className: string): any */ addComponent (typeOrClassName) { @@ -357,7 +357,7 @@ var Component = cc.Class({ * // get custom test calss. * var test = node.getComponent("Test"); * @typescript - * getComponent(type: {new(): T; }): T + * getComponent(type: typeof T): T * getComponent(className: string): any */ getComponent (typeOrClassName) { @@ -375,7 +375,7 @@ var Component = cc.Class({ * var sprites = node.getComponents(cc.Sprite); * var tests = node.getComponents("Test"); * @typescript - * getComponents(type: {new(): T; }): T[] + * getComponents(type: typeof T): T[] * getComponents(className: string): any[] */ getComponents (typeOrClassName) { @@ -393,7 +393,7 @@ var Component = cc.Class({ * var sprite = node.getComponentInChildren(cc.Sprite); * var Test = node.getComponentInChildren("Test"); * @typescript - * getComponentInChildren(type: {new(): T; }): T + * getComponentInChildren(type: typeof T): T * getComponentInChildren(className: string): any */ getComponentInChildren (typeOrClassName) { @@ -411,7 +411,7 @@ var Component = cc.Class({ * var sprites = node.getComponentsInChildren(cc.Sprite); * var tests = node.getComponentsInChildren("Test"); * @typescript - * getComponentsInChildren(type: {new(): T; }): T[] + * getComponentsInChildren(type: typeof T): T[] * getComponentsInChildren(className: string): any[] */ getComponentsInChildren (typeOrClassName) { diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js index 4f4a07770c..0af9e49ee2 100644 --- a/cocos2d/core/load-pipeline/CCLoader.js +++ b/cocos2d/core/load-pipeline/CCLoader.js @@ -409,9 +409,9 @@ proto._parseLoadResArgs = function (type, onProgress, onComplete) { * cc.log('Result should be a sprite frame: ' + (spriteFrame instanceof cc.SpriteFrame)); * }); * @typescript - * loadRes(url: string, type: {new (): cc.Asset}, progressCallback: Function, completeCallback: ((error: Error, resource: any) => void)|null): void - * loadRes(url: string, type: {new (): cc.Asset}, completeCallback: (error: Error, resource: any) => void): void - * loadRes(url: string, type: {new (): cc.Asset}): void + * loadRes(url: string, type: typeof cc.Asset, progressCallback: Function, completeCallback: ((error: Error, resource: any) => void)|null): void + * loadRes(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any) => void): void + * loadRes(url: string, type: typeof cc.Asset): void * loadRes(url: string, progressCallback: Function, completeCallback: ((error: Error, resource: any) => void)|null): void * loadRes(url: string, completeCallback: (error: Error, resource: any) => void): void * loadRes(url: string): void @@ -522,9 +522,9 @@ proto._loadResUuids = function (uuids, progressCallback, completeCallback, urls) * // ... * }); * @typescript - * loadResArray(url: string[], type: {new (): cc.Asset}, progressCallback: Function, completeCallback: ((error: Error, resource: any[]) => void)|null): void - * loadResArray(url: string[], type: {new (): cc.Asset}, completeCallback: (error: Error, resource: any[]) => void): void - * loadResArray(url: string[], type: {new (): cc.Asset}): void + * loadResArray(url: string[], type: typeof cc.Asset, progressCallback: Function, completeCallback: ((error: Error, resource: any[]) => void)|null): void + * loadResArray(url: string[], type: typeof cc.Asset, completeCallback: (error: Error, resource: any[]) => void): void + * loadResArray(url: string[], type: typeof cc.Asset): void * loadResArray(url: string[], progressCallback: Function, completeCallback: ((error: Error, resource: any[]) => void)|null): void * loadResArray(url: string[], completeCallback: (error: Error, resource: any[]) => void): void * loadResArray(url: string[]): void @@ -591,9 +591,9 @@ proto.loadResArray = function (urls, type, progressCallback, completeCallback) { * var url = urls[0]; * }); * @typescript - * loadResDir(url: string, type: {new (): cc.Asset}, progressCallback: Function, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void - * loadResDir(url: string, type: {new (): cc.Asset}, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void - * loadResDir(url: string, type: {new (): cc.Asset}): void + * loadResDir(url: string, type: typeof cc.Asset, progressCallback: Function, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void + * loadResDir(url: string, type: typeof cc.Asset, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void + * loadResDir(url: string, type: typeof cc.Asset): void * loadResDir(url: string, progressCallback: Function, completeCallback: ((error: Error, resource: any[], urls: string[]) => void)|null): void * loadResDir(url: string, completeCallback: (error: Error, resource: any[], urls: string[]) => void): void * loadResDir(url: string): void diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index f816e0ef6f..0f2fef2ffc 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -769,7 +769,7 @@ function declareProperties (cls, className, properties, baseClass, mixins, es6) * * @param {Object} [options.editor] - attributes for Component listed below. * @param {Boolean} [options.editor.executeInEditMode=false] - Allows the current component to run in edit mode. By default, all components are executed only at runtime, meaning that they will not have their callback functions executed while the Editor is in edit mode. - * @param {Component} [options.editor.requireComponent] - Automatically add required component as a dependency. + * @param {Function} [options.editor.requireComponent] - Automatically add required component as a dependency. * @param {String} [options.editor.menu] - The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera". * @param {Number} [options.editor.executionOrder=0] - The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected. * @param {Boolean} [options.editor.disallowMultiple] - If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node. diff --git a/cocos2d/core/platform/CCClassDecorator.js b/cocos2d/core/platform/CCClassDecorator.js index 09837e31c5..60f4983f95 100644 --- a/cocos2d/core/platform/CCClassDecorator.js +++ b/cocos2d/core/platform/CCClassDecorator.js @@ -194,8 +194,8 @@ var ccclass = checkCtorArgument(function (ctor, name) { * @method property * @param {Object} [options] - an object with some property attributes * @param {Any} [options.type] - * @param {RawAsset} [options.url] - * @param {Boolean} [options.visible] + * @param {Function} [options.url] + * @param {Boolean|Function} [options.visible] * @param {String} [options.displayName] * @param {String} [options.tooltip] * @param {Boolean} [options.multiline] @@ -286,7 +286,7 @@ var ccclass = checkCtorArgument(function (ctor, name) { * } * }); * @typescript - * property(options?: {type?: any; url?: cc.RawAsset; visible?: boolean; displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; editorOnly?: boolean; override?: boolean; animatable?: boolean; default?: any}): Function + * property(options?: {type?: any; url?: typeof cc.RawAsset; visible?: boolean|(() => boolean); displayName?: string; tooltip?: string; multiline?: boolean; readonly?: boolean; min?: number; max?: number; step?: number; range?: number[]; slide?: boolean; serializable?: boolean; editorOnly?: boolean; override?: boolean; animatable?: boolean; default?: any}): Function * property(_target: Object, _key: any, _desc?: any): void */ function property (ctorProtoOrOptions, propName, desc) { @@ -418,7 +418,7 @@ var executeInEditMode = (CC_DEV ? createEditorDecorator : createDummyDecorator)( * // ... * } * @typescript - * requireComponent(requiredComponent: {new (): cc.Component}): Function + * requireComponent(requiredComponent: typeof cc.Component): Function */ var requireComponent = createEditorDecorator(checkCompArgument, 'requireComponent'); diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index 71094f9d38..f4f516d2c9 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -705,7 +705,7 @@ var BaseNode = cc.Class({ * // get custom test calss. * var test = node.getComponent("Test"); * @typescript - * getComponent(type: {new(): T; }): T + * getComponent(type: typeof T): T * getComponent(className: string): any */ getComponent (typeOrClassName) { @@ -726,7 +726,7 @@ var BaseNode = cc.Class({ * var sprites = node.getComponents(cc.Sprite); * var tests = node.getComponents("Test"); * @typescript - * getComponents(type: {new(): T; }): T[] + * getComponents(type: typeof T): T[] * getComponents(className: string): any[] */ getComponents (typeOrClassName) { @@ -747,7 +747,7 @@ var BaseNode = cc.Class({ * var sprite = node.getComponentInChildren(cc.Sprite); * var Test = node.getComponentInChildren("Test"); * @typescript - * getComponentInChildren(type: {new(): T; }): T + * getComponentInChildren(type: typeof T): T * getComponentInChildren(className: string): any */ getComponentInChildren (typeOrClassName) { @@ -768,7 +768,7 @@ var BaseNode = cc.Class({ * var sprites = node.getComponentsInChildren(cc.Sprite); * var tests = node.getComponentsInChildren("Test"); * @typescript - * getComponentsInChildren(type: {new(): T; }): T[] + * getComponentsInChildren(type: typeof T): T[] * getComponentsInChildren(className: string): any[] */ getComponentsInChildren (typeOrClassName) { @@ -804,7 +804,7 @@ var BaseNode = cc.Class({ * var sprite = node.addComponent(cc.Sprite); * var test = node.addComponent("Test"); * @typescript - * addComponent(type: {new(): T; }): T + * addComponent(type: typeof T): T * addComponent(className: string): any */ addComponent (typeOrClassName) {