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

Remove strictNullChecks #16327

Closed
wants to merge 1 commit into from
Closed

Conversation

pandamicro
Copy link
Contributor

Re: User feedback to avoid union null type in properties

Changelog

  • Remove strictNullChecks

Avoid having to do the following

class Foo {
    public bar: Node | null = null;

    func () {
        if (this.bar) {
            // ...
        }
    }
}

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.

@github-actions
Copy link

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -992,9 +992,9 @@
         protected _pixelsToUnit: number;
         protected _pivot: math.Vec2;
         protected _meshType: __private._cocos_2d_assets_sprite_frame__MeshType;
         protected _extrude: number;
-        protected _customOutLine: never[];
+        protected _customOutLine: any[];
         protected _mesh: Mesh | null;
         protected _minPos: math.Vec3;
         protected _maxPos: math.Vec3;
         constructor();
@@ -7306,9 +7306,9 @@
      * 动画曲线。
      * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
      */
     export class AnimCurve {
-        static Linear: null;
+        static Linear: any;
         static Bezier(controlPoints: number[]): BezierControlPoints;
         types?: Array<(AnimationClip._legacy.LegacyEasingMethod | null)>;
         type?: AnimationClip._legacy.LegacyEasingMethod | null;
         constructor(propertyCurveData: Omit<AnimationClip._legacy.LegacyClipCurveData, "keys">, duration: number);
@@ -17630,18 +17630,18 @@
             raySphere: (ray: Ray, sphere: Sphere) => number;
             rayAABB: (ray: Ray, aabb: AABB) => number;
             rayOBB: (ray: Ray, obb: OBB) => number;
             rayPlane: (ray: Ray, plane: Plane) => number;
-            rayTriangle: (ray: Ray, triangle: Triangle, doubleSided?: boolean | undefined) => number;
+            rayTriangle: (ray: Ray, triangle: Triangle, doubleSided?: boolean) => number;
             rayCapsule: (ray: Ray, capsule: Capsule) => number;
-            raySubMesh: (ray: Ray, submesh: RenderingSubMesh, options?: IRaySubMeshOptions | undefined) => number;
-            rayMesh: (ray: Ray, mesh: Mesh, options?: IRayMeshOptions | undefined) => number;
-            rayModel: (r: Ray, model: renderer.scene.Model, options?: IRayMeshOptions | undefined) => number;
+            raySubMesh: (ray: Ray, submesh: RenderingSubMesh, options?: IRaySubMeshOptions) => number;
+            rayMesh: (ray: Ray, mesh: Mesh, options?: IRayMeshOptions) => number;
+            rayModel: (r: Ray, model: renderer.scene.Model, options?: IRayModelOptions) => number;
             lineSphere: typeof __private._cocos_core_geometry_intersect__lineSphere;
             lineAABB: typeof __private._cocos_core_geometry_intersect__lineAABB;
             lineOBB: typeof __private._cocos_core_geometry_intersect__lineOBB;
             linePlane: (line: Line, plane: Plane) => number;
-            lineTriangle: (line: Line, triangle: Triangle, outPt?: math.Vec3 | undefined) => number;
+            lineTriangle: (line: Line, triangle: Triangle, outPt?: math.Vec3) => number;
             sphereWithSphere: (sphere0: Sphere, sphere1: Sphere) => boolean;
             sphereAABB: (sphere: Sphere, aabb: AABB) => boolean;
             sphereOBB: (sphere: Sphere, obb: OBB) => boolean;
             spherePlane: (sphere: Sphere, plane: Plane) => number;
@@ -17668,9 +17668,9 @@
              * @param g2 @en The second geometry. @zh 第二个几何体。
              * @param outPt @en A 3d point to store the intersection point result, only part of the geometries support this.
              *              @zh 可选,用于保存相交点的输出对象。(注:仅部分形状的检测带有这个返回值)
              */
-            resolve(g1: any, g2: any, outPt?: null): number;
+            resolve(g1: any, g2: any, outPt?: any): number;
         };
         /**
          * @en
          * Basic Geometry: Line.
@@ -19830,12 +19830,12 @@
             extend: typeof extend;
             getSuper: typeof getSuper;
             isChildClassOf: typeof isChildClassOf;
             clear: typeof clear;
-            value: (object: Record<string | number, any>, propertyName: string, value_: any, writable?: boolean | undefined, enumerable?: boolean | undefined) => void;
-            getset: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, setter?: boolean | __private._types_globals__Setter | undefined, enumerable?: boolean | undefined, configurable?: boolean | undefined) => void;
-            get: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, enumerable?: boolean | undefined, configurable?: boolean | undefined) => void;
-            set: (object: Record<string | number, any>, propertyName: string, setter: __private._types_globals__Setter, enumerable?: boolean | undefined, configurable?: boolean | undefined) => void;
+            value: (object: Record<string | number, any>, propertyName: string, value_: any, writable?: boolean, enumerable?: boolean) => void;
+            getset: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, setter?: boolean | __private._types_globals__Setter, enumerable?: boolean, configurable?: boolean) => void;
+            get: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, enumerable?: boolean, configurable?: boolean) => void;
+            set: (object: Record<string | number, any>, propertyName: string, setter: __private._types_globals__Setter, enumerable?: boolean, configurable?: boolean) => void;
             unregisterClass: typeof unregisterClass;
             getClassName: typeof getClassName;
             setClassName: typeof setClassName;
             setClassAlias: typeof setClassAlias;
@@ -20199,9 +20199,9 @@
          * @zh 要添加的属性值,或者取代现有属性的新值。
          * @param writable @en If the property is writable. @zh 属性是否可写。
          * @param enumerable @en If the property is enumerable. @zh 属性是否可枚举。
          */
