[new-github-release-url] Add types

This commit is contained in:
Dimitri Benin
2019-01-09 20:03:18 +01:00
parent e836acc75a
commit 3f04bdfc94
4 changed files with 131 additions and 0 deletions

63
types/new-github-release-url/index.d.ts vendored Normal file
View File

@@ -0,0 +1,63 @@
// Type definitions for new-github-release-url 0.1
// Project: https://github.com/sindresorhus/new-github-release-url#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
export = newGithubReleaseUrl;
/**
* Returns a URL string.
*/
declare function newGithubReleaseUrl(options: newGithubReleaseUrl.Options): string;
declare namespace newGithubReleaseUrl {
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
type Options = XOR<RepoUrlOptions, UserRepoOptions>;
interface BaseOptions {
/**
* The tag name of the release.
*/
tag?: string;
/**
* The branch name or commit SHA to point the release's tag at, if the tag doesn't already exist.
* @default The default branch
*/
target?: string;
/**
* The title of the release.
* GitHub shows the `tag` name when not specified.
*/
title?: string;
/**
* The description text of the release.
*/
body?: string;
/**
* Whether the release should be marked as a pre-release.
* @default false
*/
isPrerelease?: boolean;
}
interface RepoUrlOptions extends BaseOptions {
/**
* The full URL to the repo.
*/
repoUrl: string;
}
interface UserRepoOptions extends BaseOptions {
/**
* GitHub username or organization.
*/
user: string;
/**
* GitHub repo.
*/
repo: string;
}
}

View File

@@ -0,0 +1,44 @@
import newGithubReleaseUrl = require('new-github-release-url');
// $ExpectType string
newGithubReleaseUrl({
repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git',
});
// $ExpectType string
newGithubReleaseUrl({
user: 'sindresorhus',
repo: 'new-github-release-url',
});
// $ExpectError
newGithubReleaseUrl({
user: 'sindresorhus',
});
// $ExpectError
newGithubReleaseUrl({
repo: 'new-github-release-url',
});
// $ExpectType string
newGithubReleaseUrl({
repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git',
tag: 'foo',
});
// $ExpectType string
newGithubReleaseUrl({
repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git',
target: 'foo',
});
// $ExpectType string
newGithubReleaseUrl({
repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git',
title: 'foo',
});
// $ExpectType string
newGithubReleaseUrl({
repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git',
body: 'foo',
});
// $ExpectType string
newGithubReleaseUrl({
repoUrl: 'https://github.com/sindresorhus/new-github-release-url.git',
isPrerelease: true,
});

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",
"new-github-release-url-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }