dart-archive / ts2dart

ts2dart TypeScript to Dart transpiler
Apache License 2.0
180 stars 62 forks source link

Strip FINAL, CONST and ABSTRACT annotations from Dart output #13

Open yjbanov opened 9 years ago

yjbanov commented 9 years ago

They pollute Dart code. Example:

This:

import {
  CONST, FINAL, ABSTRACT
} from 'angular2/src/facade/lang';

@ABSTRACT()
class Blah {
  @FINAL()
  i;

  @CONST()
  constructor(a) {
    this.i = a;
  }
}

Transpiles to this:

library angular2.blah_dart;
import 'package:angular2/src/facade/lang.dart' show CONST, FINAL, ABSTRACT;

@ABSTRACT() 
class Blah {
  final i;
  @CONST() 
  const Blah( a): i = a;
}

(@FINAL is removed but still imported unnecessarily)

chalin commented 9 years ago

/sub

mprobst commented 9 years ago

Mhpf. Done already, but now this causes dartanalyzer warnings for unused imports :-(

kevmoo commented 9 years ago

@mprobst Now you need to strip the imports. :smile:

mprobst commented 9 years ago

Actually handling the unused imports is not feasible at the moment as we don't have precise type information available to detect used and unused imports. So let's just include these in the output for now, and revisit this once we're fully migrated to TypeScript.

Maybe it's easiest to just ignore warnings from the dart analyzer - after all, this is just generated code, and the imports will be dropped by later stages during compilation.