excaliburjs / Excalibur

🎮 Your friendly TypeScript 2D game engine for the web 🗡️
https://excaliburjs.com
BSD 2-Clause "Simplified" License
1.82k stars 188 forks source link

Error when build using Vite #2157

Closed tsanyqudsi closed 2 years ago

tsanyqudsi commented 2 years ago

When i tried to build using Vite, apparently there are errors occured, and it's from node_modules/excalibur/build/dist/Graphics/

Steps to Reproduce

Build using Vite

Expected Result

No problems occured.

Actual Result


node_modules/excalibur/build/dist/Graphics/Context/batch.d.ts:4:17 - error TS2344: Type 'this' does not satisfy the constraint 'Poolable'.
  Type 'BatchCommand<T>' is not assignable to type 'Poolable'.
    The types of '_pool.recycler' are incompatible between these types.
      Type '(instance: this, ...args: any[]) => this' is not assignable to type '(instance: Poolable, ...args: any[]) => Poolable'.
        Types of parameters 'instance' and 'instance' are incompatible.
          Type 'Poolable' is not assignable to type 'this'.
            'this' could be instantiated with an arbitrary type which could be unrelated to 'Poolable'.

4     _pool: Pool<this>;
                  ~~~~

node_modules/excalibur/build/dist/Graphics/Context/draw-image-command.d.ts:14:17 - error TS2344: Type 'this' does not satisfy the constraint 'Poolable'.
  Type 'DrawImageCommand' is not assignable to type 'Poolable'.
    The types of '_pool.recycler' are incompatible between these types.
      Type '(instance: this, ...args: any[]) => this' is not assignable to type '(instance: Poolable, ...args: any[]) => Poolable'.
        Types of parameters 'instance' and 'instance' are incompatible.
          Type 'Poolable' is not assignable to type 'this'.
            'this' could be instantiated with an arbitrary type which could be unrelated to 'Poolable'.

14     _pool: Pool<this>;
                   ~~~~

node_modules/excalibur/build/dist/Graphics/Context/image-renderer.d.ts:28:58 - error TS2344: Type 'DrawImageCommand' does not satisfy the constraint 'Poolable'.
  The types of '_pool.recycler' are incompatible between these types.
    Type '(instance: DrawImageCommand, ...args: any[]) => DrawImageCommand' is not assignable to type '(instance: Poolable, ...args: any[]) => Poolable'.
      Types of parameters 'instance' and 'instance' are incompatible.
        Type 'Poolable' is not assignable to type 'DrawImageCommand'.

