Merge pull request #31686 from BendingBender/remote-origin-url

[remote-origin-url] Add types
This commit is contained in:
Wesley Wigham
2018-12-25 22:40:31 -08:00
committed by GitHub
4 changed files with 73 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for remote-origin-url 2.0
// Project: https://github.com/jonschlinkert/remote-origin-url
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = remoteOriginUrl;
declare function remoteOriginUrl(
options?: string | remoteOriginUrl.Options
): Promise<string | undefined>;
declare function remoteOriginUrl(callback: remoteOriginUrl.Callback): void;
declare function remoteOriginUrl(
options: string | remoteOriginUrl.Options,
callback: remoteOriginUrl.Callback
): void;
declare namespace remoteOriginUrl {
function promise(options?: string | Options): Promise<string | undefined>;
function sync(options?: string | Options): string | undefined;
interface Options {
path?: string;
}
type Callback = (error: Error | null, url?: string) => void;
}
@@ -0,0 +1,23 @@
import origin = require('remote-origin-url');
origin(); // $ExpectType Promise<string | undefined>
origin('foo'); // $ExpectType Promise<string | undefined>
origin({ path: 'foo' }); // $ExpectType Promise<string | undefined>
// $ExpectType void
origin((err, url) => {
err; // $ExpectType Error | null
url; // $ExpectType string | undefined
});
// $ExpectType void
origin({ path: 'foo' }, (err, url) => {
err; // $ExpectType Error | null
url; // $ExpectType string | undefined
});
origin.promise(); // $ExpectType Promise<string | undefined>
origin.promise('foo'); // $ExpectType Promise<string | undefined>
origin.promise({ path: 'foo' }); // $ExpectType Promise<string | undefined>
origin.sync(); // $ExpectType string | undefined
origin.sync('foo'); // $ExpectType string | undefined
origin.sync({ path: 'foo' }); // $ExpectType string | undefined
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"remote-origin-url-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }