1.0.0 • Published 8 years ago

babel-plugin-polymer-to-typescript v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

Babel transformer to convert standard Polymer 1.x projects to polymer-ts style.

This is still in development. I've had better luck in generating .d.ts files using (my fork) of generator-polymerts - the output is available at polymer-elements-typings.

Options

  • userBehaviorDecorator - if true use @behavior(SomeBehavior) for each behavior. If false (default) use Mixins

Using with Gulp

package.json

{
	...
	"devDependencies": {
		"gulp": "^3.9.0",
		"gulp-babel": "^6.1.1",
		"gulp-crisper": "^1.0.0",
		"gulp-if": "^2.0.0",
		"gulp-load-plugins": "^1.1.0",
		"gulp-rename": "^1.2.2",
		"gulp-replace": "^0.5.4",
		"babel-plugin-polymer-to-typescript": "^0.1.22"
	}
}

gulpfile.js

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

gulp.task('polymer-to-typescript', function() {
  return gulp.src('app/elements/**/*.html')
    .pipe($.crisper({scriptInHead: false}))
    .pipe($.if('*.html', $.replace(/^<html><head>|<\/head><body>|<\/body><\/html>/g, '')))
    .pipe($.if('*.html', 
      $.replace(/^<html><head>|<\/head><body>|<\/body><\/html>/g, ''),
      $.babel({"plugins": ["polymer-to-typescript", {
//		  "useBehaviorDecorator": true
      	}]})
    ))
    .pipe($.if('*.js', $.rename({extname: '.ts'})))
    .pipe(gulp.dest('dist'));
});

Contributing

PRs are welcome. I found the AST Explorer very useful to gain an understanding of the structure of the original code and the code to be generated.
Another good reference was the README for babel-types.

1.0.0

8 years ago

0.1.23

8 years ago

0.1.2333

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago