Decorators (e.g. @Component) are an active EcmaScript 7 proposal. You can see the “equivalent” ES6 code by compiling your code with the TypeScript compiler and looking at the output:
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component, bootstrap } from 'angular2/angular2';
// Annotation section
let MyApp = class {
constructor() {
this.name = 'Max';
}
};
MyApp = __decorate([
Component({
selector: 'my-app',
template: '<h1>Hello {{ name }}</h1>'
})
], MyApp);
A slightly cleaned up, but not 100% equivalent to TypeScript output, would be:
import { Component, bootstrap } from 'angular2/angular2';
// Annotation section
let MyApp = class {
constructor() {
this.name = 'Max';
}
};
MyApp = Component({
selector: 'my-app',
template: '<h1>Hello {{ name }}</h1>'
})(MyApp) || MyApp;
Of course since all of this is still just at the proposal phase, it is possible that the syntax or semantics of decorators will change in the future, so you can’t necessarily rely on them working this way forever.
(Please also note that a 'use strict' pragma inside an ES6 module makes no sense; all code inside ES6 modules already runs in strict mode per the specification.)