DefinitelyTyped/types/kap-plugin/kap-plugin-tests.ts
Connor Peet 98c1a4b208
add types for kap plugins (#42416)
* add types for kap plugins

* add support for new oauth functionality

* fixup! pr comments

* fixup! pr comments

* Update types/kap-plugin/index.d.ts

Co-Authored-By: Sindre Sorhus <sindresorhus@gmail.com>

* rebuild

Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2020-02-19 12:13:24 -08:00

36 lines
814 B
TypeScript

import { KapShareService } from 'kap-plugin';
interface Config {
name: string;
greeting: string;
accessToken?: string;
}
const service: KapShareService<Config> = {
title: 'My Plugin',
formats: ['apng', 'gif'],
config: {
name: {
type: 'string',
minLength: 1,
required: true,
default: 'Bilbo',
},
// $ExpectError
greeting: { type: 'string', default: true },
},
action: async context => {
// $ExpectType string
const name = context.config.get('name');
context.config.get('accessToken');
// $ExpectError
context.config.get('unknown');
await context.request(`https://example.com/greet/${name}`);
context.notify('Greeted example.com');
},
};