Cannot compile Typescript file, ERROR TS2583

Hello everyone,

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.

1 Like

I’d also recommend, if you’re using VS Code, installing the TypeScript Extension Pack.

I learnt a lot from this article:

TypeScript With Babel: A Beautiful Marriage

And the embedded meme I found to be so true :slight_smile:

Thanks a lot @inteja! I’ll try it, and let ya’ll know whether the error continues!

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.

thanks a lot

I’m getting the same error as before.

Just posting the error message doesn’t help much sorry. You’d need to archive the lot for anyone to be able to diagnose the issue.

I did lookup TS2583 though and there is this ERROR: TS 2583 ERROR:TS 2705 · Issue #29523 · microsoft/TypeScript · GitHub

There’s a comment in that thread:

If you invoke tsc with a filename it ignores tsconfig.json. It should work if you just execute tsc without any CLI arguments.

But that may not help you either.

Did you also try that gitlab repo I posted, which has everything setup for you?

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.

I’ll try understanding your work, and continues learning babylon and webdev. I would post my code as you advised, but because I’m a new user, I cant.

However, I’d sincerely thanks for your help!

@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!

Thanks a lot.

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

Hello @RaananW! thanks to reply my post.

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.

Thanks a lot everyone!

babylon_typescript_tutorial.zip (513.8 KB)

This is a different error from what was originally posted.

Maybe try this https://stackoverflow.com/a/43999062

How does your tsconfig.json file look like? How does your webpack configuration look like?