|
1 |
| -interface CommonOptions { |
2 |
| - /** |
3 |
| - * The issue body. |
4 |
| - */ |
5 |
| - readonly body?: string; |
| 1 | +declare namespace newGithubIssueUrl { |
| 2 | + interface CommonOptions { |
| 3 | + /** |
| 4 | + The issue body. |
| 5 | + */ |
| 6 | + readonly body?: string; |
6 | 7 |
|
7 |
| - /** |
8 |
| - * The issue title. |
9 |
| - */ |
10 |
| - readonly title?: string; |
| 8 | + /** |
| 9 | + The issue title. |
| 10 | + */ |
| 11 | + readonly title?: string; |
11 | 12 |
|
12 |
| - /** |
13 |
| - * Use an [issue template](https://help.github.com/articles/manually-creating-a-single-issue-template-for-your-repository/). |
14 |
| - * |
15 |
| - * @example |
16 |
| - * |
17 |
| - * 'unicorn.md' // If you want to use a template at `ISSUE_TEMPLATE/unicorn.md`. |
18 |
| - */ |
19 |
| - readonly template?: string; |
| 13 | + /** |
| 14 | + Use an [issue template](https://help.github.com/articles/manually-creating-a-single-issue-template-for-your-repository/). |
20 | 15 |
|
21 |
| - /** |
22 |
| - * The labels for the issue. |
23 |
| - * |
24 |
| - * *Requires the user to have the permission to add labels.* |
25 |
| - */ |
26 |
| - readonly labels?: string[]; |
| 16 | + @example |
| 17 | + ``` |
| 18 | + 'unicorn.md' // If you want to use a template at `ISSUE_TEMPLATE/unicorn.md`. |
| 19 | + ``` |
| 20 | + */ |
| 21 | + readonly template?: string; |
27 | 22 |
|
28 |
| - /** |
29 |
| - * The milestone for the issue. |
30 |
| - * |
31 |
| - * *Requires the user to have the permission to add milestone.* |
32 |
| - */ |
33 |
| - readonly milestone?: string; |
| 23 | + /** |
| 24 | + The labels for the issue. |
34 | 25 |
|
35 |
| - /** |
36 |
| - * The user to assign to the issue. |
37 |
| - * |
38 |
| - * *Requires the user to have the permission to add assignee.* |
39 |
| - */ |
40 |
| - readonly assignee?: string; |
| 26 | + _Requires the user to have the permission to add labels._ |
| 27 | + */ |
| 28 | + readonly labels?: string[]; |
41 | 29 |
|
42 |
| - /** |
43 |
| - * The projects to add the issue to. |
44 |
| - * The project reference format is `user/<project-number>`, for example, if the URL to the project is `https://github.com/sindresorhus/some-repo/projects/3`, the project reference would be `some-repo/3`. |
45 |
| - * |
46 |
| - * *Requires the user to have the permission to add projects.* |
47 |
| - */ |
48 |
| - readonly projects?: string[]; |
49 |
| -} |
| 30 | + /** |
| 31 | + The milestone for the issue. |
| 32 | +
|
| 33 | + _Requires the user to have the permission to add milestone._ |
| 34 | + */ |
| 35 | + readonly milestone?: string; |
| 36 | + |
| 37 | + /** |
| 38 | + The user to assign to the issue. |
| 39 | +
|
| 40 | + _Requires the user to have the permission to add assignee._ |
| 41 | + */ |
| 42 | + readonly assignee?: string; |
| 43 | + |
| 44 | + /** |
| 45 | + The projects to add the issue to. |
| 46 | + The project reference format is `user/<project-number>`, for example, if the URL to the project is `https://github.com/sindresorhus/some-repo/projects/3`, the project reference would be `some-repo/3`. |
| 47 | +
|
| 48 | + _Requires the user to have the permission to add projects._ |
| 49 | + */ |
| 50 | + readonly projects?: string[]; |
| 51 | + } |
| 52 | + |
| 53 | + interface RepoUrlOptions extends CommonOptions { |
| 54 | + /** |
| 55 | + The full URL to the repo. |
| 56 | + */ |
| 57 | + readonly repoUrl: string; |
| 58 | + } |
| 59 | + |
| 60 | + interface UserAndRepoOptions extends CommonOptions { |
| 61 | + /** |
| 62 | + GitHub username or organization. |
| 63 | + */ |
| 64 | + readonly user: string; |
| 65 | + |
| 66 | + /** |
| 67 | + GitHub repo. |
| 68 | + */ |
| 69 | + readonly repo: string; |
| 70 | + } |
50 | 71 |
|
51 |
| -interface RepoUrlOptions extends CommonOptions { |
52 | 72 | /**
|
53 |
| - * The full URL to the repo. |
54 |
| - */ |
55 |
| - readonly repoUrl: string; |
| 73 | + You are required to either specify the `repoUrl` option or both the `user` and `repo` options. |
| 74 | + */ |
| 75 | + type Options = RepoUrlOptions | UserAndRepoOptions; |
56 | 76 | }
|
57 | 77 |
|
58 |
| -interface UserAndRepoOptions extends CommonOptions { |
| 78 | +declare const newGithubIssueUrl: { |
59 | 79 | /**
|
60 |
| - * GitHub username or organization. |
61 |
| - */ |
62 |
| - readonly user: string; |
| 80 | + Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields. |
63 | 81 |
|
64 |
| - /** |
65 |
| - * GitHub repo. |
66 |
| - */ |
67 |
| - readonly repo: string; |
68 |
| -} |
| 82 | + @example |
| 83 | + ``` |
| 84 | + import newGithubIssueUrl = require('new-github-issue-url'); |
| 85 | + import opn = require('opn'); |
| 86 | +
|
| 87 | + const url = newGithubIssueUrl({ |
| 88 | + user: 'sindresorhus', |
| 89 | + repo: 'new-github-issue-url', |
| 90 | + body: '\n\n\n---\nI\'m a human. Please be nice.' |
| 91 | + }); |
| 92 | + //=> 'https://github.com/sindresorhus/new-github-issue-url/issues/new?body=%0A%0A%0A---%0AI%27m+a+human.+Please+be+nice.' |
| 93 | +
|
| 94 | + // Then open it |
| 95 | + opn(url); |
| 96 | + ``` |
| 97 | + */ |
| 98 | + (options: newGithubIssueUrl.Options): string; |
| 99 | + |
| 100 | + // TODO: Remove this for the next major release, refactor the whole definition to: |
| 101 | + // declare function newGithubIssueUrl(options: newGithubIssueUrl.Options): string; |
| 102 | + // export = newGithubIssueUrl; |
| 103 | + default: typeof newGithubIssueUrl; |
| 104 | +}; |
69 | 105 |
|
70 |
| -/** |
71 |
| - * You are required to either specify the `repoUrl` option or both the `user` and `repo` options. |
72 |
| - */ |
73 |
| -export type Options = RepoUrlOptions | UserAndRepoOptions |
74 |
| - |
75 |
| -/** |
76 |
| - * Generate a URL for opening a new GitHub issue with prefilled title, body, and other fields. |
77 |
| - * |
78 |
| - * @example |
79 |
| - * |
80 |
| - * import newGithubIssueUrl from 'new-github-issue-url'; |
81 |
| - * import opn from 'opn'; |
82 |
| - * |
83 |
| - * const url = newGithubIssueUrl({ |
84 |
| - * user: 'sindresorhus', |
85 |
| - * repo: 'new-github-issue-url', |
86 |
| - * body: '\n\n\n---\nI\'m a human. Please be nice.' |
87 |
| - * }); |
88 |
| - * //=> 'https://github.com/sindresorhus/new-github-issue-url/issues/new?body=%0A%0A%0A---%0AI%27m+a+human.+Please+be+nice.' |
89 |
| - * |
90 |
| - * // Then open it |
91 |
| - * opn(url); |
92 |
| - */ |
93 |
| -export default function newGithubIssueUrl(options: Options): string; |
| 106 | +export = newGithubIssueUrl; |
0 commit comments