Add github-url-to-object (#27229)

Please fill in this template.

- [x] Use a meaningful title for the pull request. Include the name of the package modified.
- [x] Test the change in your own code. (Compile and run.)
- [x] Add or edit tests to reflect the change. (Run with `npm test`.)
- [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request).
- [x] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes).
- [x] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present).
- [x] The package does not already provide its own types, or cannot have its `.d.ts` files generated via `--declaration`
- [x] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
- [x] Create it with `dts-gen --dt`, not by basing it on an existing project.
- [x] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, `strictNullChecks`, and `strictFunctionTypes` set to `true`.
This commit is contained in:
Klaus Meinhardt 2018-07-15 21:46:24 +02:00 committed by Ryan Cavanaugh
parent 4ca4cba9ea
commit d37a85553f
4 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import gh = require('github-url-to-object');
gh('github:monkey/business'); // $ExpectType Result | null
gh('https://ghe.example.com:heroku/heroku-flags.git', {enterprise: true}); // $ExpectType Result | null
gh({url: 'git+https://github.com/monkey/business.git'}); // $ExpectType Result | null

25
types/github-url-to-object/index.d.ts vendored Normal file
View File

@ -0,0 +1,25 @@
// Type definitions for github-url-to-object 4.0
// Project: https://github.com/zeke/github-url-to-object#readme
// Definitions by: Klaus Meinhardt <https://github.com/ajafff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace gh {
interface Options {
enterprise?: boolean;
}
interface Result {
user: string;
repo: string;
branch: string;
https_url: string;
tarball_url: string;
clone_url: string;
travis_url: string;
api_url: string;
zip_url: string;
}
}
declare function gh(url: string | {url: string}, options?: gh.Options): gh.Result | null;
export = gh;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"github-url-to-object-tests.ts"
]
}

View File

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