I’m starting programming in typescript, and I want to use BabylonJS for my first little project. One thing though, is that every time I try to compile the TSC file, I get this error bellow. I’ve tried to change the “lib” and “target” on my tsconfig.json, however, nothing happerns.
Could someone helps me?
felipeaamacedo@felipeaamacedo-VivoBook-ASUSLaptop-X570ZD-X570ZD:~/Documents/Projects/babylon_typescript_tutorial$ tsc scripts/TSintro.ts
node_modules/babylonjs/babylon.module.d.ts:143281:19 - error TS2583: Cannot find name ‘Set’. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.
143281 type XRPlaneSet = Set<XRPlane>;
~~~
node_modules/babylonjs/babylon.module.d.ts:143282:20 - error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
143282 type XRAnchorSet = Set<XRAnchor>;
@Felipe_Macedo I can’t help with your specific error, but here’s the Babylon.js TypeScript setup I use when starting most projects. It can be frustrating to get all the the tooling (Babylon, TS compiler, babel, webpack etc) working smoothly and efficiently together, but when you finally do, it’s a huge time saver.
Haven’t got it to work yet… I do not know what is it. I believe maybe this is a TypeScript version issue… I simple copy and paste the BabylonJS Typescript tutorial from the documentation, and it keeps doing the same issue.
Have any idea? I could send my tsconfig.json file… Idk whether it helps, though.
Yeah! Thanks @inteja I’ve just tested it! It worked flawlessly! but I honestly do not get it… I have to admit that I have no real experience with web app development, I’ve only worked with Delphi and an open source library called GLScene, though, I’ve always had a thing for web apps, and recently I’ve started to learn web dev. When I found BabylonJS I though that it would perfectly fit my needs. When I start to do its Documentary typescript tutorial, I did everything the tutorial says but then, I get this errors. And because I don’t really understand all tools you’ve used in your babylon setup it kind of bothers me, if you know what I mean…
If you’re new to modern web dev, yes there’s a lot of preliminary things to learn, but there’s no need to fully understand all the boilerplate code and tooling. You can just use it and learn bits as you need to.
But if you’d prefer to stick with the Babylon.js TS tutorial, then you’ll need to zip up and post exactly what you’ve done so someone can assist further.
@inteja
I’ve tried to figured out what was happening that I couldn’t get my coding to work, and what I think I was doing wrong is that I usually use live-server and the tsc -w command, and to get it work, I installed the BABYLONJS NPM module and using the import * as BABYLON from 'babylonjs' command. However I does not work I have no reason why. But, if I erase the import line, and runs tsc game.js babylon.d.ts and open the index.html file in the browser it works flawlessly.
It kindda answer my question! Now I’m going to learn a little more about webpack while using your settup!
Have you tried doing what the compiler is telling to to try? This seems like a tsconfig issue to me. Make sure you set the right lib, because set is relatively new.
I would also recommend you to try the es6 module version of Babylon, this way you won’t let to read the entire lib but only the parts you actually need. Try @babylonjs/core on NPM
I have tried all lib versions, right now I am using the ES6, as show at the NPM tutorial… I am updating my folder and a screenshot of the error, it will probably help.