Skip to content

Commit

Permalink
fix(typescript): agent client option is optional (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
philschatz authored and gr2m committed Mar 15, 2018
1 parent 3dd2d01 commit 4800e03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"generate-bundle-report": "webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html",
"prevalidate:ts": "npm run -s build:ts",
"validate:ts": "tsc --target es6 index.d.ts",
"postvalidate:ts": "tsc --noEmit test/typescript-validate.ts",
"deploy-docs": "gh-pages-with-token -d doc",
"semantic-release": "semantic-release",
"start-fixtures-server": "octokit-fixtures-server"
Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/index.d.ts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declare namespace Github {
requestMedia?: string;
rejectUnauthorized?: boolean;
family?: number;
agent: http.Agent;
agent?: http.Agent;
}

export interface AuthBasic {
Expand Down
20 changes: 20 additions & 0 deletions test/typescript-validate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as Octokit from '../'

// ************************************************************
// THIS CODE IS NOT EXECUTED. IT IS JUST FOR TYPECHECKING
// ************************************************************

// Test the TypeScript definition.
export default async function() {
// ************************************************************
// THIS CODE IS NOT EXECUTED. IT IS JUST FOR TYPECHECKING
// ************************************************************
new Octokit() // Check empty constructor
const octo = new Octokit({}) // Check that all arguments are optional
const repo = await octo.repos.get({owner: 'octokit', repo: 'rest.js'})
// Check Response
repo.data
repo.meta.link
repo.meta.etag
repo.meta.status
}

0 comments on commit 4800e03

Please sign in to comment.