Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed #16594: getComponent() can't support abstract class. #16917

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

dumganhar
Copy link
Contributor

@dumganhar dumganhar commented Apr 22, 2024

Update ccbuild to 2.2.10,

Re: #16594

cocos/cocos-ccbuild#63

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@dumganhar dumganhar requested a review from minggo April 22, 2024 02:26
Copy link

github-actions bot commented Apr 22, 2024

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -19656,9 +19656,9 @@
      * // }
      * BitMask(obj);
      * ```
      */
-    export function BitMask<T>(obj: T): T;
+    export function BitMask<T extends object>(obj: T): T;
     export namespace BitMask {
         export var isBitMask: (BitMaskType: any) => any;
         export var getList: (BitMaskDef: any) => any;
         export var update: (BitMaskDef: any) => any;
@@ -19677,14 +19677,14 @@
      * @en A JavaScript literal object containing enum names and values, or a TypeScript enum type.
      * @zh 包含枚举名和值的 JavaScript literal 对象,或者是一个 TypeScript enum 类型。
      * @return @en The defined enum type. @zh 定义的枚举类型。
      */
-    export function Enum<T>(obj: T): T;
+    export function Enum<T extends object>(obj: T): T;
     export namespace Enum {
-        export var update: <T>(obj: T) => T;
-        export var isEnum: <EnumT extends {}>(enumType: EnumT) => boolean;
-        export var getList: <EnumT extends {}>(enumType: EnumT) => readonly __private._cocos_core_value_types_enum__Enum.Enumerator<EnumT>[];
-        export var sortList: <EnumT extends {}>(enumType: EnumT, compareFn: (a: any, b: any) => number) => void;
+        export var update: <T extends object>(obj: T) => T;
+        export var isEnum: <EnumT extends object>(enumType: EnumT) => boolean;
+        export var getList: <EnumT extends object>(enumType: EnumT) => readonly __private._cocos_core_value_types_enum__Enum.Enumerator<EnumT>[];
+        export var sortList: <EnumT extends object>(enumType: EnumT, compareFn: (a: any, b: any) => number) => void;
     }
     /**
      * Make the enum type `enumType` as enumeration so that Creator may identify, operate on it.
      * Formally, as a result of invocation on this function with enum type `enumType`:
@@ -19693,9 +19693,9 @@
      * @param
      * @en enumType An enum type, eg, a kind of type with similar semantic defined by TypeScript.
      * @zh 枚举类型,例如 TypeScript 中定义的类型。
      */
-    export function ccenum<EnumT extends {}>(enumType: EnumT): void;
+    export function ccenum<EnumT extends object>(enumType: EnumT): void;
     /**
      * @en The base class of all value types.
      * @zh 所有值类型的基类。
      */
@@ -62173,14 +62173,14 @@
          * @en A JavaScript literal object containing enum names and values, or a TypeScript enum type.
          * @zh 包含枚举名和值的 JavaScript literal 对象,或者是一个 TypeScript enum 类型。
          * @return @en The defined enum type. @zh 定义的枚举类型。
          */
-        export function _cocos_core_value_types_enum__Enum<T>(obj: T): T;
+        export function _cocos_core_value_types_enum__Enum<T extends object>(obj: T): T;
         export namespace _cocos_core_value_types_enum__Enum {
-            var update: <T>(obj: T) => T;
-            var isEnum: <EnumT extends {}>(enumType: EnumT) => boolean;
-            var getList: <EnumT extends {}>(enumType: EnumT) => readonly _cocos_core_value_types_enum__Enum.Enumerator<EnumT>[];
-            var sortList: <EnumT extends {}>(enumType: EnumT, compareFn: (a: any, b: any) => number) => void;
+            var update: <T extends object>(obj: T) => T;
+            var isEnum: <EnumT extends object>(enumType: EnumT) => boolean;
+            var getList: <EnumT extends object>(enumType: EnumT) => readonly _cocos_core_value_types_enum__Enum.Enumerator<EnumT>[];
+            var sortList: <EnumT extends object>(enumType: EnumT, compareFn: (a: any, b: any) => number) => void;
         }
         export namespace _cocos_core_value_types_enum__Enum {
             interface Enumerator<EnumT> {
                 /**
@@ -63883,9 +63883,9 @@
              */
             getBubblingTargets(type: string, targets: Node[]): void;
             onUpdatingSiblingIndex(): void;
         }
-        export type __types_globals__AbstractedConstructor<T = unknown> = new (...args: any[]) => T;
+        export type __types_globals__AbstractedConstructor<T = unknown> = abstract new (...args: any[]) => T;
         /**
          * @en Node's UI properties abstraction
          * @zh 节点上 UI 相关的属性抽象类
          */
@@ -65669,40 +65669,40 @@
              * @language zh_CN
              */
             Single = 5
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__EXT_color_buffer_half_float {
+        export interface __node_modules_typescript_lib_libdom__EXT_color_buffer_half_float {
             readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum;
             readonly RGB16F_EXT: GLenum;
             readonly RGBA16F_EXT: GLenum;
             readonly UNSIGNED_NORMALIZED_EXT: GLenum;
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__EXT_color_buffer_half_float {
+        export interface __node_modules_typescript_lib_libdom__EXT_color_buffer_half_float {
             readonly RGBA16F_EXT: GLenum;
             readonly RGB16F_EXT: GLenum;
             readonly FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: GLenum;
             readonly UNSIGNED_NORMALIZED_EXT: GLenum;
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_multi_draw {
+        export interface __node_modules_typescript_lib_libdom__WEBGL_multi_draw {
             multiDrawArraysInstancedWEBGL(mode: GLenum, firstsList: Int32Array | GLint[], firstsOffset: GLuint, countsList: Int32Array | GLsizei[], countsOffset: GLuint, instanceCountsList: Int32Array | GLsizei[], instanceCountsOffset: GLuint, drawcount: GLsizei): void;
             multiDrawArraysWEBGL(mode: GLenum, firstsList: Int32Array | GLint[], firstsOffset: GLuint, countsList: Int32Array | GLsizei[], countsOffset: GLuint, drawcount: GLsizei): void;
             multiDrawElementsInstancedWEBGL(mode: GLenum, countsList: Int32Array | GLsizei[], countsOffset: GLuint, type: GLenum, offsetsList: Int32Array | GLsizei[], offsetsOffset: GLuint, instanceCountsList: Int32Array | GLsizei[], instanceCountsOffset: GLuint, drawcount: GLsizei): void;
             multiDrawElementsWEBGL(mode: GLenum, countsList: Int32Array | GLsizei[], countsOffset: GLuint, type: GLenum, offsetsList: Int32Array | GLsizei[], offsetsOffset: GLuint, drawcount: GLsizei): void;
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_multi_draw {
+        export interface __node_modules_typescript_lib_libdom__WEBGL_multi_draw {
             multiDrawArraysWEBGL(mode: GLenum, firstsList: GLint[] | Int32Array, firstsOffset: GLuint, countsList: GLsizei[] | Int32Array, countsOffset: GLuint, drawCount: GLsizei): void;
             multiDrawElementsWEBGL(mode: GLenum, countsList: GLint[] | Int32Array, countsOffset: GLuint, type: GLenum, offsetsList: GLsizei[] | Int32Array, OffsetsOffset: GLuint, drawCount: GLsizei): void;
             multiDrawArraysInstancedWEBGL(mode: GLenum, firstsList: GLint[] | Int32Array, firstsOffset: GLuint, countsList: GLsizei[] | Int32Array, countsOffset: GLuint, instanceCountsList: GLsizei[] | Int32Array, instanceCountsOffset: GLuint, drawCount: GLsizei): void;
             multiDrawElementsInstancedWEBGL(mode: GLenum, countsList: GLint[] | Int32Array, countsOffset: GLuint, type: GLenum, offsetsList: GLsizei[] | Int32Array, OffsetsOffset: GLuint, instanceCountsList: GLsizei[] | Int32Array, instanceCountsOffset: GLuint, drawCount: GLsizei): void;
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 {
+        export interface __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 {
             readonly COMPRESSED_RGB_ETC1_WEBGL: GLenum;
         }
         // note that ETC1 is not supported with the compressedTexSubImage2D() method
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 {
+        export interface __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 {
             readonly COMPRESSED_RGB_ETC1_WEBGL: GLenum;
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc {
+        export interface __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc {
             readonly COMPRESSED_R11_EAC: GLenum;
             readonly COMPRESSED_RG11_EAC: GLenum;
             readonly COMPRESSED_RGB8_ETC2: GLenum;
             readonly COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: GLenum;
@@ -65712,9 +65712,9 @@
             readonly COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: GLenum;
             readonly COMPRESSED_SRGB8_ETC2: GLenum;
             readonly COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: GLenum;
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc {
+        export interface __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc {
             readonly COMPRESSED_R11_EAC: GLenum;
             readonly COMPRESSED_SIGNED_R11_EAC: GLenum;
             readonly COMPRESSED_RG11_EAC: GLenum;
             readonly COMPRESSED_SIGNED_RG11_EAC: GLenum;
@@ -65737,13 +65737,13 @@
             EXT_frag_depth: EXT_frag_depth | null;
             EXT_shader_texture_lod: EXT_shader_texture_lod | null;
             EXT_sRGB: EXT_sRGB | null;
             OES_vertex_array_object: OES_vertex_array_object | null;
-            EXT_color_buffer_half_float: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__EXT_color_buffer_half_float | null;
-            WEBGL_multi_draw: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_multi_draw | null;
+            EXT_color_buffer_half_float: __node_modules_typescript_lib_libdom__EXT_color_buffer_half_float | null;
+            WEBGL_multi_draw: __node_modules_typescript_lib_libdom__WEBGL_multi_draw | null;
             WEBGL_color_buffer_float: WEBGL_color_buffer_float | null;
-            WEBGL_compressed_texture_etc1: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 | null;
-            WEBGL_compressed_texture_etc: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc | null;
+            WEBGL_compressed_texture_etc1: __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 | null;
+            WEBGL_compressed_texture_etc: __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc | null;
             WEBGL_compressed_texture_pvrtc: __types_webGLextras__WEBGL_compressed_texture_pvrtc | null;
             WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null;
             WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null;
             WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null;
@@ -65829,19 +65829,19 @@
             constructor();
             destroy(): void;
             draw(gpuTextureSrc: _cocos_gfx_webgl_webgl_gpu_objects__IWebGLGPUTexture, gpuTextureDst: _cocos_gfx_webgl_webgl_gpu_objects__IWebGLGPUTexture, regions: gfx.TextureBlit[], filter: gfx.Filter): void;
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__EXT_color_buffer_float {
+        export interface __node_modules_typescript_lib_libdom__EXT_color_buffer_float {
         }
-        export interface __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__EXT_color_buffer_float {
+        export interface __node_modules_typescript_lib_libdom__EXT_color_buffer_float {
         }
         export interface _cocos_gfx_webgl2_webgl2_define__IWebGL2Extensions {
             EXT_texture_filter_anisotropic: EXT_texture_filter_anisotropic | null;
-            EXT_color_buffer_half_float: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__EXT_color_buffer_half_float | null;
-            EXT_color_buffer_float: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__EXT_color_buffer_float | null;
-            WEBGL_multi_draw: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_multi_draw | null;
-            WEBGL_compressed_texture_etc1: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 | null;
-            WEBGL_compressed_texture_etc: __node_modules_cocos_ccbuild_node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc | null;
+            EXT_color_buffer_half_float: __node_modules_typescript_lib_libdom__EXT_color_buffer_half_float | null;
+            EXT_color_buffer_float: __node_modules_typescript_lib_libdom__EXT_color_buffer_float | null;
+            WEBGL_multi_draw: __node_modules_typescript_lib_libdom__WEBGL_multi_draw | null;
+            WEBGL_compressed_texture_etc1: __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc1 | null;
+            WEBGL_compressed_texture_etc: __node_modules_typescript_lib_libdom__WEBGL_compressed_texture_etc | null;
             WEBGL_compressed_texture_pvrtc: __types_webGLextras__WEBGL_compressed_texture_pvrtc | null;
             WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null;
             WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null;
             WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null;

@dumganhar dumganhar requested a review from minggo April 22, 2024 03:10
@@ -95,7 +95,7 @@ export function BitMask<T> (obj: T): T {
* @returns @en True if it is a BitMask, false else.
* @zh 如果是 BitMask,返回 true;否则返回 false。
*/
BitMask.isBitMask = (BitMaskType): any => BitMaskType && BitMaskType.hasOwnProperty('__bitmask__');
BitMask.isBitMask = (BitMaskType): any => BitMaskType && Object.prototype.hasOwnProperty.call(BitMaskType, '__bitmask__');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change it?

Copy link
Contributor Author

@dumganhar dumganhar Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix an ESLint error:

Do not access Object.prototype method 'hasOwnProperty' from target object.eslintno-prototype-builtins

ESLint doesn't suggest to use obj.hasOwnProperty on target object since target object may contain a same key hasOwnProperty to override the original behavior.

}

/**
* Get the enumerators from the enum type.
* @param enumType @en An enum type. @zh 枚举类型。
*/
Enum.getList = <EnumT extends {}>(enumType: EnumT): readonly Enum.Enumerator<EnumT>[] => {
Enum.getList = <EnumT extends object>(enumType: EnumT): readonly Enum.Enumerator<EnumT>[] => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix an eslint error:

Don't use {} as a type. {} actually means "any non-nullish value".

  • If you want a type meaning "any object", you probably want object instead.
  • If you want a type meaning "any value", you probably want unknown instead.
  • If you want a type meaning "empty object", you probably want Record<string, never> instead.
  • If you really want a type meaning "any non-nullish value", you probably want NonNullable<unknown> instead.eslint@typescript-eslint/ban-types

@dumganhar dumganhar requested a review from minggo April 22, 2024 03:37
@dumganhar
Copy link
Contributor Author

@cocos-robot run test cases

@dumganhar dumganhar merged commit 340e30d into cocos:v3.8.4 Apr 22, 2024
9 checks passed
"integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==",
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade the default typescript cause typedoc failed since we're using typedoc v0.22.13 which depends on typescript <= 4.7. Perhaps, we need to update typedoc version now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants