Typescript Errors with babylonJS:

With Typescript 4.9.4 target ES2020 and BJS 5.39.0, I am getting TypeScript Compile errors:
Any suggestions?

../../web/node_modules/babylonjs/babylon.module.d.ts:185616:9 - error TS2416: Property 'executeStep' in type 'AmmoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(delta: number, impostors: PhysicsImpostor[]) => void' is not assignable to type '{ (delta: number, impostors: PhysicsImpostor[]): void; (delta: number): void; }'.

185616         executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
               ~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:185639:9 - error TS2416: Property 'applyImpulse' in type 'AmmoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void; (body: PhysicsBody, location: Vector3, impulse: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is missing the following properties from type 'PhysicsImpostor': object, type, _options, _physicsEngine, and 66 more.

185639         applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
               ~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:185719:9 - error TS2416: Property 'setLinearVelocity' in type 'AmmoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, velocity: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, velocity: Vector3): void; (body: PhysicsBody, linVel: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

185719         setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
               ~~~~~~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:185725:9 - error TS2416: Property 'setAngularVelocity' in type 'AmmoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, velocity: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, velocity: Vector3): void; (body: PhysicsBody, angVel: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

185725         setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
               ~~~~~~~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:185928:9 - error TS2416: Property 'executeStep' in type 'CannonJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(delta: number, impostors: PhysicsImpostor[]) => void' is not assignable to type '{ (delta: number, impostors: PhysicsImpostor[]): void; (delta: number): void; }'.

185928         executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
               ~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:185930:9 - error TS2416: Property 'applyImpulse' in type 'CannonJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void; (body: PhysicsBody, location: Vector3, impulse: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

185930         applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
               ~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:185950:9 - error TS2416: Property 'setLinearVelocity' in type 'CannonJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, velocity: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, velocity: Vector3): void; (body: PhysicsBody, linVel: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

185950         setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
               ~~~~~~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:185951:9 - error TS2416: Property 'setAngularVelocity' in type 'CannonJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, velocity: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, velocity: Vector3): void; (body: PhysicsBody, angVel: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

185951         setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
               ~~~~~~~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:186007:9 - error TS2416: Property 'executeStep' in type 'OimoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(delta: number, impostors: PhysicsImpostor[]) => void' is not assignable to type '{ (delta: number, impostors: PhysicsImpostor[]): void; (delta: number): void; }'.

186007         executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
               ~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:186008:9 - error TS2416: Property 'applyImpulse' in type 'OimoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void; (body: PhysicsBody, location: Vector3, impulse: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

186008         applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
               ~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:186018:9 - error TS2416: Property 'setLinearVelocity' in type 'OimoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, velocity: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, velocity: Vector3): void; (body: PhysicsBody, linVel: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

186018         setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
               ~~~~~~~~~~~~~~~~~

../../web/node_modules/babylonjs/babylon.module.d.ts:186019:9 - error TS2416: Property 'setAngularVelocity' in type 'OimoJSPlugin' is not assignable to the same property in base type 'IPhysicsEnginePlugin'.
  Type '(impostor: PhysicsImpostor, velocity: Vector3) => void' is not assignable to type '{ (impostor: PhysicsImpostor, velocity: Vector3): void; (body: PhysicsBody, angVel: Vector3): void; }'.
    Types of parameters 'impostor' and 'body' are incompatible.
      Type 'PhysicsBody' is not assignable to type 'PhysicsImpostor'.

186019         setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
               ~~~~~~~~~~~~~~~~~~


Found 12 errors in the same file, starting at: ../../web/node_modules/babylonjs/babylon.module.d.ts:185616

Hello! Can you share more about your project configuration? How’s the package.json and the typescript configs? @Cedric is out at this moment :christmas_tree: but he’ll see this as soon as he’s available :slight_smile:

setting the tsconfig option to skipLibCheck=true fixes this.

1 Like

I also got this problem with 5.39.0

I posted an issues here as well

I also found this issue after I install the package. The setup uses Angular 15. Here is the package.json setting.

"dependencies": {
    "@angular/animations": "^15.0.0",
    "@angular/common": "^15.0.0",
    "@angular/compiler": "^15.0.0",
    "@angular/core": "^15.0.0",
    "@angular/forms": "^15.0.0",
    "@angular/platform-browser": "^15.0.0",
    "@angular/platform-browser-dynamic": "^15.0.0",
    "@angular/router": "^15.0.0",
    "@types/offscreencanvas": "^2019.7.0",
    "babylonjs": "^5.40.0",
    "normalize.css": "^8.0.1",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.0.3",
    "@angular/cli": "~15.0.3",
    "@angular/compiler-cli": "^15.0.0",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "prettier": "2.8.1",
    "typescript": "~4.8.2"
  }

Once Cedric and Raanan are back they’ll look into it :smiley:

1 Like

@RaananW will have a look soon. I think we might need to update our TS version :slight_smile:

1 Like

i’m on it! it’s a UMD issue only. moving to @babylonjs/core instead will prevent this issue, BUT of course we support UMD as well :slight_smile:

1 Like

Hi @RaananW is this one fixed yet?

This should have been resolve by now. If it wasn’t please let me know.

1 Like

TS2345: Argument of type ‘AbstractMesh’ is not assignable to parameter of type ‘Mesh | AbstractMesh’.
Type ‘AbstractMesh’ is missing the following properties from type ‘AbstractMesh’: _physicsBody, physicsBody, getPhysicsBody

So how can I solve this problem

Hello and welcome!

(m as Mesh)
or better

if (m instanceof Mesh) {
// do something
}
1 Like