mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
add polyfill-service types
This commit is contained in:
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// Type definitions for polyfill-service 3.25
|
||||
// Project: https://github.com/financial-times/polyfill-service#readme
|
||||
// Definitions by: Arturas Molcanovas <https://github.com/Alorel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export type PolyfillFlag = 'gated' | 'always';
|
||||
export type Unknown = 'polyfill' | 'ignore';
|
||||
|
||||
export interface Feature {
|
||||
flags?: PolyfillFlag[];
|
||||
}
|
||||
|
||||
export interface Features {
|
||||
[feature: string]: Feature;
|
||||
}
|
||||
|
||||
export interface GetPolyfillsOptions {
|
||||
uaString: string;
|
||||
features?: Features;
|
||||
excludes?: string[];
|
||||
}
|
||||
|
||||
export interface GetPolyfillStringOptions extends GetPolyfillsOptions {
|
||||
minify?: boolean;
|
||||
unknown?: Unknown;
|
||||
}
|
||||
|
||||
export interface PolyfillSpec {
|
||||
aliasOf?: Set<string>;
|
||||
flags: Set<PolyfillFlag>;
|
||||
}
|
||||
|
||||
export interface GetPolyfillsResponse {
|
||||
[name: string]: PolyfillSpec;
|
||||
}
|
||||
|
||||
export function listAllPolyfills(): Promise<ReadonlyArray<string>>;
|
||||
|
||||
export function getPolyfillString(options: GetPolyfillsOptions): Promise<string>;
|
||||
|
||||
export function getPolyfills(options: GetPolyfillsOptions): Promise<GetPolyfillsResponse>;
|
||||
@@ -0,0 +1,43 @@
|
||||
import * as svc from 'polyfill-service';
|
||||
|
||||
const o: svc.GetPolyfillsOptions = {
|
||||
uaString: ''
|
||||
};
|
||||
|
||||
o.excludes = ['foo'];
|
||||
o.features = {
|
||||
foo: {},
|
||||
bar: {flags: ['gated', 'always']}
|
||||
};
|
||||
|
||||
const o2: svc.GetPolyfillStringOptions = {
|
||||
uaString: ''
|
||||
};
|
||||
|
||||
o2.excludes = ['foo'];
|
||||
o2.features = {
|
||||
foo: {},
|
||||
bar: {flags: ['gated', 'always']}
|
||||
};
|
||||
o2.minify = true;
|
||||
o2.minify = false;
|
||||
o2.unknown = 'polyfill';
|
||||
o2.unknown = 'ignore';
|
||||
|
||||
svc.listAllPolyfills().then(v => {
|
||||
v[0].toLocaleLowerCase();
|
||||
});
|
||||
|
||||
svc.getPolyfillString(o2).then(s => {
|
||||
s.toLocaleUpperCase();
|
||||
});
|
||||
|
||||
svc.getPolyfills(o).then(r => {
|
||||
const p = r.Symbol;
|
||||
p.flags.clear();
|
||||
|
||||
const a = p.aliasOf;
|
||||
if (a) {
|
||||
a.clear();
|
||||
}
|
||||
});
|
||||
@@ -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",
|
||||
"polyfill-service-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user