jodo

Babylon and Typescript Compile error

Recommended Posts

My project for that evening was to try out Typescript a little bit to actually code something on the babylon framework. I did some tutorials and it seems really cool!

Then I took the src Folder from Babylon added it to my Project Folder and wanted to compile and I got these errors:

EDIT: Okay i managed to compile without errors. Than when using the javascript file I got that error when running in the Browser.
I figgured that in the tsconfig.json the "module" should probably not commonjs but amd (it is some sort of require.js right?). But it didnt resolve the proble : /

TypeError: BABYLON is undefined

I am guessing there is something wrong with my config files... but I dont know what. I couldnt find any info online that helped me :/. I am using Visual Studio Code by the way.

This would be the tsconfig.json

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "sourceMap": true,
        "out": "babylon_myBuild.js"
    }
}

And this is my task.json

{
	"version": "0.1.0",

	// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
	"command": "tsc",
 
	// The command is a shell script
	"isShellCommand": true,
 
	// Show the output window always
	"showOutput": "always",

	// Tell the tsc compiler to use the tsconfig.json from the open folder.
	"args": ["-p", "."],

	// use the standard tsc problem matcher to find compile problems
	// in the output.
	"problemMatcher": "$tsc"
}

 

Also what does the *.d.ts file mean? Would be cool if somebody could point me to the right direction ;)

 

 

Share this post


Link to post
Share on other sites

I personaly compile with the provided gulp script

Go to Babylon.js/Tools/Gulp

Then run "gulp typescript"

This will compile everything, minify it, etc. You will find the new compiled files then in /Babylon.js/dist/preview release/

Share this post


Link to post
Share on other sites

Is it posible to just compile one typescript file to a javascript file? Because when using the gulp.js file and for example using the command "glup typescript" it takes like 4 minutes to compile the whole thing :(. As I am not quite new to both typescript and babylon and have to try out a lot of stuff, but waiting 4 minutes every time is quite time consuming ^^.

Or are you working on the js files and when you know everything is working fine with the js files you convert it into the typescript files?

Edit: using "gulp typscript-compile" and adding the single js files is quite a bit faster ... still takes some time. Maybe its just my super old and slow laptop ;)

Share this post


Link to post
Share on other sites

the whole compilation is only about 12" on the computer I develop on. I only code in TS and only compile everything each time.

don't know about the way to compile only one file with the TS declarations taken in account... some TS expert will answer you here

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.