Вопрос

I have an existing project that accesses some variables off of the window scope. changing them around is an option, but I'd like to understand why the following isn't working...

//test.js
window.alert('I work');
traceur test.js
// -> ReferenceError: window is not defined

Why does this happen and how can I fix it? I cannot import window nor could I find any reference to how to fix this through searching.

Это было полезно?

Решение

As it turns out, you need to specify and output file if you want to compile your files to target the browser.

this command worked for me

traceur --out compiled.js test.js

Другие советы

If you are running it in command line you then there is no window object. window object are specific to browser. The window object represents an open window in a browser. I am not sure what traceur is and if it was build based on the intention to run on anywhere else except a browser window.

If not, then all references to things like window or dom (Document Object Model) will fail..

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top