TypeScript/tests/baselines/reference/sourceMapValidationDecorators.js

108 lines
4.5 KiB
TypeScript
Raw Normal View History

2015-03-18 19:17:26 +01:00
//// [sourceMapValidationDecorators.ts]
declare function ClassDecorator1(target: Function): void;
declare function ClassDecorator2(x: number): (target: Function) => void;
2015-03-25 01:00:29 +01:00
declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void;
declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void;
declare function ParameterDecorator1(target: Function, key: string | symbol, paramIndex: number): void;
declare function ParameterDecorator2(x: number): (target: Function, key: string | symbol, paramIndex: number) => void;
2015-03-18 19:17:26 +01:00
@ClassDecorator1
@ClassDecorator2(10)
class Greeter {
constructor(
@ParameterDecorator1
@ParameterDecorator2(20)
public greeting: string,
@ParameterDecorator1
@ParameterDecorator2(30)
...b: string[]) {
}
@PropertyDecorator1
@PropertyDecorator2(40)
greet() {
return "<h1>" + this.greeting + "</h1>";
}
@PropertyDecorator1
@PropertyDecorator2(50)
private x: string;
@PropertyDecorator1
@PropertyDecorator2(60)
private static x1: number = 10;
private fn(
@ParameterDecorator1
@ParameterDecorator2(70)
x: number) {
return this.greeting;
}
@PropertyDecorator1
@PropertyDecorator2(80)
get greetings() {
return this.greeting;
}
set greetings(
@ParameterDecorator1
@ParameterDecorator2(90)
greetings: string) {
this.greeting = greetings;
2015-03-25 01:00:29 +01:00
}
2015-03-18 19:17:26 +01:00
}
//// [sourceMapValidationDecorators.js]
2015-03-25 01:00:29 +01:00
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
2015-03-18 19:17:26 +01:00
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
2015-03-25 01:00:29 +01:00
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
2015-03-18 19:17:26 +01:00
}
2015-03-25 01:00:29 +01:00
return value;
2015-03-18 19:17:26 +01:00
};
2015-03-26 02:12:57 +01:00
var __metadata = this.__metadata || (typeof Reflect === "object" && Reflect.metadata) || function () { return function() { } };
2015-03-18 19:17:26 +01:00
var Greeter = (function () {
function Greeter(greeting) {
var b = [];
for (var _i = 1; _i < arguments.length; _i++) {
b[_i - 1] = arguments[_i];
}
this.greeting = greeting;
}
Greeter.prototype.greet = function () {
return "<h1>" + this.greeting + "</h1>";
};
Greeter.prototype.fn = function (x) {
return this.greeting;
};
Object.defineProperty(Greeter.prototype, "greetings", {
get: function () {
return this.greeting;
},
2015-03-25 01:00:29 +01:00
set: function (greetings) {
2015-03-18 19:17:26 +01:00
this.greeting = greetings;
},
enumerable: true,
configurable: true
});
Greeter.x1 = 10;
2015-03-18 01:09:39 +01:00
Object.defineProperty(Greeter.prototype, "greet", __decorate([PropertyDecorator1, PropertyDecorator2(40), __metadata('design:type', Function), __metadata('design:paramtypes', []), __metadata('design:returntype', Object)], Greeter.prototype, "greet", Object.getOwnPropertyDescriptor(Greeter.prototype, "greet")));
__decorate([PropertyDecorator1, PropertyDecorator2(50), __metadata('design:type', String)], Greeter.prototype, "x");
__decorate([ParameterDecorator1, ParameterDecorator2(70), __metadata('design:type', Number)], Greeter.prototype, "fn", 0);
__decorate([ParameterDecorator1, ParameterDecorator2(90), __metadata('design:type', String)], Greeter.prototype, "greetings", 0);
Object.defineProperty(Greeter.prototype, "greetings", __decorate([PropertyDecorator1, PropertyDecorator2(80), __metadata('design:type', Object)], Greeter.prototype, "greetings", Object.getOwnPropertyDescriptor(Greeter.prototype, "greetings")));
__decorate([PropertyDecorator1, PropertyDecorator2(60), __metadata('design:type', Number)], Greeter, "x1");
__decorate([ParameterDecorator1, ParameterDecorator2(20), __metadata('design:type', String)], Greeter, void 0, 0);
__decorate([ParameterDecorator1, ParameterDecorator2(30), __metadata('design:type', Array)], Greeter, void 0, 1);
Greeter = __decorate([ClassDecorator1, ClassDecorator2(10), __metadata('design:paramtypes', [String, String])], Greeter);
2015-03-18 19:17:26 +01:00
return Greeter;
})();
//# sourceMappingURL=sourceMapValidationDecorators.js.map