Skip to content

Commit e843908

Browse files
author
Kanchalai Tanglertsampan
committed
Add tests for emitting metadata with module targetting system
1 parent 8b128d9 commit e843908

File tree

9 files changed

+127
-0
lines changed

9 files changed

+127
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
2+
3+
4+
==== main.ts (1 errors) ====
5+
import * as ng from "angular2/core";
6+
~~~~~~~~~~~~~~~
7+
!!! error TS2307: Cannot find module 'angular2/core'.
8+
9+
declare function foo(...args: any[]);
10+
11+
@foo
12+
export class MyClass1 {
13+
constructor(private _elementRef: ng.ElementRef){}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
3+
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS",
4+
"baselineCheck": true,
5+
"runTest": true,
6+
"resolvedInputFiles": [
7+
"lib.d.ts",
8+
"main.ts"
9+
],
10+
"emittedFiles": [
11+
"main.js"
12+
]
13+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4+
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;
5+
return c > 3 && r && Object.defineProperty(target, key, r), r;
6+
};
7+
var __metadata = (this && this.__metadata) || function (k, v) {
8+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9+
};
10+
define(["require", "exports", "angular2/core"], function (require, exports, ng) {
11+
"use strict";
12+
var MyClass1 = (function () {
13+
function MyClass1(_elementRef) {
14+
this._elementRef = _elementRef;
15+
}
16+
MyClass1 = __decorate([
17+
foo,
18+
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
19+
], MyClass1);
20+
return MyClass1;
21+
var _a;
22+
}());
23+
exports.MyClass1 = MyClass1;
24+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
main.ts(1,21): error TS2307: Cannot find module 'angular2/core'.
2+
3+
4+
==== main.ts (1 errors) ====
5+
import * as ng from "angular2/core";
6+
~~~~~~~~~~~~~~~
7+
!!! error TS2307: Cannot find module 'angular2/core'.
8+
9+
declare function foo(...args: any[]);
10+
11+
@foo
12+
export class MyClass1 {
13+
constructor(private _elementRef: ng.ElementRef){}
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
3+
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS",
4+
"baselineCheck": true,
5+
"runTest": true,
6+
"resolvedInputFiles": [
7+
"lib.d.ts",
8+
"main.ts"
9+
],
10+
"emittedFiles": [
11+
"main.js"
12+
]
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use strict";
2+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5+
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;
6+
return c > 3 && r && Object.defineProperty(target, key, r), r;
7+
};
8+
var __metadata = (this && this.__metadata) || function (k, v) {
9+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10+
};
11+
var ng = require("angular2/core");
12+
var MyClass1 = (function () {
13+
function MyClass1(_elementRef) {
14+
this._elementRef = _elementRef;
15+
}
16+
MyClass1 = __decorate([
17+
foo,
18+
__metadata('design:paramtypes', [(typeof (_a = typeof ng !== 'undefined' && ng.ElementRef) === 'function' && _a) || Object])
19+
], MyClass1);
20+
return MyClass1;
21+
var _a;
22+
}());
23+
exports.MyClass1 = MyClass1;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"scenario": "Emit decorator metadata when commonJS and isolatedModules are on",
3+
"projectRoot": "tests/cases/projects/decoratorMetadata/emitDecoratorMetadataSystemJS",
4+
"baselineCheck": true,
5+
"runTest": true
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as ng from "angular2/core";
2+
3+
declare function foo(...args: any[]);
4+
5+
@foo
6+
export class MyClass1 {
7+
constructor(private _elementRef: ng.ElementRef){}
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compileOnSave": true,
3+
"compilerOptions": {
4+
"target": "es5",
5+
"module": "system",
6+
"emitDecoratorMetadata": true,
7+
"experimentalDecorators": true
8+
},
9+
"files": [
10+
"main.ts"
11+
]
12+
}

0 commit comments

Comments
 (0)