[caniuse-api] Add initial types for caniuse-api

This commit is contained in:
Dave Cardwell 2018-10-24 17:45:50 -04:00
parent 9491811758
commit 1e315508b2
4 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import * as caniuse from "caniuse-api";
caniuse.features; // $ExpectType string[]
caniuse.getSupport(""); // $ExpectType BrowserSupport
caniuse.isSupported("", ""); // $ExpectType boolean
caniuse.isSupported("", [""]); // $ExpectType boolean
caniuse.find(""); // $ExpectType string[]
caniuse.getLatestStableBrowsers(); // $ExpectType string[]
caniuse.setBrowserScope(""); // $ExpectType void
caniuse.setBrowserScope([""]); // $ExpectType void
caniuse.getBrowserScope(); // $ExpectType string[]

32
types/caniuse-api/index.d.ts vendored Normal file
View File

@ -0,0 +1,32 @@
// Type definitions for caniuse-api 3.0
// Project: https://github.com/nyalab/caniuse-api#readme
// Definitions by: Dave Cardwell <https://github.com/davecardwell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export const features: string[];
export interface BrowserSupport {
[browser: string]: {
y?: number;
n?: number;
a?: number;
x?: number;
};
}
export function getSupport(feature: string): BrowserSupport;
export function isSupported(
feature: string,
browsers: string | ReadonlyArray<string>
): boolean;
export function find(query: string): string[];
export function getLatestStableBrowsers(): string[];
export function setBrowserScope(
browserscope: string | ReadonlyArray<string>
): void;
export function getBrowserScope(): string[];

View File

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

View File

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