@octokit/core
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -11,3 +11,3 @@ 'use strict'; | ||
const VERSION = "2.0.0"; | ||
const VERSION = "2.1.0"; | ||
@@ -14,0 +14,0 @@ class Octokit { |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "2.0.0"; | ||
export const VERSION = "2.1.0"; |
@@ -5,3 +5,3 @@ import { HookCollection } from "before-after-hook"; | ||
import { Constructor, OctokitOptions, OctokitPlugin, ReturnTypeOf } from "./types"; | ||
export { OctokitOptions } from "./types"; | ||
export { OctokitOptions, OctokitPlugin, ReturnTypeOf, Constructor } from "./types"; | ||
export declare class Octokit { | ||
@@ -8,0 +8,0 @@ static defaults(defaults: OctokitOptions): { |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "2.0.0"; | ||
export declare const VERSION = "2.1.0"; |
@@ -7,3 +7,3 @@ import { getUserAgent } from 'universal-user-agent'; | ||
const VERSION = "2.0.0"; | ||
const VERSION = "2.1.0"; | ||
@@ -10,0 +10,0 @@ class Octokit { |
{ | ||
"name": "@octokit/core", | ||
"description": "Extendable client for GitHub's REST & GraphQL APIs", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -379,2 +379,4 @@ # core.js | ||
<a name="a-note-on-typescript"></a> | ||
### ⚠️ A note on TypeScript | ||
@@ -385,5 +387,5 @@ | ||
```js | ||
import { Octokit, BuildYourOwnWorkaround } from '@octokit/core' | ||
import { Octokit, OctokitOptions, OctokitPlugin, ReturnTypeOf, Constructor } from '@octokit/core' | ||
const MyActionOctokitWithPlugins = Octokit | ||
const CoreWithPlugins = Octokit | ||
.plugin([ | ||
@@ -395,18 +397,21 @@ paginate, | ||
class MyActionOctokitWorkaround extends MyActionOctokitWithPlugins { | ||
static plugin<T extends BuildYourOwnWorkaround.TestPlugin | BuildYourOwnWorkaround.TestPlugin[]>(plugin: T) { | ||
class CoreWithPluginsWorkaround extends CoreWithPlugins { | ||
static plugin<T extends OctokitPlugin | OctokitPlugin[]>(pluginOrPlugins: T) { | ||
const currentPlugins = this.plugins; | ||
const newPlugins = Array.isArray(pluginOrPlugins) | ||
? pluginOrPlugins | ||
: [pluginOrPlugins]; | ||
const BaseWithPlugins = class extends this { | ||
static plugins = currentPlugins.concat(plugin); | ||
const NewOctokit = class extends this { | ||
static plugins = currentPlugins.concat( | ||
newPlugins.filter(plugin => !currentPlugins.includes(plugin)) | ||
); | ||
}; | ||
type Extension = BuildYourOwnWorkaround.ReturnTypeOf<T>; | ||
return BaseWithPlugins as typeof BaseWithPlugins & | ||
BuildYourOwnWorkaround.Constructor<Extension>; | ||
return NewOctokit as typeof NewOctokit & Constructor<ReturnTypeOf<T>>; | ||
} | ||
static defaults(defaults: BuildYourOwnWorkaround.Options) { | ||
static defaults(defaults: OctokitOptions) { | ||
return class OctokitWithDefaults extends this { | ||
constructor(options: BuildYourOwnWorkaround.Options = {}) { | ||
constructor(options: OctokitOptions = {}) { | ||
super(Object.assign({}, defaults, options)); | ||
@@ -418,3 +423,3 @@ } | ||
const MyActionOctokit = MyActionOctokitWorkaround | ||
const MyActionOctokit = CoreWithPluginsWorkaround | ||
.defaults({ | ||
@@ -421,0 +426,0 @@ authStrategy: require("@octokit/auth-action"), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46026
433