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

Error when build using Vite #2157

Closed
tsanyqudsi opened this issue Dec 17, 2021 · 2 comments
Closed

Error when build using Vite #2157

tsanyqudsi opened this issue Dec 17, 2021 · 2 comments

Comments

@tsanyqudsi
Copy link

tsanyqudsi commented Dec 17, 2021

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",
  • browsers and versions:
  • operating system:
  • Excalibur versions:
  • (anything else that may be relevant)

Current Workaround

using strict:false on tsconfig.json

@tsanyqudsi
Copy link
Author

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

@eonarheim
Copy link
Member

eonarheim commented Dec 17, 2021

@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

eonarheim added a commit that referenced this issue Jan 9, 2022
This PR simplifies the renderer code to prepare for custom render plugins, this will allow custom renderers with custom shaders to be built into excalibur.


## Changes:

- Add border drawing to circles and rectangles 🎉
- Split the monolithic style renderer into separate internal renderer plugins
- Improve the Shader code abstractions, adds a safety feature and error logging to avoid common shader/webgl issues
- Remove complicated pooling strategy, and remove Poolable which is invalid in stricter TS (mentioned in #2157)
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

No branches or pull requests

2 participants