jnsmalm / pixi3d

The 3D renderer for PixiJS. Seamless integration with 2D applications.
https://pixi3d.org
MIT License
759 stars 44 forks source link

Typescript definition not compatible with Pixi v5.3.7 #52

Closed goldenratio closed 3 years ago

goldenratio commented 3 years ago

Can you please advice on how to resolve this? Versions:

"pixi.js-legacy": "5.3.7",
"pixi3d": "^0.9.8",

node_modules/pixi3d/types/camera/camera-orbit-control.d.ts:15:19 - error TS2315: Type 'ObservablePoint' is not generic.

15     get angles(): PIXI.ObservablePoint<undefined>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/pixi3d/types/camera/camera.d.ts:26:38 - error TS2694: Namespace 'PIXI' has no exported member 'IDestroyOptions'.

26     destroy(options?: boolean | PIXI.IDestroyOptions): void;
                                        ~~~~~~~~~~~~~~~

node_modules/pixi3d/types/container.d.ts:9:5 - error TS2416: Property 'transform' in type 'Container3D' is not assignable to the same property in base type 'Container'.
  Type 'Transform3D' is not assignable to type 'Transform'.
    Types of property 'worldTransform' are incompatible.
      Type 'TransformMatrix' is not assignable to type 'Matrix'.

9     transform: Transform3D;
      ~~~~~~~~~

node_modules/pixi3d/types/container.d.ts:10:9 - error TS2611: 'position' is defined as a property in class 'Container', but is overridden here in 'Container3D' as an accessor.

10     set position(value: ObservablePoint3D);
           ~~~~~~~~

node_modules/pixi3d/types/container.d.ts:12:9 - error TS2611: 'scale' is defined as a property in class 'Container', but is overridden here in 'Container3D' as an accessor.

12     set scale(value: ObservablePoint3D);
           ~~~~~

node_modules/pixi3d/types/container.d.ts:21:9 - error TS2416: Property 'localTransform' in type 'Container3D' is not assignable to the same property in base type 'Container'.
  Type 'TransformMatrix' is not assignable to type 'Matrix'.

21     get localTransform(): import(".").TransformMatrix;
           ~~~~~~~~~~~~~~

node_modules/pixi3d/types/container.d.ts:21:9 - error TS2611: 'localTransform' is defined as a property in class 'Container', but is overridden here in 'Container3D' as an accessor.

21     get localTransform(): import(".").TransformMatrix;
           ~~~~~~~~~~~~~~

node_modules/pixi3d/types/container.d.ts:22:9 - error TS2416: Property 'worldTransform' in type 'Container3D' is not assignable to the same property in base type 'Container'.
  Type 'TransformMatrix' is not assignable to type 'Matrix'.

22     get worldTransform(): import(".").TransformMatrix;
           ~~~~~~~~~~~~~~

node_modules/pixi3d/types/container.d.ts:22:9 - error TS2611: 'worldTransform' is defined as a property in class 'Container', but is overridden here in 'Container3D' as an accessor.

22     get worldTransform(): import(".").TransformMatrix;
           ~~~~~~~~~~~~~~

node_modules/pixi3d/types/cubemap/cubemap.d.ts:8:38 - error TS2315: Type 'BaseTexture' is not generic.

