I want to experiment with webxr and have setup a typescript project. According to WebXR
I should do the following:
const supported = await navigator.xr.isSessionSupported('immersive-vr');
With my typescript setup navigator.xr
is displayed as error.
I wonder how to setup typescript for webxr
. My tsconfig
looks like this:
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "esNext",
"target": "es6",
"allowJs": true,
"moduleResolution": "node"
},
"exclude": [
"./node_modules"
],
}
You need to add definitions for WebXR, such as these ones. Something like running: npm install --save-dev @types/webxr
and then importing the types:
import type { Navigator } from 'webxr';
Related: