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