8 export declare class Cubemap extends PIXI.BaseTexture<CubemapResource> {
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/pixi3d/types/gltf/gltf-asset.d.ts:48:51 - error TS2724: 'PIXI' has no exported member named 'ILoaderResource'. Did you mean 'LoaderResource'?

48     load(uri: string, onComplete: (resource: PIXI.ILoaderResource) => void): void;
                                                     ~~~~~~~~~~~~~~~

node_modules/pixi3d/types/instanced-model.d.ts:8:37 - error TS2694: Namespace 'PIXI' has no exported member 'DestroyOptions'.

8     destroy(options: boolean | PIXI.DestroyOptions | undefined): void;
                                      ~~~~~~~~~~~~~~

node_modules/pixi3d/types/lighting/image-based-lighting.d.ts:13:17 - error TS2315: Type 'Texture' is not generic.

13     get brdf(): PIXI.Texture<PIXI.Resource>;
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/pixi3d/types/lighting/image-based-lighting.d.ts:13:35 - error TS2724: 'PIXI' has no exported member named 'Resource'. Did you mean 'resources'?

13     get brdf(): PIXI.Texture<PIXI.Resource>;
                                     ~~~~~~~~

node_modules/pixi3d/types/lighting/lighting-environment.d.ts:8:58 - error TS2694: Namespace 'PIXI' has no exported member 'IRendererPlugin'.

8 export declare class LightingEnvironment implements PIXI.IRendererPlugin {
                                                           ~~~~~~~~~~~~~~~

node_modules/pixi3d/types/loader/gltf-binary-loader.d.ts:3:26 - error TS2724: 'PIXI' has no exported member named 'ILoaderResource'. Did you mean 'LoaderResource'?

3     use: (resource: PIXI.ILoaderResource, next: () => void) => void;
                           ~~~~~~~~~~~~~~~

node_modules/pixi3d/types/loader/gltf-loader.d.ts:3:26 - error TS2724: 'PIXI' has no exported member named 'ILoaderResource'. Did you mean 'LoaderResource'?

3     use: (resource: PIXI.ILoaderResource, next: () => void) => void;
                           ~~~~~~~~~~~~~~~

node_modules/pixi3d/types/mesh/instanced-mesh.d.ts:8:37 - error TS2694: Namespace 'PIXI' has no exported member 'IDestroyOptions'.

8     destroy(options: boolean | PIXI.IDestroyOptions | undefined): void;
                                      ~~~~~~~~~~~~~~~

node_modules/pixi3d/types/picking/picking-manager.d.ts:9:53 - error TS2694: Namespace 'PIXI' has no exported member 'IRendererPlugin'.

9 export declare class PickingManager implements PIXI.IRendererPlugin {
                                                      ~~~~~~~~~~~~~~~

node_modules/pixi3d/types/pipeline/standard-pipeline.d.ts:49:5 - error TS2416: Property 'render' in type 'StandardPipeline' is not assignable to the same property in base type 'ObjectRenderer'.
  Type '(mesh: Mesh3D) => void' is not assignable to type '(object: DisplayObject) => void'.
    Types of parameters 'mesh' and 'object' are incompatible.
      Type 'DisplayObject' is missing the following properties from type 'Mesh3D': geometry, pluginName, enabledRenderPasses, _instances, and 34 more.

49     render(mesh: Mesh3D): void;
       ~~~~~~

node_modules/pixi3d/types/pixi/array-resource.d.ts:2:49 - error TS2339: Property 'ArrayResource' does not exist on type 'typeof PIXI'.

2 export declare const ArrayResource: typeof PIXI.ArrayResource;
                                                  ~~~~~~~~~~~~~

node_modules/pixi3d/types/pixi/cube-resource.d.ts:2:48 - error TS2339: Property 'CubeResource' does not exist on type 'typeof PIXI'.

2 export declare const CubeResource: typeof PIXI.CubeResource;
                                                 ~~~~~~~~~~~~

node_modules/pixi3d/types/sprite/post-processing-sprite.d.ts:27:25 - error TS2315: Type 'BaseTexture' is not generic.

27     get depthTexture(): PIXI.BaseTexture<PIXI.Resource, PIXI.IAutoDetectOptions> | undefined;
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/pixi3d/types/sprite/post-processing-sprite.d.ts:27:47 - error TS2724: 'PIXI' has no exported member named 'Resource'. Did you mean 'resources'?

27     get depthTexture(): PIXI.BaseTexture<PIXI.Resource, PIXI.IAutoDetectOptions> | undefined;
                                                 ~~~~~~~~

node_modules/pixi3d/types/sprite/post-processing-sprite.d.ts:27:62 - error TS2694: Namespace 'PIXI' has no exported member 'IAutoDetectOptions'.

27     get depthTexture(): PIXI.BaseTexture<PIXI.Resource, PIXI.IAutoDetectOptions> | undefined;
                                                                ~~~~~~~~~~~~~~~~~~

node_modules/pixi3d/types/transform/observable-point.d.ts:22:9 - error TS2611: 'x' is defined as a property in class 'ObservablePoint', but is overridden here in 'ObservablePoint3D' as an accessor.

22     get x(): number;
           ~

node_modules/pixi3d/types/transform/observable-point.d.ts:27:9 - error TS2611: 'y' is defined as a property in class 'ObservablePoint', but is overridden here in 'ObservablePoint3D' as an accessor.

27     get y(): number;
           ~

node_modules/pixi3d/types/transform/observable-quaternion.d.ts:21:9 - error TS2611: 'x' is defined as a property in class 'ObservablePoint', but is overridden here in 'ObservableQuaternion' as an accessor.

21     get x(): number;
           ~

node_modules/pixi3d/types/transform/observable-quaternion.d.ts:24:9 - error TS2611: 'y' is defined as a property in class 'ObservablePoint', but is overridden here in 'ObservableQuaternion' as an accessor.

24     get y(): number;
           ~

node_modules/pixi3d/types/transform/transform-matrix.d.ts:28:5 - error TS2416: Property 'toArray' in type 'TransformMatrix' is not assignable to the same property in base type 'Matrix'.
  Type '(transpose: boolean, out?: Float32Array | undefined) => Float32Array' is not assignable to type '(transpose: boolean, out?: Float32Array | undefined) => number[]'.
    Type 'Float32Array' is missing the following properties from type 'number[]': pop, push, concat, shift, and 5 more.

28     toArray(transpose: boolean, out?: Float32Array): Float32Array;
       ~~~~~~~

node_modules/pixi3d/types/transform/transform-matrix.d.ts:47:5 - error TS2416: Property 'copyFrom' in type 'TransformMatrix' is not assignable to the same property in base type 'Matrix'.
  Type '(matrix: TransformMatrix) => this' is not assignable to type '(matrix: Matrix) => Matrix'.
    Types of parameters 'matrix' and 'matrix' are incompatible.
      Type 'Matrix' is missing the following properties from type 'TransformMatrix': _transformId, transformId, array, position, and 10 more.

47     copyFrom(matrix: TransformMatrix): this;
       ~~~~~~~~

node_modules/pixi3d/types/transform/transform.d.ts:16:5 - error TS2416: Property 'worldTransform' in type 'Transform3D' is not assignable to the same property in base type 'Transform'.
  Type 'TransformMatrix' is not assignable to type 'Matrix'.
    Types of property 'toArray' are incompatible.
      Type '(transpose: boolean, out?: Float32Array | undefined) => Float32Array' is not assignable to type '(transpose: boolean, out?: Float32Array | undefined) => number[]'.

16     worldTransform: TransformMatrix;
       ~~~~~~~~~~~~~~

node_modules/pixi3d/types/transform/transform.d.ts:18:5 - error TS2416: Property 'localTransform' in type 'Transform3D' is not assignable to the same property in base type 'Transform'.
  Type 'TransformMatrix' is not assignable to type 'Matrix'.

18     localTransform: TransformMatrix;
       ~~~~~~~~~~~~~~

node_modules/pixi3d/types/transform/transform.d.ts:31:5 - error TS2416: Property 'setFromMatrix' in type 'Transform3D' is not assignable to the same property in base type 'Transform'.
  Type '(matrix: TransformMatrix) => void' is not assignable to type '(matrix: Matrix) => void'.
    Types of parameters 'matrix' and 'matrix' are incompatible.
      Type 'Matrix' is not assignable to type 'TransformMatrix'.

31     setFromMatrix(matrix: TransformMatrix): void;
       ~~~~~~~~~~~~~

Found 34 errors.
jnsmalm commented 3 years ago

Blaming PixiJS on this one :) PixiJS v5 has unfortunately incorrect typings which doesn't match the actual implementation in some places. This has been fixed in PixiJS v6. Two options:

  1. Upgrade your project to PixiJS v6 (which is almost identical to v5 in terms of API, it's mostly changes for typings)
  2. Set skipLibCheck = true in tsconfig.json and //@ts-ignore in some places.
goldenratio commented 3 years ago

@jnsmalm I had similar issue with pixi.js v6.1.3. I will confirm today.

Currently using skipLibCheck = true, works like a charm

jnsmalm commented 3 years ago

I just tried 6.1.3 and you are right, they still have some issues with the types.