28 export declare class ImageRenderer extends BatchRenderer<DrawImageCommand> {
                                                            ~~~~~~~~~~~~~~~~

node_modules/excalibur/build/dist/Graphics/Context/image-renderer.d.ts:37:5 - error TS2416: Property 'renderBatch' in type 'ImageRenderer' is not assignable to the same property in base type 'BatchRenderer<DrawImageCommand>'.
  Type '(gl: WebGLRenderingContext, batch: BatchImage, vertexCount: number) => void' is not assignable to type '(gl: WebGLRenderingContext, batch: BatchCommand<DrawImageCommand>, vertexCount: number) => void'.
    Types of parameters 'batch' and 'batch' are incompatible.
      Type 'BatchCommand<DrawImageCommand>' is missing the following properties from type 'BatchImage': maxDraws, maxTextures, textures, _graphicMap, and 7 more.

37     renderBatch(gl: WebGLRenderingContext, batch: BatchImage, vertexCount: number): void;
       ~~~~~~~~~~~

node_modules/excalibur/build/dist/Graphics/Context/image-renderer.d.ts:38:5 - error TS2416: Property 'buildBatchVertices' in type 'ImageRenderer' is not assignable to the same property in base type 'BatchRenderer<DrawImageCommand>'.
  Type '(vertexBuffer: Float32Array, batch: BatchImage) => number' is not assignable to type '(vertexBuffer: Float32Array, batch: BatchCommand<DrawImageCommand>) => number'.
    Types of parameters 'batch' and 'batch' are incompatible.
      Type 'BatchCommand<DrawImageCommand>' is not assignable to type 'BatchImage'.

38     buildBatchVertices(vertexBuffer: Float32Array, batch: BatchImage): number;
       ~~~~~~~~~~~~~~~~~~

node_modules/excalibur/build/dist/Graphics/Context/line-renderer.d.ts:9:18 - error TS2344: Type 'this' does not satisfy the constraint 'Poolable'.
  Type 'DrawLine' is not assignable to type 'Poolable'.
    Types of property '_pool' are incompatible.
      Type 'Pool<this> | undefined' is not assignable to type 'Pool<Poolable> | undefined'.
        Type 'Pool<this>' is not assignable to type 'Pool<Poolable>'.
          Types of property 'recycler' are incompatible.
            Type '(instance: this, ...args: any[]) => this' is not assignable to type '(instance: Poolable, ...args: any[]) => Poolable'.
              Types of parameters 'instance' and 'instance' are incompatible.
                Type 'Poolable' is not assignable to type 'this'.
                  'this' could be instantiated with an arbitrary type which could be unrelated to 'Poolable'.

9     _pool?: Pool<this>;
                   ~~~~

node_modules/excalibur/build/dist/Graphics/Context/line-renderer.d.ts:15:57 - error TS2344: Type 'DrawLine' does not satisfy the constraint 'Poolable'.
  Types of property '_pool' are incompatible.
    Type 'Pool<DrawLine> | undefined' is not assignable to type 'Pool<Poolable> | undefined'.
      Type 'Pool<DrawLine>' is not assignable to type 'Pool<Poolable>'.
        Types of property 'recycler' are incompatible.
          Type '(instance: DrawLine, ...args: any[]) => DrawLine' is not assignable to type '(instance: Poolable, ...args: any[]) => Poolable'.
            Types of parameters 'instance' and 'instance' are incompatible.
              Type 'Poolable' is not assignable to type 'DrawLine'.

15 export declare class LineRenderer extends BatchRenderer<DrawLine> {
                                                           ~~~~~~~~

node_modules/excalibur/build/dist/Graphics/Context/point-renderer.d.ts:9:18 - error TS2344: Type 'this' does not satisfy the constraint 'Poolable'.
  Type 'DrawPoint' is not assignable to type 'Poolable'.
    Types of property '_pool' are incompatible.
      Type 'Pool<this> | undefined' is not assignable to type 'Pool<Poolable> | undefined'.
        Type 'Pool<this>' is not assignable to type 'Pool<Poolable>'.
          Types of property 'recycler' are incompatible.
            Type '(instance: this, ...args: any[]) => this' is not assignable to type '(instance: Poolable, ...args: any[]) => Poolable'.
              Types of parameters 'instance' and 'instance' are incompatible.
                Type 'Poolable' is not assignable to type 'this'.
                  'this' could be instantiated with an arbitrary type which could be unrelated to 'Poolable'.

9     _pool?: Pool<this>;
                   ~~~~

node_modules/excalibur/build/dist/Graphics/Context/point-renderer.d.ts:15:58 - error TS2344: Type 'DrawPoint' does not satisfy the constraint 'Poolable'.
  Types of property '_pool' are incompatible.
    Type 'Pool<DrawPoint> | undefined' is not assignable to type 'Pool<Poolable> | undefined'.
      Type 'Pool<DrawPoint>' is not assignable to type 'Pool<Poolable>'.
        Types of property 'recycler' are incompatible.
          Type '(instance: DrawPoint, ...args: any[]) => DrawPoint' is not assignable to type '(instance: Poolable, ...args: any[]) => Poolable'.
            Types of parameters 'instance' and 'instance' are incompatible.
              Type 'Poolable' is not assignable to type 'DrawPoint'.

15 export declare class PointRenderer extends BatchRenderer<DrawPoint> {
                                                            ~~~~~~~~~

Found 9 errors.

Environment

"excalibur": "0.25.1",

Current Workaround

using strict:false on tsconfig.json

tsanyqudsi commented 2 years ago

nevermind.. i saw on the roadmap you guys still need to fix issues with strict: true

eonarheim commented 2 years ago

@tsanyqudsi thanks for the issue!

I think this specific issue around the Pool type will go away in the next point release 0.25.2 with some work that's planned in the renderer code.

Any remaining issues will be covered by moving Excalibur to strict: true