Skip to main content

New site for Dart news and articles

For the latest Dart news, visit our new blog at  https://medium.com/dartlang .

Breaking Change: Deprecated Language Features Will No Longer be Supported by Dart2js



Peter von der Ahé writes:
dart2js will soon start rejecting code that uses certain deprecated language features.  Right now, the compiler is warning  about these language features, but it will soon reject code that uses 
them. 

The compiler, dart2js, will soon start rejecting the following deprecated language features: 

* Interface declarations.  Use abstract classes instead. 

* Getters with explicit parameter lists "()".  Just remove the parentheses. 

* Old-style #library, #import, and #source syntax.  Convert to new-style syntax: 

    #library('foo'); 

    becomes: 

    library foo; 


    #source('foo.dart'); 

    becomes: 

    part 'foo.dart'; 


    #import('foolib.dart', prefix: 'foo'); 

    becomes: 

    import 'foolib.dart' as foo; 

* triple-equal operators, === and !===.  Use the function "identical" instead. 

* The keyword "Dynamic".  Use dynamic instead (all lowercase). 

You can check that your code is up to spec with the dart2js options --analyze-all and --reject-deprecated-language-features. 

Cheers, 
Peter 

PS: If you're working on the platform libraries, you can use --report-sdk-use-of-deprecated language-features to see what deprecated language features the platform libraries are using. 
As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.