-        export const value: (object: Record<string | number, any>, propertyName: string, value_: any, writable?: boolean | undefined, enumerable?: boolean | undefined) => void;
+        export const value: (object: Record<string | number, any>, propertyName: string, value_: any, writable?: boolean, enumerable?: boolean) => void;
         /**
          * @en A helper function to add or modify `get`, `set`, `enumerable` or `configurable` of a property.
          * @zh 添加或修改属性的 `get`, `set`, `enumerable` 或者 `configurable`。
          * @param object @en The object to add or modify attributes. @zh 要添加或者修改属性的对象。
@@ -20210,9 +20210,9 @@
          * @param setter @en The setter of a property. @zh 属性的设置函数。
          * @param enumerable @en If the property is enumerable. @zh 属性是否可列举。
          * @param configurable @en If the property is configurable. @zh 属性是否可配置。
          */
-        export const getset: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, setter?: boolean | __private._types_globals__Setter | undefined, enumerable?: boolean | undefined, configurable?: boolean | undefined) => void;
+        export const getset: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, setter?: __private._types_globals__Setter | boolean, enumerable?: boolean, configurable?: boolean) => void;
         /**
          * @en A helper function to add or modify `get`, `enumerable` or `configurable` of a property.
          * @zh 添加或修改属性的 `get`, `enumerable` 或者 `configurable`。
          * @param object @en The object to add or modify attributes. @zh 要添加或者修改属性的对象。
@@ -20220,9 +20220,9 @@
          * @param getter @en The getter of a property. @zh 属性的获取函数。
          * @param enumerable @en If the property is enumerable. @zh 属性是否可列举。
          * @param configurable @en If the property is configurable. @zh 属性是否可配置。
          */
-        export const get: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, enumerable?: boolean | undefined, configurable?: boolean | undefined) => void;
+        export const get: (object: Record<string | number, any>, propertyName: string, getter: __private._types_globals__Getter, enumerable?: boolean, configurable?: boolean) => void;
         /**
          * @en A helper function to add or modify `get`, `enumerable` or `configurable` of a property.
          * @zh 添加或修改属性的 `get`, `enumerable` 或者 `configurable`。
          * @param object @en The object to add or modify attributes. @zh 要添加或者修改属性的对象。
@@ -20230,9 +20230,9 @@
          * @param setter @en The setter of a property. @zh 属性的设置函数。
          * @param enumerable @en If the property is enumerable. @zh 属性是否可列举。
          * @param configurable @en If the property is configurable. @zh 属性是否可配置。
          */
-        export const set: (object: Record<string | number, any>, propertyName: string, setter: __private._types_globals__Setter, enumerable?: boolean | undefined, configurable?: boolean | undefined) => void;
+        export const set: (object: Record<string | number, any>, propertyName: string, setter: __private._types_globals__Setter, enumerable?: boolean, configurable?: boolean) => void;
         /**
          * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
          */
         export const _idToClass: Record<string, __private._types_globals__Constructor>;
@@ -23828,9 +23828,9 @@
     export class PipelineStateManager {
         static getOrCreatePipelineState(device: gfx.Device, pass: renderer.Pass, shader: gfx.Shader, renderPass: gfx.RenderPass, ia: gfx.InputAssembler): gfx.PipelineState;
     }
     export class PipelineEventProcessor extends EventTarget {
-        eventTargetOn: <TFunction extends (...any: any[]) => void>(type: string | number, callback: TFunction, thisArg?: any, once?: boolean | undefined) => TFunction;
+        eventTargetOn: <TFunction extends (...any: any[]) => void>(type: string | number, callback: TFunction, thisArg?: any, once?: boolean) => TFunction;
         eventTargetOnce: <TFunction extends (...any: any[]) => void>(type: string | number, callback: TFunction, thisArg?: any) => TFunction;
         on(type: PipelineEventType, callback: any, target?: any, once?: boolean): typeof callback;
         once(type: PipelineEventType, callback: any, target?: any): typeof callback;
     }
