brianzinn Posted December 12, 2017 Share Posted December 12, 2017 https://github.com/BabylonJS/Babylon.js/blob/c319ca1cbfa1b249bee93771d4fea1d4279f5e25/src/Mesh/babylon.csg.ts#L590 I think the signature should be: public toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh { I can PR if you want and that is correct. thanks. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 12, 2017 Share Posted December 12, 2017 I will fix it thanks! Quote Link to comment Share on other sites More sharing options...
brianzinn Posted December 12, 2017 Author Share Posted December 12, 2017 @Deltakosh Thanks - whole game builds with strictNullChecks compile option enabled! One gotcha is that there are a lot of Nullable<T> (Nullable<T> = T | null), while they can often be undefined. ie: mesh.physicsImpostor. Not sure if it makes sense to default some to null - or at least new Nullable<T> properties that are added in the future. ie: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L357 Could be public physicsImpostor: Nullable<PhysicsImpostor> = null; So, right now I need to check if (mesh.physicsImpostor) {...}, whereas I thought I could do if (mesh.physicsImpostor !== null) {..}. I have a feeling that would break a lot of existing code, so I would guess it is just something we have to deal with knowing how it is implemented Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 13, 2017 Share Posted December 13, 2017 I'm ok with that feel free to send tiny PR for that ! Quote Link to comment Share on other sites More sharing options...
brianzinn Posted December 13, 2017 Author Share Posted December 13, 2017 I tested it out and created a PR: https://github.com/BabylonJS/Babylon.js/pull/3382 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted December 13, 2017 Author Share Posted December 13, 2017 Those 2 fields are really the tip of the iceberg. Before even if I checked "if (mesh.physicsImpostor !== undefined)", I would get a potential Null warning in compiler in my if block, while checking for not null did not work and failed at runtime (default was undefined). I think it's hard to say a (T | null) can either be a T or null only, which is what we expect from a typed language and not so much from JavaScript, but it does add some consistency and match the .d.ts file to help people in their editors and compile/lint errors. Cheers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.