Version:
@babylonjs/core: 5.23.0
Problem:
When installing the @babylonjs/core
package, the TypeScript compilation fails on library type checks for two files within the dependency. This even happens when nothing is imported.
Cause:
The flag tsconfig.json:compilerOptions.exactOptionalPropertyTypes
set to true
is not compatible with the exported types in .d.ts
files from @babylonjs/core
.
Error
node_modules/@babylonjs/core/Meshes/meshSimplification.d.ts:39:22 - error TS2420: Class 'SimplificationSettings' incorrectly implements interface 'ISimplificationSettings'.
Types of property 'optimizeMesh' are incompatible.
Type 'boolean | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.
39 export declare class SimplificationSettings implements ISimplificationSettings {
~~~~~~~~~~~~~~~~~~~~~~
node_modules/@babylonjs/core/XR/native/nativeXRFrame.d.ts:7:22 - error TS2420: Class 'NativeXRFrame' incorrectly implements interface 'XRFrame'.
Types of property 'trackedAnchors' are incompatible.
Type 'XRAnchorSet | undefined' is not assignable to type 'XRAnchorSet'.
Type 'undefined' is not assignable to type 'Set<XRAnchor>'.
Workaround:
Yes
Set tsconfig.json:compilerOptions.skipLibCheck
to true
.
Severity:
Low
Why this should be supported
The exactOptionalPropertyTypes
flag added in TypeScript 4.4 is a very useful addition to complement strict: true
because it enforces stricter - and more correct - rules for typing. Having seen it’s positive effects on typing, I believe it to become a popular flag or a default flag over time (no source).
Supporting this flag is consistent with your mentality to adopt ES6 modules and bleeding edge features like WebGPU.
The workaround of having to set skipLibChecks: false
gives a bad impression and stands in contrast to the rather high quality of babylon.js.