@@ -24993,9 +24993,9 @@
          *
          * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
          */
         _globals: SceneGlobals;
-        dependAssets: null;
+        dependAssets: any;
         protected _renderScene: renderer.RenderScene | null;
         protected _inited: boolean;
         protected _prefabSyncedInLiveReload: boolean;
         protected _updateScene(): void;
@@ -25281,9 +25281,9 @@
          *
          * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
          */
         get _isOnLoadCalled(): number;
-        static system: null;
+        static system: any;
         /**
          * @en The node this component is attached to. A component is always attached to a node.
          * @zh 该组件被附加到的节点。组件总会附加到一个节点。
          * @example
@@ -27123,9 +27123,9 @@
         static safeFindClass(id: string): __private._types_globals__Constructor<unknown> | undefined;
         /**
          * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
          */
-        _$erialized: null;
+        _$erialized: any;
         constructor();
         onLoad(): void;
     }
     /**
@@ -27791,9 +27791,9 @@
          * @en The renderer backend of the game.
          * @zh 游戏的渲染器类型。
          */
         renderType: number;
-        eventTargetOn: <TFunction extends (...any: any[]) => void>(type: string | number, callback: TFunction, thisArg?: any, once?: boolean | undefined) => TFunction;
+        eventTargetOn: <TFunction extends (...any: any[]) => void>(type: string | number, callback: TFunction, thisArg?: any, once?: boolean) => TFunction;
         eventTargetOnce: <TFunction extends (...any: any[]) => void>(type: string | number, callback: TFunction, thisArg?: any) => TFunction;
         /**
          * @en
          * The current game configuration,
@@ -29638,9 +29638,9 @@
         loadPipe: typeof __private._cocos_asset_asset_manager_load__default;
         /**
          * @internal
          */
-        references: AssetManager.Cache<any[]> | null;
+        references: AssetManager.Cache<any[]>;
         /**
          * @en
          * A global singleton instance of [[AssetManager]], which you can access directly through [[assetManager]].
          *
@@ -49366,16 +49366,16 @@
             export function cylinder(radiusTop?: number, radiusBottom?: number, height?: number, opts?: __private._types_globals__RecursivePartial<__private._cocos_primitive_cylinder__ICylinderOptions>): primitives.IGeometry;
             export const VEC3_0: math.Vec3;
             export const TriggerEventObject: {
                 type: TriggerEventType;
-                selfCollider: Collider | null;
-                otherCollider: Collider | null;
+                selfCollider: Collider;
+                otherCollider: Collider;
                 impl: any;
             };
             export const CharacterTriggerEventObject: {
                 type: CharacterTriggerEventType;
-                collider: Collider | null;
-                characterController: CharacterController | null;
+                collider: Collider;
+                characterController: CharacterController;
                 impl: any;
             };
             export const CollisionEventObject: {
                 type: CollisionEventType;
@@ -56722,15 +56722,15 @@
         animationState: {
             previewing: boolean;
             time: number;
             animatedSinceLastFrame: boolean;
-        } | null;
+        };
         init(): void;
         add(widget: Widget): void;
         remove(widget: Widget): void;
         onResized(): void;
         refreshWidgetOnResized(node: Node): void;
-        updateOffsetsToStayPut(widget: Widget, e?: __private._cocos_ui_widget__AlignFlags | undefined): void;
+        updateOffsetsToStayPut(widget: Widget, e?: __private._cocos_ui_widget__AlignFlags): void;
         updateAlignment: typeof __private._cocos_ui_widget_manager__updateAlignment;
         AlignMode: typeof __private._cocos_ui_widget__AlignMode;
         AlignFlags: typeof __private._cocos_ui_widget__AlignFlags;
     };
@@ -65701,9 +65701,9 @@
              * @en Space used to calculate limit velocity.
              * @zh 计算速度下限时采用的坐标系 [[Space]]。
              */
             space: number;
-            drag: null;
+            drag: any;
             multiplyDragByParticleSize: boolean;
             multiplyDragByParticleVelocity: boolean;
             name: string;
             constructor();

@minggo minggo deleted the branch cocos:v3.8.2 May 16, 2024 02:52
@minggo minggo closed this May 16, 2024
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.

None yet

2 participants