-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(typescript): do not permit unknown keys on
octokit
instance
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ************************************************************ | ||
// THIS CODE IS NOT EXECUTED. IT IS JUST FOR TYPECHECKING | ||
// ************************************************************ | ||
|
||
import { Octokit } from "../src"; | ||
|
||
export function pluginsTest() { | ||
// `octokit` instance does not permit unknown keys | ||
const octokit = new Octokit(); | ||
|
||
// @ts-expect-error Property 'unknown' does not exist on type 'Octokit'.(2339) | ||
octokit.unknown; | ||
|
||
const OctokitWithDefaults = Octokit.defaults({}); | ||
const octokitWithDefaults = new OctokitWithDefaults(); | ||
|
||
// Error: `octokitWithDefaults` does permit unknown keys | ||
// @ts-expect-error `.unknown` should not be typed as `any` | ||
octokitWithDefaults.unknown; | ||
|
||
const OctokitWithPlugin = Octokit.plugin(() => ({})); | ||
const octokitWithPlugin = new OctokitWithPlugin(); | ||
|
||
// Error: `octokitWithPlugin` does permit unknown keys | ||
// @ts-expect-error `.unknown` should not be typed as `any` | ||
octokitWithPlugin.unknown; | ||
|
||
const OctokitWithPluginAndDefaults = Octokit.plugin(() => ({ | ||
foo: 42, | ||
})).defaults({ | ||
baz: "daz", | ||
}); | ||
|
||
const octokitWithPluginAndDefaults = new OctokitWithPluginAndDefaults(); | ||
|
||
octokitWithPluginAndDefaults.foo; | ||
// @ts-expect-error `.unknown` should not be typed as `any` | ||
octokitWithPluginAndDefaults.unknown; | ||
} |