diff --git a/promises-a-plus/index.d.ts b/promises-a-plus/index.d.ts deleted file mode 100644 index 806020d051..0000000000 --- a/promises-a-plus/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for promises-a-plus -// Project: http://promisesaplus.com/ -// Definitions by: Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace PromisesAPlus { - interface PromiseCtor { - (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; - } - - interface PromiseImpl { - new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; - } - - interface Thenable { - then(onFulfill?: (value: T) => Thenable|R, onReject?: (error: any) => Thenable|R): Thenable; - } -} diff --git a/promises-a-plus/promises-a-plus-tests.ts b/promises-a-plus/promises-a-plus-tests.ts deleted file mode 100644 index 222cca14d8..0000000000 --- a/promises-a-plus/promises-a-plus-tests.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// -/// -/// - -var thenNum: PromisesAPlus.Thenable; -var thenStr: PromisesAPlus.Thenable; -var thenBool: PromisesAPlus.Thenable; - -var impl: PromisesAPlus.PromiseImpl; - -declare class PromiseImpl { - constructor(resolver: (resolvePromise: (value: R) => void, rejectPromise: (reason: any) => void) => void); - - then(onFulfill: (value: R) => PromiseImpl, onReject: (error: any) => PromiseImpl): PromiseImpl; - then(onFulfill: (value: R) => PromiseImpl, onReject?: (error: any) => U): PromiseImpl; - then(onFulfill: (value: R) => U, onReject: (error: any) => PromiseImpl): PromiseImpl; - then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): PromiseImpl; -} - -function testCompatibleWithPromiseImpl() { - var pNum: PromiseImpl = thenNum; - - thenNum = pNum; - - impl = PromiseImpl; -} - -function testCompatibleWithRxJS() { - // from spec to Rx - var rxThenNum: Rx.IPromise = thenNum; - var rxThenStr: Rx.IPromise = thenStr; - - // from Rx to spec - thenNum = rxThenNum; - thenStr = rxThenStr; - - var obsNum: Rx.Observable; - - // implementation usage - thenNum = obsNum.toPromise>(impl); - thenNum = obsNum.toPromise(impl); - obsNum.toPromise(PromiseImpl); -} - -function testCompatibleWithES6Promises() { - // define ES6 thenables - var es6ThenNum: PromiseLike; - var es6ThenStr: PromiseLike; - - // from ES6 to spec - thenNum = es6ThenNum; - thenStr = es6ThenStr; - - // implementation - impl = Promise; -} - -function testCompatibleWithQ() { - // from spec to ES6 - var qThenNum: Q.IPromise = thenNum; - var qThenStr: Q.IPromise = thenStr; - - // from ES6 to spec - thenNum = qThenNum; - thenStr = qThenStr; - - // there's no standart implementation with constructor behaviour -} - -function testCompatibleWithWhen() { - var whenPromiseNum: When.Promise; - var whenPromiseStr: When.Promise; - - // from ES6 to spec - thenNum = whenPromiseNum; - thenStr = whenPromiseStr; - - // there's no standart implementation with constructor behaviour -} diff --git a/promises-a-plus/tsconfig.json b/promises-a-plus/tsconfig.json deleted file mode 100644 index d5ccf86f75..0000000000 --- a/promises-a-plus/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "promises-a-plus-tests.ts" - ] -} \ No newline at end of file diff --git a/stamplay-js-sdk/index.d.ts b/stamplay-js-sdk/index.d.ts index 53f57ad86c..81f20d8c95 100644 --- a/stamplay-js-sdk/index.d.ts +++ b/stamplay-js-sdk/index.d.ts @@ -1,35 +1,27 @@ -// Type definitions for stamplay-js-sdk 1.2.9 +// Type definitions for stamplay-js-sdk 1.2 // Project: https://github.com/Stamplay/stamplay-js-sdk // Definitions by: Riderman de Sousa Barbosa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace Stamplay { + export function init(appId: string): void; + export function User(): StamplayObject; + export function Cobject(object: string): StamplayObject; - export interface IStamplayModel { - signup({}) : PromisesAPlus.Thenable - new() : IStamplayModel - get(property : string) : any - set(property : string, value: any) : void - unset(property : string) : void - fetch(id : any) : PromisesAPlus.Thenable - destroy() : PromisesAPlus.Thenable - save({}?) : PromisesAPlus.Thenable - upVote() : PromisesAPlus.Thenable + export interface Model { + signup({}): Promise; + new(): Model; // This is suspicious, but tests show model instances being constructable... + get(property: string): any; + set(property: string, value: any): void; + unset(property: string) : void; + fetch(id: any) : Promise; + destroy(): Promise; + save({}?): Promise; + upVote(): Promise; } - export interface IStamplayObject { - Model : IStamplayModel - Collection : any - - } - - export interface StamplayStatic { - init(appId : string) : void; - User() : IStamplayObject - Cobject(object : string) : IStamplayObject + export interface StamplayObject { + Model: Model; + Collection : any; } } - -declare var Stamplay: Stamplay.StamplayStatic; diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts index d9a4247e03..9dddc1b242 100644 --- a/stamplay-js-sdk/stamplay-js-sdk-tests.ts +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -11,26 +11,24 @@ var registrationData = { password: 'mySecret' }; -user.signup(registrationData).then(function(){ - user.set('phoneNumber', '020 123 4567' ); - return user.save(); - }).then(function(){ - var number = user.get('phoneNumber'); - console.log(number); // number value is 020 123 4567 - }); +user.signup(registrationData).then(() => { + user.set('phoneNumber', '020 123 4567' ); + return user.save(); +}).then(() => { + var number = user.get('phoneNumber'); + console.log(number); // number value is 020 123 4567 +}); // Action var colFoo = Stamplay.Cobject('foo'); var fooMod = new colFoo.Model(); -fooMod.fetch(5).then( - function(){ - return fooMod.upVote() - } -).then( - function(){ +fooMod.fetch(5) + .then(() => fooMod.upVote()) + .then( + () => { //success callback - }, function( err : any ){ + }, (err: any) => { //error callback } ) diff --git a/stamplay-js-sdk/tslint.json b/stamplay-js-sdk/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/stamplay-js-sdk/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file