Merge pull request #30023 from davecardwell/browserslist

[browserslist] Add initial types for browserslist
This commit is contained in:
Daniel Rosenwasser
2018-11-08 11:01:07 -08:00
committed by GitHub
4 changed files with 74 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import browserslist from "browserslist";
browserslist(); // $ExpectType string[]
browserslist(""); // $ExpectType string[]
browserslist([""]); // $ExpectType string[]
const opts: browserslist.Options[] = [
{},
{ path: "" },
{ env: "" },
{ stats: { "": { "": 0 } } },
{ config: "" },
{ ignoreUnknownVersions: false },
{ dangerousExtend: false }
];
for (const opt of opts) {
browserslist("", opt); // $ExpectType string[]
browserslist([""], opt); // $ExpectType string[]
}
browserslist.coverage([""]); // $ExpectType number
browserslist.coverage([""], { "": { "": 0 } }); // $ExpectType number
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for browserslist 4.3
// Project: https://github.com/browserslist/browserslist#readme
// Definitions by: Dave Cardwell <https://github.com/davecardwell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
declare namespace browserslist {
interface Browserslist {
(queries?: string | ReadonlyArray<string>, opts?: Options): string[];
coverage: (browsers: ReadonlyArray<string>, stats?: Stats) => number;
clearCaches: () => void;
}
interface Stats {
[browser: string]: {
[version: string]: number;
};
}
interface Options {
path?: string;
env?: string;
stats?: Stats;
config?: string;
ignoreUnknownVersions?: boolean;
dangerousExtend?: boolean;
}
}
declare var browserslist: browserslist.Browserslist;
export = browserslist;
+17
View File
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": ["index.d.ts", "browserslist-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }