types declaration for architect (#34993)

This commit is contained in:
Iván López Santiago
2019-04-26 02:55:41 +02:00
committed by Pranav Senthilnathan
parent 4b7b454e31
commit 32cd2e644a
4 changed files with 68 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import * as architect from 'architect';
architect.loadConfig('./fake-path', (err, config) => {
if (err) throw err;
const myApp = architect.createApp(config, (err, app) => {
if (err) throw err;
console.log('App ready');
});
myApp.on('service', (name, service) => {
console.log('Service registered %s', name);
});
myApp.on('plugin', (plugin) => {
console.log('Plugin registered', plugin);
});
myApp.on('ready', (app) => {
console.log('All plugins loaded');
});
});

23
types/architect/index.d.ts vendored Normal file
View File

@@ -0,0 +1,23 @@
// Type definitions for architect 0.1
// Project: https://github.com/c9/architect#readme
// Definitions by: Ivan Lopez <https://github.com/greuze>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { EventEmitter } from "events";
export type Config = any;
export type Service = any;
export type Plugin = any;
export function loadConfig(configPath: string, callback?: (err: Error, config: Config) => void): void;
export function createApp(config: Config, callback?: (err: Error, app: Architect) => void): Architect;
export interface Architect extends EventEmitter {
on(event: "service", listener: (name: string, service: Service, plugin: Plugin) => void): this;
on(event: "plugin", listener: (plugin: Plugin) => void): this;
on(event: "ready", listener: (app: Architect) => void): this;
on(event: "error", listener: (error: Error) => void): this;
getService(name: string): any;
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"architect-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }