Skip to content

Commit a24e953

Browse files
committed
Added experimental typings definition for TypeScript support
1 parent 5734f40 commit a24e953

File tree

12 files changed

+170
-35
lines changed

12 files changed

+170
-35
lines changed

dist/decorators/component/require.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
44

5-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
5+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
66

77
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
88

@@ -54,14 +54,14 @@ describe('@Require Component Decorator', function () {
5454
})();
5555

5656
var Child = (function (_Parent2) {
57+
_inherits(Child, _Parent2);
58+
5759
function Child() {
5860
_classCallCheck(this, _Child);
5961

6062
_get(Object.getPrototypeOf(_Child.prototype), 'constructor', this).apply(this, arguments);
6163
}
6264

63-
_inherits(Child, _Parent2);
64-
6565
var _Child = Child;
6666
Child = (0, _require.Require)('b')(Child) || Child;
6767
return Child;

dist/decorators/component/view.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
44

5-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
5+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
66

77
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
88

@@ -53,28 +53,28 @@ describe('@View Decorator', function () {
5353
})();
5454

5555
var Child = (function (_Parent2) {
56+
_inherits(Child, _Parent2);
57+
5658
function Child() {
5759
_classCallCheck(this, _Child);
5860

5961
_get(Object.getPrototypeOf(_Child.prototype), 'constructor', this).apply(this, arguments);
6062
}
6163

62-
_inherits(Child, _Parent2);
63-
6464
var _Child = Child;
6565
Child = (0, _view.View)({ templateUrl: '/path/to/it' })(Child) || Child;
6666
return Child;
6767
})(Parent);
6868

6969
var GrandChild = (function (_Child2) {
70+
_inherits(GrandChild, _Child2);
71+
7072
function GrandChild() {
7173
_classCallCheck(this, _GrandChild);
7274

7375
_get(Object.getPrototypeOf(_GrandChild.prototype), 'constructor', this).apply(this, arguments);
7476
}
7577

76-
_inherits(GrandChild, _Child2);
77-
7878
var _GrandChild = GrandChild;
7979
GrandChild = (0, _view.View)({ template: 'new test' })(GrandChild) || GrandChild;
8080
return GrandChild;

dist/decorators/inject.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_ag
44

55
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
66

7-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
7+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
88

99
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
1010

@@ -57,14 +57,14 @@ describe('@Inject annotation', function () {
5757
})();
5858

5959
var SubClass = (function (_MyClass4) {
60+
_inherits(SubClass, _MyClass4);
61+
6062
function SubClass() {
6163
_classCallCheck(this, _SubClass);
6264

6365
_get(Object.getPrototypeOf(_SubClass.prototype), 'constructor', this).apply(this, arguments);
6466
}
6567

66-
_inherits(SubClass, _MyClass4);
67-
6868
var _SubClass = SubClass;
6969
SubClass = (0, _inject.Inject)('d', 'e', 'f')(SubClass) || SubClass;
7070
return SubClass;

dist/decorators/providers/component.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
44

5-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
5+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
66

77
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
88

@@ -101,14 +101,14 @@ describe('@Component annotation', function () {
101101
})();
102102

103103
var ChildCtrl = (function (_ParentCtrl2) {
104+
_inherits(ChildCtrl, _ParentCtrl2);
105+
104106
function ChildCtrl() {
105107
_classCallCheck(this, _ChildCtrl);
106108

107109
_get(Object.getPrototypeOf(_ChildCtrl.prototype), 'constructor', this).apply(this, arguments);
108110
}
109111

110-
_inherits(ChildCtrl, _ParentCtrl2);
111-
112112
var _ChildCtrl = ChildCtrl;
113113
ChildCtrl = (0, _component.Component)({ selector: 'child' })(ChildCtrl) || ChildCtrl;
114114
return ChildCtrl;

dist/decorators/providers/controller.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_ag
44

55
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
66

7-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
7+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
88

99
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
1010

@@ -79,14 +79,14 @@ describe('@Controller annotation', function () {
7979
})();
8080

8181
var NewController = (function (_MyController4) {
82+
_inherits(NewController, _MyController4);
83+
8284
function NewController() {
8385
_classCallCheck(this, _NewController);
8486

8587
_get(Object.getPrototypeOf(_NewController.prototype), 'constructor', this).apply(this, arguments);
8688
}
8789

88-
_inherits(NewController, _MyController4);
89-
9090
var _NewController = NewController;
9191
NewController = (0, _controller.Controller)(NewController) || NewController;
9292
return NewController;

dist/decorators/providers/factory.spec.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ describe('@Factory Annotation', function () {
5555
_classCallCheck(this, _ExampleClass2);
5656
}
5757

58-
var _ExampleClass2 = ExampleClass;
59-
60-
_createClass(_ExampleClass2, null, [{
58+
_createClass(ExampleClass, null, [{
6159
key: 'create',
6260
value: function create() {
6361
called = true;
6462
}
6563
}]);
6664

65+
var _ExampleClass2 = ExampleClass;
6766
ExampleClass = (0, _factory.Factory)('MyFactory')(ExampleClass) || ExampleClass;
6867
return ExampleClass;
6968
})();
@@ -85,9 +84,7 @@ describe('@Factory Annotation', function () {
8584
_classCallCheck(this, _ExampleClass3);
8685
}
8786

88-
var _ExampleClass3 = ExampleClass;
89-
90-
_createClass(_ExampleClass3, null, [{
87+
_createClass(ExampleClass, null, [{
9188
key: 'create',
9289
value: function create(dependencies) {
9390
var _dependencies = _slicedToArray(dependencies, 2);
@@ -97,6 +94,7 @@ describe('@Factory Annotation', function () {
9794
}
9895
}]);
9996

97+
var _ExampleClass3 = ExampleClass;
10098
ExampleClass = (0, _factory.Factory)('MyFactory')(ExampleClass) || ExampleClass;
10199
return ExampleClass;
102100
})();

dist/decorators/providers/service.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_ag
44

55
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
66

7-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
7+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
88

99
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
1010

@@ -46,14 +46,14 @@ describe('@Service Decorator', function () {
4646
})();
4747

4848
var MyClass = (function (_BaseClass2) {
49+
_inherits(MyClass, _BaseClass2);
50+
4951
function MyClass() {
5052
_classCallCheck(this, _MyClass);
5153

5254
_get(Object.getPrototypeOf(_MyClass.prototype), 'constructor', this).apply(this, arguments);
5355
}
5456

55-
_inherits(MyClass, _BaseClass2);
56-
5757
var _MyClass = MyClass;
5858
MyClass = (0, _service.Service)(MyClass) || MyClass;
5959
return MyClass;

dist/index.d.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
export function Factory(name: string): (any) => void;
3+
export function Inject(...dependencies: string[]): (any) => void;
4+
export function Service(name: string): (any) => void;
5+
6+
export function Component(
7+
componentConfig: {
8+
selector: string,
9+
properties?: string[],
10+
controllerAs?: string,
11+
bindings?: any,
12+
restrict?: string,
13+
scope?: any,
14+
bindToController?: boolean
15+
}
16+
): (any) => void;
17+
18+
export function Directive(
19+
directiveConfig: {
20+
selector: string,
21+
properties?: string[],
22+
controllerAs?: string,
23+
bindings?: any,
24+
restrict?: string,
25+
scope?: any,
26+
bindToController?: boolean
27+
}
28+
): (any) => void;
29+
30+
export function Controller(name: string): (any) => void;
31+
32+
export interface IFilter{
33+
supports(input: any): boolean;
34+
transform(input: any, ...params: any[]): any;
35+
}
36+
37+
export function Filter(name: string): (IFilter) => void;
38+
39+
export interface IProvider{
40+
$get: any;
41+
}
42+
43+
export function Provider(name: string): (IProvider) => void;
44+
45+
export function Animation(classSelector: string): (any) => void;
46+
47+
export function Require(...directiveNames: string[]): (any) => void;
48+
49+
export function View(
50+
viewConfig: {
51+
template?: string,
52+
templateUrl?: string
53+
}
54+
): (any) => void;
55+
56+
export function Transclude(any): (any) => any;
57+
58+
export interface IModule{
59+
add(...providers: any[]): IModule;
60+
config(...providers: any[]): IModule;
61+
run(...providers: any[]): IModule;
62+
value(name: string, value: any);
63+
constant(name: string, value: any);
64+
}
65+
66+
export function Module(name: string, dependencies: any[]): IModule;

dist/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var _parsers = {};
1515

1616
var DecoratedModule = (function () {
1717
function DecoratedModule(name) {
18-
var modules = arguments[1] === undefined ? false : arguments[1];
18+
var modules = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
1919

2020
_classCallCheck(this, DecoratedModule);
2121

dist/util/decorate-directive.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var _createClass = (function () { function defineProperties(target, props) { for
99

1010
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
1111

12-
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
12+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1313

1414
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
1515

@@ -175,14 +175,14 @@ describe('Directive Decorator', function () {
175175
}, Parent);
176176

177177
var Child = (function (_Parent) {
178+
_inherits(Child, _Parent);
179+
178180
function Child() {
179181
_classCallCheck(this, Child);
180182

181183
_get(Object.getPrototypeOf(Child.prototype), 'constructor', this).apply(this, arguments);
182184
}
183185

184-
_inherits(Child, _Parent);
185-
186186
return Child;
187187
})(Parent);
188188

gulpfile.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
var gulp = require('gulp');
22
var babel = require('gulp-babel');
33
var mocha = require('gulp-mocha');
4-
5-
gulp.task('build', function () {
4+
5+
gulp.task('transpile', function () {
66
return gulp.src('src/**/*.js')
77
.pipe(babel({
8-
stage : 0
8+
stage: 0
99
}))
1010
.pipe(gulp.dest('dist'));
1111
});
1212

13+
gulp.task('build', ['transpile'], function () {
14+
return gulp.src('src/index.d.ts')
15+
.pipe(gulp.dest('dist'));
16+
});
17+
1318
gulp.task('test', ['build'], function (done) {
1419
return gulp.src('dist/**/*.spec.js')
15-
.pipe(mocha({ reporter : 'spec' }));
20+
.pipe(mocha({ reporter: 'spec' }));
1621
});
1722

1823
gulp.task('default', function(){
1924
gulp.watch('./src/**/*.js', ['test']);
20-
});
25+
});

0 commit comments

Comments
 (0)