🤖 Merge PR #62764 feat(gulp-live-server): add types by @robertmaier

This commit is contained in:
Robert Maier
2022-10-20 06:14:50 +02:00
committed by GitHub
parent c6de4f58a5
commit 9cefd61111
4 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import * as gls from 'gulp-live-server';
// $ExpectType GLSStatic
gls(['command']);
// $ExpectType GLSStatic
gls.static('folder', 123);
// $ExpectType GLSStatic
gls.new('script.js');

41
types/gulp-live-server/index.d.ts vendored Normal file
View File

@@ -0,0 +1,41 @@
// Type definitions for gulp-live-server 0.0
// Project: https://github.com/gimm/gulp-live-server
// Definitions by: robertmaier <https://github.com/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import type { spawn } from 'child_process';
import type { createServer } from 'https';
import type { Handler, Application } from 'express';
declare namespace gls {
interface LivereloadParams {
livereload?: string;
port?: number;
errorListener?: (error: Error) => void;
handler?: Handler;
app?: Application;
key?: NonNullable<Parameters<typeof createServer>[0]>['key'];
cert?: NonNullable<Parameters<typeof createServer>[0]>['cert'];
pfx?: NonNullable<Parameters<typeof createServer>[0]>['pfx'];
liveCSS?: boolean;
liveImg?: boolean;
prefix?: boolean;
dashboard?: boolean;
}
type Livereload = boolean | number | LivereloadParams;
interface GLSStatic {
start: (execPath?: string) => void;
notify: (event: { path: string }) => void;
stop: () => void;
static: (folder: string, port?: number) => GLSStatic;
new: (script: string) => GLSStatic;
}
type GLS = {
(args: Parameters<typeof spawn>[1], options?: Parameters<typeof spawn>[2], livereload?: Livereload): GLSStatic;
} & GLSStatic;
}
declare var gls: gls.GLS;
export = gls;

View File

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

View File

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