(1) Don't understand the error; (2) Seeking recommendation for an efficient workflow for Dart

75 views
Skip to first unread message

Test This

unread,
Jun 22, 2016, 2:25:50 PM6/22/16
to Dart Misc
Hello

Started with Dart recently and am enjoying working with it. It feel great.

However, I have run into an issue and am looking for advice on a more efficient
workflow. Currently, I make changes to my dart file, compile it to js using
dart2js and then reload the webpage that references the compiled js file. Forgetting the long
time it takes to compile, I have the following more serious issue.

When there is an error in my Dart code,
the error message in the Chrome Developer tool is next to useless (maybe, I
don't know how to read it). For example, I made the following mistake. I defined 

    TableRowElement tr; // instead of TableRowElement tr = new TableRowElement();

and then tried adding cell elements to tr. After compiling to js (no error was
thrown during the compilation), on the browser developer window, I got some
some general "uncaught exception" error...nothing pointing to the specific error I had
made. 

I thought that probably I should load the app in Dartium/Chromium and use the
dart file instead of the compiled js file. I did that, and the developer window
in Chromium says that I have an 'Uncaught SyntaxError: Unexpected reserved word'
in line 2 of my code, which is 

   import 'dart:html';

Can someone help me understand why I am obtaining this error? And, in general what would
be a good workflow to use with Dart. 

Thank you.

Harry Terkelsen

unread,
Jun 22, 2016, 2:33:47 PM6/22/16
to Dart Misc
I would recommend using Dartium for your edit/refresh workflow. Then you should get an error saying something like 'noSuchMethod cells on null' and it will show you where in your code you are trying to tr, which is null since it's not initialized to a value.

Your SyntaxError looks to me like you tried to run dart code in Chrome as js code and it's failing since 'import' is reserved. Make sure you're using Dartium, not Chrome.

--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Jim Trainor

unread,
Jun 23, 2016, 9:46:24 AM6/23/16
to mi...@dartlang.org
Your script tag should look like this:

<script type=“application/dart”src="myProgram.dart"></script>


Perhaps you missed the type.


It should work fine in Dartium.  Nothing other than the dart script tag is necessary to get the dart code to execute in Dartium.




Test This

unread,
Jun 23, 2016, 12:13:25 PM6/23/16
to Dart Misc
Thank you Harry and Jim. 

Yes, I was missing the type=application/dart in the script tag. Now it works well in Dartium and the errors are also more informative. 

Dart feels so much better compared to JavaScript.
Reply all
Reply to author
Forward
0 new messages