Merge pull request #32571 from DefinitelyTyped/fixJsforce

Fix jsforce definitions
This commit is contained in:
Ron Buckton
2019-01-31 16:32:39 -08:00
committed by GitHub
4 changed files with 6 additions and 13 deletions

View File

@@ -27,7 +27,7 @@ interface RequestParams {
export class RequestResult {
}
export class Request<T> implements Promise<T> {
export class Request<T> implements PromiseLike<T> {
constructor(chatter: Chatter, params: RequestParams);
batchParams(): BatchRequestParams;
@@ -36,16 +36,12 @@ export class Request<T> implements Promise<T> {
stream(): Stream;
catch<TResult>(onrejected?: ((reason: any) => (PromiseLike<TResult> | TResult)) | null | undefined): Promise<T | TResult>;
then<TResult1, TResult2>(onfulfilled?: ((value: T) => (PromiseLike<TResult1> | TResult1)) | null | undefined,
onrejected?: ((reason: any) => (PromiseLike<TResult2> | TResult2)) | null | undefined): Promise<TResult1 | TResult2>;
finally(onfinally?: () => void): Promise<T>;
thenCall(callback?: (err: Error, records: T) => void): Query<T>;
readonly [Symbol.toStringTag]: 'Promise';
}
export class Resource<T> extends Request<T> {

View File

@@ -112,21 +112,17 @@ interface DeployOptions {
singlePackage?: boolean;
}
export class AsyncResultLocator<T> extends EventEmitter implements Promise<T> {
export class AsyncResultLocator<T> extends EventEmitter implements PromiseLike<T> {
check(callback?: Callback<T>): Promise<T>
complete(callback?: Callback<T>): Promise<T>
poll(interval: number, timeout: number): void;
catch<TResult>(onrejected?: ((reason: any) => (PromiseLike<TResult> | TResult)) | null | undefined): Promise<T | TResult>;
then<TResult1, TResult2>(onfulfilled?: ((value: T) => (PromiseLike<TResult1> | TResult1)) | null | undefined,
onrejected?: ((reason: any) => (PromiseLike<TResult2> | TResult2)) | null | undefined): Promise<TResult1 | TResult2>;
finally(onfinally?: () => void): Promise<T>;
readonly [Symbol.toStringTag]: "Promise";
}
export class DeployResultLocator<T> extends AsyncResultLocator<T> {}

View File

@@ -615,7 +615,7 @@ async function testChatter(conn: sf.Connection): Promise<void> {
const feedResource: sf.Resource<sf.RequestResult> = 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<void> {
},
feedElementType: 'FeedItem',
subjectId: 'me'
}) as Promise<sf.RequestResult>);
});
console.log(`feedCreateRequest.id: ${feedCreateRequest.id}`);
const itemLikesUrl = `/feed-elements/${feedCreateRequest.id}/capabilities/chatter-likes/items`;
const itemsLikeResource: sf.Resource<sf.RequestResult> = chatter.resource(itemLikesUrl);
const itemsLikeCreateResult: sf.RequestResult = await (itemsLikeResource.create('') as Promise<sf.RequestResult>);
const itemsLikeCreateResult: sf.RequestResult = await itemsLikeResource.create('');
console.log(`itemsLikeCreateResult['likedItem']: ${itemsLikeCreateResult as any['likedItem']}`);
}

View File

@@ -3,6 +3,7 @@
"rules": {
// TODOs
"array-type": false,
"await-promise": [true, "Request"],
"ban-types": false,
"eofline": false,
"max-line-length": false,