From f42e2acfbfeda3ed3d183ad00e6b958a5bfe0574 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 28 Jan 2019 12:54:16 -0800 Subject: [PATCH] Fix jsforce definitions --- types/jsforce/api/chatter.d.ts | 6 +----- types/jsforce/api/metadata.d.ts | 6 +----- types/jsforce/jsforce-tests.ts | 6 +++--- types/jsforce/tslint.json | 1 + 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/types/jsforce/api/chatter.d.ts b/types/jsforce/api/chatter.d.ts index c712187559..4b65740f36 100644 --- a/types/jsforce/api/chatter.d.ts +++ b/types/jsforce/api/chatter.d.ts @@ -27,7 +27,7 @@ interface RequestParams { export class RequestResult { } -export class Request implements Promise { +export class Request implements PromiseLike { constructor(chatter: Chatter, params: RequestParams); batchParams(): BatchRequestParams; @@ -36,16 +36,12 @@ export class Request implements Promise { stream(): Stream; - catch(onrejected?: ((reason: any) => (PromiseLike | TResult)) | null | undefined): Promise; - then(onfulfilled?: ((value: T) => (PromiseLike | TResult1)) | null | undefined, onrejected?: ((reason: any) => (PromiseLike | TResult2)) | null | undefined): Promise; finally(onfinally?: () => void): Promise; thenCall(callback?: (err: Error, records: T) => void): Query; - - readonly [Symbol.toStringTag]: 'Promise'; } export class Resource extends Request { diff --git a/types/jsforce/api/metadata.d.ts b/types/jsforce/api/metadata.d.ts index c6aec12e7e..88dbdaa52d 100644 --- a/types/jsforce/api/metadata.d.ts +++ b/types/jsforce/api/metadata.d.ts @@ -112,21 +112,17 @@ interface DeployOptions { singlePackage?: boolean; } -export class AsyncResultLocator extends EventEmitter implements Promise { +export class AsyncResultLocator extends EventEmitter implements PromiseLike { check(callback?: Callback): Promise complete(callback?: Callback): Promise poll(interval: number, timeout: number): void; - catch(onrejected?: ((reason: any) => (PromiseLike | TResult)) | null | undefined): Promise; - then(onfulfilled?: ((value: T) => (PromiseLike | TResult1)) | null | undefined, onrejected?: ((reason: any) => (PromiseLike | TResult2)) | null | undefined): Promise; finally(onfinally?: () => void): Promise; - - readonly [Symbol.toStringTag]: "Promise"; } export class DeployResultLocator extends AsyncResultLocator {} diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 08ea888062..45442b91dc 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -615,7 +615,7 @@ async function testChatter(conn: sf.Connection): Promise { const feedResource: sf.Resource = chatter.resource('/feed-elements'); - const feedCreateRequest: any = await (feedResource.create({ + const feedCreateRequest: any = await feedResource.create({ body: { messageSegments: [{ type: 'Text', @@ -624,13 +624,13 @@ async function testChatter(conn: sf.Connection): Promise { }, feedElementType: 'FeedItem', subjectId: 'me' - }) as Promise); + }); console.log(`feedCreateRequest.id: ${feedCreateRequest.id}`); const itemLikesUrl = `/feed-elements/${feedCreateRequest.id}/capabilities/chatter-likes/items`; const itemsLikeResource: sf.Resource = chatter.resource(itemLikesUrl); - const itemsLikeCreateResult: sf.RequestResult = await (itemsLikeResource.create('') as Promise); + const itemsLikeCreateResult: sf.RequestResult = await itemsLikeResource.create(''); console.log(`itemsLikeCreateResult['likedItem']: ${itemsLikeCreateResult as any['likedItem']}`); } diff --git a/types/jsforce/tslint.json b/types/jsforce/tslint.json index 43829466b8..12201695b9 100644 --- a/types/jsforce/tslint.json +++ b/types/jsforce/tslint.json @@ -3,6 +3,7 @@ "rules": { // TODOs "array-type": false, + "await-promise": [true, "Request"], "ban-types": false, "eofline": false, "max-line-length": false,