forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#44316 Make Vimeo request() generic to opti…
…onally type results by @mattleff * Make Vimeo request() generic to optionally type results * Add tests for vimeo types * Don't type request() method
- Loading branch information
Showing
3 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts" | ||
"index.d.ts", | ||
"vimeo-tests.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { RequestOptions, Vimeo } from 'vimeo'; | ||
|
||
const errorHandler = (e: string) => {}; | ||
const uriHandler = (uri: string) => {}; | ||
const progressHandler = (bytesUploaded: number, bytesTotal: number) => {}; | ||
const completeHandler = ( | ||
err: string | undefined, | ||
result: undefined | object, | ||
statusCode?: number, | ||
headers?: object, | ||
) => {}; | ||
const completeHandlerShort = (err: string | undefined, result: undefined | object) => {}; | ||
|
||
// $ExpectType Vimeo | ||
const client = new Vimeo('', '', ''); | ||
|
||
// $ExpectType void | ||
client.upload('', {}, uriHandler, undefined, errorHandler); | ||
|
||
// $ExpectType void | ||
client.upload('', {}, uriHandler, progressHandler, errorHandler); | ||
|
||
// $ExpectType void | ||
client.upload('', uriHandler, undefined, errorHandler); | ||
|
||
// $ExpectType void | ||
client.upload('', uriHandler, progressHandler, errorHandler); | ||
|
||
// $ExpectType void | ||
client.replace('', '', {}, uriHandler, undefined, errorHandler); | ||
|
||
// $ExpectType void | ||
client.replace('', '', {}, uriHandler, progressHandler, errorHandler); | ||
|
||
// $ExpectType void | ||
client.request('', completeHandler); | ||
|
||
// $ExpectType void | ||
client.request('', completeHandlerShort); | ||
|
||
// $ExpectType void | ||
client.request('', (err: string | undefined, result: string | undefined) => {}); | ||
|
||
// $ExpectType void | ||
client.request('', (err: string | undefined, result: { thing: string } | undefined) => {}); | ||
|
||
const requestOptions: RequestOptions = { | ||
method: 'GET', | ||
path: '/videos/123', | ||
}; | ||
|
||
// $ExpectType void | ||
client.request(requestOptions, completeHandler); | ||
|
||
const requestOptionsFull: RequestOptions = { | ||
method: 'GET', | ||
path: '/videos/123', | ||
headers: {}, | ||
query: 'thing=thing2', | ||
}; | ||
|
||
// $ExpectType void | ||
client.request(requestOptionsFull, (err: string | undefined, result: string | undefined) => {}); | ||
|
||
// $ExpectType Vimeo | ||
const clientWithoutAccessToken = new Vimeo('', ''); | ||
|
||
// $ExpectType void | ||
clientWithoutAccessToken.setAccessToken(''); | ||
|
||
// $ExpectType void | ||
clientWithoutAccessToken.accessToken('', '', completeHandler); | ||
|
||
// $ExpectType void | ||
clientWithoutAccessToken.buildAuthorizationEndpoint('', '', ''); | ||
|
||
// $ExpectType void | ||
clientWithoutAccessToken.buildAuthorizationEndpoint('', [''], ''); |