1- var TSObject = ( function ( _super ) {
1+ // TODO: Use TypeScript definitions when they get ready
2+ var __extends = ( this && this . __extends ) || ( function ( ) {
3+ var extendStatics = function ( d , b ) {
4+ extendStatics = Object . setPrototypeOf ||
5+ ( { __proto__ : [ ] } instanceof Array && function ( d , b ) { d . __proto__ = b ; } ) ||
6+ function ( d , b ) { for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ; } ;
7+ return extendStatics ( d , b ) ;
8+ } ;
9+ return function ( d , b ) {
10+ extendStatics ( d , b ) ;
11+ function __ ( ) { this . constructor = d ; }
12+ d . prototype = b === null ? Object . create ( b ) : ( __ . prototype = b . prototype , new __ ( ) ) ;
13+ } ;
14+ } ) ( ) ;
15+ var __decorate = ( this && this . __decorate ) || function ( decorators , target , key , desc ) {
16+ var c = arguments . length , r = c < 3 ? target : desc === null ? desc = Object . getOwnPropertyDescriptor ( target , key ) : desc , d ;
17+ if ( typeof Reflect === "object" && typeof Reflect . decorate === "function" ) r = Reflect . decorate ( decorators , target , key , desc ) ;
18+ 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 ;
19+ return c > 3 && r && Object . defineProperty ( target , key , r ) , r ;
20+ } ;
21+ var __metadata = ( this && this . __metadata ) || function ( k , v ) {
22+ if ( typeof Reflect === "object" && typeof Reflect . metadata === "function" ) return Reflect . metadata ( k , v ) ;
23+ } ;
24+ var __param = ( this && this . __param ) || function ( paramIndex , decorator ) {
25+ return function ( target , key ) { decorator ( target , key , paramIndex ) ; }
26+ } ;
27+ var TSObject = /** @class */ ( function ( _super ) {
228 __extends ( TSObject , _super ) ;
329 function TSObject ( ) {
430 return _super !== null && _super . apply ( this , arguments ) || this ;
@@ -58,14 +84,14 @@ var TSObject = (function (_super) {
5884 TSObject . returnsConstructorMethod = function ( ) {
5985 return TSObject ;
6086 } ;
87+ TSObject . property = 1 ;
88+ TSObject . ObjCExposedMethods = {
89+ 'voidSelector' : { returns : interop . types . void } ,
90+ 'variadicSelector:x:' : { returns : NSObject , params : [ NSString , interop . types . int32 ] }
91+ } ;
6192 return TSObject ;
6293} ( TNSDerivedInterface ) ) ;
63- TSObject . property = 1 ;
64- TSObject . ObjCExposedMethods = {
65- 'voidSelector' : { returns : interop . types . void } ,
66- 'variadicSelector:x:' : { returns : NSObject , params : [ NSString , interop . types . int32 ] }
67- } ;
68- var TSObject1 = ( function ( _super ) {
94+ var TSObject1 = /** @class */ ( function ( _super ) {
6995 __extends ( TSObject1 , _super ) ;
7096 function TSObject1 ( ) {
7197 return _super !== null && _super . apply ( this , arguments ) || this ;
@@ -98,10 +124,10 @@ var TSObject1 = (function (_super) {
98124 enumerable : true ,
99125 configurable : true
100126 } ) ;
127+ TSObject1 . ObjCProtocols = [ TNSBaseProtocol2 ] ;
101128 return TSObject1 ;
102129} ( NSObject ) ) ;
103- TSObject1 . ObjCProtocols = [ TNSBaseProtocol2 ] ;
104- var TSDecoratedObject = ( function ( _super ) {
130+ var TSDecoratedObject = /** @class */ ( function ( _super ) {
105131 __extends ( TSDecoratedObject , _super ) ;
106132 function TSDecoratedObject ( ) {
107133 return _super !== null && _super . apply ( this , arguments ) || this ;
@@ -116,16 +142,22 @@ var TSDecoratedObject = (function (_super) {
116142 TSDecoratedObject . staticFunc = function ( x ) {
117143 TNSLog ( 'staticFunc:' + x + ' called' ) ;
118144 } ;
145+ __decorate ( [
146+ ObjCMethod ( ) ,
147+ __metadata ( "design:type" , Function ) ,
148+ __metadata ( "design:paramtypes" , [ ] ) ,
149+ __metadata ( "design:returntype" , void 0 )
150+ ] , TSDecoratedObject . prototype , "voidSelector" , null ) ;
151+ __decorate ( [
152+ ObjCMethod ( 'variadicSelector:x:' , NSObject ) ,
153+ __param ( 0 , ObjCParam ( NSString ) ) , __param ( 1 , ObjCParam ( interop . types . int32 ) ) ,
154+ __metadata ( "design:type" , Function ) ,
155+ __metadata ( "design:paramtypes" , [ Object , Object ] ) ,
156+ __metadata ( "design:returntype" , void 0 )
157+ ] , TSDecoratedObject . prototype , "variadicSelectorX" , null ) ;
119158 return TSDecoratedObject ;
120159} ( TNSDerivedInterface ) ) ;
121- __decorate ( [
122- ObjCMethod ( )
123- ] , TSDecoratedObject . prototype , "voidSelector" , null ) ;
124- __decorate ( [
125- ObjCMethod ( 'variadicSelector:x:' , NSObject ) ,
126- __param ( 0 , ObjCParam ( NSString ) ) , __param ( 1 , ObjCParam ( interop . types . int32 ) )
127- ] , TSDecoratedObject . prototype , "variadicSelectorX" , null ) ;
128- var TSDecoratedObject1 = ( function ( _super ) {
160+ var TSDecoratedObject1 = /** @class */ ( function ( _super ) {
129161 __extends ( TSDecoratedObject1 , _super ) ;
130162 function TSDecoratedObject1 ( ) {
131163 return _super !== null && _super . apply ( this , arguments ) || this ;
@@ -158,12 +190,12 @@ var TSDecoratedObject1 = (function (_super) {
158190 enumerable : true ,
159191 configurable : true
160192 } ) ;
193+ TSDecoratedObject1 = __decorate ( [
194+ ObjCClass ( TNSBaseProtocol2 )
195+ ] , TSDecoratedObject1 ) ;
161196 return TSDecoratedObject1 ;
162197} ( NSObject ) ) ;
163- TSDecoratedObject1 = __decorate ( [
164- ObjCClass ( TNSBaseProtocol2 )
165- ] , TSDecoratedObject1 ) ;
166- var UnusedConstructor = ( function ( _super ) {
198+ var UnusedConstructor = /** @class */ ( function ( _super ) {
167199 __extends ( UnusedConstructor , _super ) ;
168200 function UnusedConstructor ( ) {
169201 var _this = _super !== null && _super . apply ( this , arguments ) || this ;
@@ -238,6 +270,78 @@ describe(module.id, function () {
238270 expect ( TNSGetOutput ( ) ) . toBe ( 'voidSelector called' +
239271 'variadicSelector:native x:9 called' ) ;
240272 } ) ;
273+ it ( "MethodOverrides: errors" , function ( ) {
274+ expect ( function ( ) {
275+ var TSObjectErr1 = /** @class */ ( function ( _super ) {
276+ __extends ( TSObjectErr1 , _super ) ;
277+ function TSObjectErr1 ( ) {
278+ return _super !== null && _super . apply ( this , arguments ) || this ;
279+ }
280+ Object . defineProperty ( TSObjectErr1 . prototype , "isEqual" , {
281+ get : function ( ) { return false ; } ,
282+ enumerable : true ,
283+ configurable : true
284+ } ) ;
285+ return TSObjectErr1 ;
286+ } ( NSObject ) ) ;
287+ return TSObjectErr1 . alloc ( ) ;
288+ } ) . toThrowError ( / C a n n o t o v e r r i d e n a t i v e m e t h o d " i s E q u a l " w i t h a p r o p e r t y , d e f i n e i t a s a J S f u n c t i o n i n s t e a d ./ ) ;
289+ expect ( function ( ) {
290+ var TSObjectErr2 = /** @class */ ( function ( _super ) {
291+ __extends ( TSObjectErr2 , _super ) ;
292+ function TSObjectErr2 ( ) {
293+ return _super !== null && _super . apply ( this , arguments ) || this ;
294+ }
295+ return TSObjectErr2 ;
296+ } ( TNSDerivedInterface ) ) ;
297+ TSObjectErr2 . prototype . isEqual = true ;
298+ return TSObjectErr2 . alloc ( ) ;
299+ } ) . toThrowError ( / t r u e c a n n o t o v e r r i d e n a t i v e m e t h o d " i s E q u a l " ./ ) ;
300+ } ) ;
301+ it ( 'ExposeWithWrongParams' , function ( ) {
302+ expect ( function ( ) {
303+ var ExposeWithWrongParams = /** @class */ ( function ( _super ) {
304+ __extends ( ExposeWithWrongParams , _super ) ;
305+ function ExposeWithWrongParams ( ) {
306+ return _super !== null && _super . apply ( this , arguments ) || this ;
307+ }
308+ ExposeWithWrongParams . prototype . wrongRet = function ( ) { } ;
309+ ExposeWithWrongParams . ObjCExposedMethods = {
310+ 'wrongRet' : { returns : "a string" , params : [ interop . types . selector ] }
311+ } ;
312+ return ExposeWithWrongParams ;
313+ } ( NSObject ) ) ;
314+ return ExposeWithWrongParams . alloc ( ) ;
315+ } ) . toThrowError ( "\"a string\" Method wrongRet has an invalid return type encoding" ) ;
316+ expect ( function ( ) {
317+ var ExposeWithWrongParams2 = /** @class */ ( function ( _super ) {
318+ __extends ( ExposeWithWrongParams2 , _super ) ;
319+ function ExposeWithWrongParams2 ( ) {
320+ return _super !== null && _super . apply ( this , arguments ) || this ;
321+ }
322+ ExposeWithWrongParams2 . prototype . wrongArg = function ( ) { } ;
323+ ExposeWithWrongParams2 . ObjCExposedMethods = {
324+ 'wrongArg' : { returns : interop . types . selector , params : [ 3 ] }
325+ } ;
326+ return ExposeWithWrongParams2 ;
327+ } ( NSObject ) ) ;
328+ return ExposeWithWrongParams2 . alloc ( ) ;
329+ } ) . toThrowError ( "3 Method wrongArg has an invalid type encoding for argument 1" ) ;
330+ expect ( function ( ) {
331+ var ExposeWithWrongParams3 = /** @class */ ( function ( _super ) {
332+ __extends ( ExposeWithWrongParams3 , _super ) ;
333+ function ExposeWithWrongParams3 ( ) {
334+ return _super !== null && _super . apply ( this , arguments ) || this ;
335+ }
336+ ExposeWithWrongParams3 . prototype . wrongArg = function ( ) { } ;
337+ ExposeWithWrongParams3 . ObjCExposedMethods = {
338+ 'wrongArg' : { returns : interop . types . void , params : { notArray : true } }
339+ } ;
340+ return ExposeWithWrongParams3 ;
341+ } ( NSObject ) ) ;
342+ return ExposeWithWrongParams3 . alloc ( ) ;
343+ } ) . toThrowError ( "Object The 'params' property of method wrongArg is not an array" ) ;
344+ } ) ;
241345 it ( 'AddedNewProperty' , function ( ) {
242346 var object = TSObject . alloc ( ) . init ( ) ;
243347 expect ( object . method ( ) ) . toBe ( 1 ) ;
@@ -257,12 +361,12 @@ describe(module.id, function () {
257361 'baseProtocolProperty1Optional called' ) ;
258362 } ) ;
259363 it ( 'PlainExtends' , function ( ) {
260- var A = ( function ( ) {
364+ var A = /** @class */ ( function ( ) {
261365 function A ( ) {
262366 }
263367 return A ;
264368 } ( ) ) ;
265- var B = ( function ( _super ) {
369+ var B = /** @class */ ( function ( _super ) {
266370 __extends ( B , _super ) ;
267371 function B ( ) {
268372 return _super !== null && _super . apply ( this , arguments ) || this ;
@@ -273,7 +377,7 @@ describe(module.id, function () {
273377 } ) ;
274378 it ( 'Scope' , function ( ) {
275379 global [ "Derived" ] = 3 ;
276- var Derived = ( function ( _super ) {
380+ var Derived = /** @class */ ( function ( _super ) {
277381 __extends ( Derived , _super ) ;
278382 function Derived ( ) {
279383 return _super !== null && _super . apply ( this , arguments ) || this ;
0 commit comments