Ingo Chou Posted October 4, 2017 Share Posted October 4, 2017 Hello, There is an error: "importScripts" not found when I compile BABYLONJS source in VS2017. And the source file is "babylon.collisionWorker.ts". My project is TYPESCRIPT. How can I fix this? Thanks for your help. Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 4, 2017 Share Posted October 4, 2017 importScripts is a dom-feature, existing natively in webworkers (https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Importing_scripts_and_libraries) My assumption is that you are missing the type declaration for importScripts, which should be defined in your tsconfig.json. Try adding "webworker" to "types" in your typescript configuration and see if it helps. BTW - what TS version are you using? Quote Link to comment Share on other sites More sharing options...
Ingo Chou Posted October 4, 2017 Author Share Posted October 4, 2017 { "compileOnSave": true, "compilerOptions": { "experimentalDecorators": true, "module": "commonjs", "target": "es5", "sourceMap": true, "lib": [ "dom", "es2015.promise", "es5" ], "types": [ "webworker" ] } } I add "types" like this. Is it right ? But there is an error: tsc : error TS2688: Build:Cannot find type definition file for 'webworker'. My TS version is ES5. Thanks. Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 4, 2017 Share Posted October 4, 2017 Ahh! sorry as a lib, not as types Quote Link to comment Share on other sites More sharing options...
Ingo Chou Posted October 5, 2017 Author Share Posted October 5, 2017 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(656,5): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'source' must be of type 'any', but here has type 'Window'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(2505,5): error TS2375: Build:Duplicate number index signature. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(3695,14): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'srcElement' must be of type 'any', but here has type 'Element'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(3766,5): error TS2375: Build:Duplicate number index signature. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(8044,14): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'source' must be of type 'any', but here has type 'Window'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(13333,14): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'responseXML' must be of type 'any', but here has type 'Document'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14171,14): error TS2300: Build:Duplicate identifier 'EventListenerOrEventListenerObject'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14707,13): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'location' must be of type 'WorkerLocation', but here has type 'Location'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14713,13): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'navigator' must be of type 'WorkerNavigator', but here has type 'Navigator'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14740,13): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'onerror' must be of type '(this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any', but here has type 'ErrorEventHandler'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14752,13): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'onmessage' must be of type '(this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any', but here has type '(this: Window, ev: MessageEvent) => any'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14823,13): error TS2403: Build:Subsequent variable declarations must have the same type. Variable 'self' must be of type 'WorkerGlobalScope', but here has type 'Window'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14897,6): error TS2300: Build:Duplicate identifier 'AlgorithmIdentifier'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14898,6): error TS2300: Build:Duplicate identifier 'BodyInit'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14920,6): error TS2300: Build:Duplicate identifier 'IDBKeyPath'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14929,6): error TS2300: Build:Duplicate identifier 'RequestInfo'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14930,6): error TS2300: Build:Duplicate identifier 'USVString'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14934,6): error TS2300: Build:Duplicate identifier 'IDBValidKey'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.dom.d.ts(14935,6): error TS2300: Build:Duplicate identifier 'BufferSource'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1684,14): error TS2300: Build:Duplicate identifier 'EventListenerOrEventListenerObject'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1743,6): error TS2300: Build:Duplicate identifier 'AlgorithmIdentifier'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1744,6): error TS2300: Build:Duplicate identifier 'BodyInit'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1745,6): error TS2300: Build:Duplicate identifier 'IDBKeyPath'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1746,6): error TS2300: Build:Duplicate identifier 'RequestInfo'. 1>C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2\lib.webworker.d.ts(1747,6): error TS2300: Build:Duplicate identifier 'USVString'. { "compileOnSave": true, "compilerOptions": { "experimentalDecorators": true, "module": "commonjs", "target": "es5", "sourceMap": true, "lib": [ "dom", "es2015.promise", "es5", "webworker" ] } } There are some errors after add "webworker" to "lib". Thanks. Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 5, 2017 Share Posted October 5, 2017 That seems rather odd. But still makes sense. I wonder - what are you actually trying to do? compile Babylon? There is a dedicated Gulp Script for that, that compiles each module correctly. The problem is that both modules should include a different lib, and then compile. Afterwards you are able to combine the two. Quote Link to comment Share on other sites More sharing options...
Ingo Chou Posted October 5, 2017 Author Share Posted October 5, 2017 @RaananW , Thank you very much. Yes, I want to compile BABYLON. It seems that it is very difficult or even impossible. Thanks. Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 5, 2017 Share Posted October 5, 2017 It obviously more than possible, as we are doing it at least once a day. You should use gulp for that, and our predefined gulp script. You can read about it here - http://doc.babylonjs.com/generals/how_to_start . We don't support compiling Babylon outside of gulp, mainly due to the problem you are currently facing. All modules, loaders, materials etc' are being built externally and then (if needed, like in the case of workers) integrated into a single file. davrous 1 Quote Link to comment Share on other sites More sharing options...
Ingo Chou Posted October 6, 2017 Author Share Posted October 6, 2017 Can not compile BABYLON source by VS2015 / VS2017 ? But only gulp? I just want to compile it by VS2017, so I can use BABYLON in my other project compiled by typescript. Thanks. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 6, 2017 Share Posted October 6, 2017 Gulp is integrated in VS2017 so you could use the task panel integrated in it. Also if it is to use in another project why not simply referencing the declaration files instead of the full source ? (this would help understanding how you could do) Quote Link to comment Share on other sites More sharing options...
Ingo Chou Posted October 7, 2017 Author Share Posted October 7, 2017 @Sebavan Thank you very much. My project is TYPESCRIPT and I referenced the babylon.d.ts and Babylon.js . There is an error: namespace BABYLON.Engine not fount when I use BABYLON. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.